Browse Source

Projektdateien hinzufügen.

master
Julian Graf 1 year ago
parent
commit
181ba992fb

+ 235
- 0
Teensy4.1_Datalogger new.ino View File

@@ -0,0 +1,235 @@
// Visual Micro is in vMicro>General>Tutorial Mode
//
/*
Name: Teensy4.1_Datalogger new.ino
Created: 03.05.2022 12:04:32
Author: GAMINGMASHEEN\Julian Graf
*/

#include <SdFat.h>
#include <TimeLib.h>
#include <Bounce.h>

#define SD_FAT_TYPE 3

#ifndef SDCARD_SS_PIN
const uint8_t SD_CS_PIN = SS;
#else // SDCARD_SS_PIN
// Assume built-in SD is used.
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
#endif // SDCARD_SS_PIN

#if HAS_SDIO_CLASS
#define SD_CONFIG SdioConfig(FIFO_SDIO)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
#else // HAS_SDIO_CLASS
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
#endif // HAS_SDIO_CLASS

#if SD_FAT_TYPE == 0
SdFat sd;
File file;
#elif SD_FAT_TYPE == 1
SdFat32 sd;
File32 file;
#elif SD_FAT_TYPE == 2
SdExFat sd;
ExFile file;
#elif SD_FAT_TYPE == 3
SdFs sd;
FsFile file;
#else // SD_FAT_TYPE
#error Invalid SD_FAT_TYPE
#endif // SD_FAT_TYPE

// Define User Types below here or use a .h file
//
const char software_name[] = "Software: Teensy_datalog V.2";
const int min_voltage_batterie = 13;
const int fixed_resistor_temperatur = 500;

const int power_Temp_sensor = 34, power_Windfahne = 36, LED_Fail = 24,
LED_Write = 5, LED_Normal = 6, LED_Batterie = 7,
taster_manuell_speichern = 28, Windfahne = 20, T_sensor_input = 17, Batterie_input = 38;

int last_second, last_minute, last_hour;


struct calculations {
private:

float summ;
float square_summ;
float cubic_summ;

public:

void calculate(float speed_per_second[60], int amount_saved) {
summ = 0;
square_summ = 0;
cubic_summ = 0;

for (int i = 0; i < amount_saved; i++) {
summ = summ + speed_per_second[i];
square_summ = square_summ + pow(speed_per_second[i], 2);
cubic_summ = cubic_summ + pow(speed_per_second[i], 3);
}
arithmetic_mean = summ / float(amount_saved);
square_mean = pow((square_summ / float(amount_saved)), (1 / 2.0));
cubic_mean = pow((cubic_mean / float(amount_saved)), (1 / 3.0));

summ = 0;
square_summ = 0;
cubic_summ = 0;

for (int i = 0; i < amount_saved; i++) {
summ = summ + pow((speed_per_second[i] - arithmetic_mean), 2);
square_summ = square_summ + pow((speed_per_second[i] - square_mean), 2);
cubic_summ = cubic_summ + pow((speed_per_second[i] - cubic_mean), 2);
}
arithmetic_deviation = pow((summ / float(amount_saved - 1)), (1 / 2.0));
square_deviation = pow((square_summ / float(amount_saved - 1)), (1 / 2.0));
cubic_deviation = pow((cubic_summ / float(amount_saved - 1)), (1 / 2.0));
}
float arithmetic_mean;
float arithmetic_deviation;
float square_mean;
float square_deviation;
float cubic_mean;
float cubic_deviation;
};


struct anemomenter_maessurement {
public:
int pin = 0;
int seconds_saved = 0;
int minutes_saved = 0;

void meassure() {
if (reed_contact.update() && reed_contact.fallingEdge()) {
count_per_second++;
}
}
void save_wind_speed() {
wind_speed_per_second[seconds_saved] = 0.4 * count_per_second;
seconds_saved++;
}

void calculate() {
values[minutes_saved].calculate(wind_speed_per_second, seconds_saved);
seconds_saved = 0;
minutes_saved++;
}

private:
int count_per_second = 0;
int saved_seconds = 0;
int saved_minutes = 0;
float wind_speed_per_second[60];

calculations values[60];


Bounce reed_contact = Bounce(pin, 10);

}anemometer_1, anemometer_2, anemometer_3;



// Define Function Prototypes that use User Types below here or use a .h file
//


// Define Functions below here or use other .ino or cpp files
//
void every_second() {

anemometer_1.save_wind_speed();
anemometer_2.save_wind_speed();
anemometer_3.save_wind_speed();

last_second = second();
}

void every_minute() {
anemometer_1.calculate();
anemometer_2.calculate();
anemometer_3.calculate();

last_minute = minute();
}

void every_hour() {

last_hour = hour();
}

// The setup() function runs once each time the micro-controller starts
void setup()
{
//set input and output
pinMode(Windfahne, INPUT);
pinMode(Batterie_input, INPUT);
pinMode(T_sensor_input, INPUT);
pinMode(taster_manuell_speichern, INPUT);
pinMode(LED_Write, OUTPUT);
pinMode(LED_Fail, OUTPUT);
pinMode(LED_Normal, OUTPUT);
pinMode(LED_Batterie, OUTPUT);
pinMode(power_Temp_sensor, OUTPUT);
pinMode(power_Windfahne, OUTPUT);

setSyncProvider((getExternalTime)Teensy3Clock.get());

Serial.begin(9600);
Serial.println("Teensy 4.1-Datalogger gestartet");
if (timeStatus() != timeSet) {
Serial.println("Fehler bei Synchronisieren der Uhrzeit mit der RTC");
digitalWrite(LED_Fail, HIGH);
return;
}
Serial.println("Uhrzeit erfolgreich mit der RTC synchronisiert");
if (!sd.begin(SD_CONFIG)) {
digitalWrite(LED_Fail, HIGH);
sd.initErrorHalt(&Serial);
}
anemometer_1.pin = 2;
anemometer_2.pin = 9;
anemometer_3.pin = 22;


Serial.println("Messung startet");
last_second = second();
while (last_second == second()) {};
last_second = second();
last_minute = minute();
last_hour = hour();
}

// Add the main program code into the continuous loop() function
void loop()
{
anemometer_1.meassure();
anemometer_2.meassure();
anemometer_3.meassure();

if (second() != last_second) {
if (minute() != last_minute) {
if (hour() != last_hour) {
every_hour();
}
every_minute();
}
every_second();
}

}

+ 31
- 0
Teensy4.1_Datalogger new.sln View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32421.90
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Teensy4.1_Datalogger new", "Teensy4.1_Datalogger new.vcxproj", "{2E6F448E-0966-4C65-8DA5-8AFD46F294D2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Teensy4.1-Datenlogger-Software", "..\Projekt\Teensy4.1-Datenlogger-Software\Teensy4.1-Datenlogger-Software.vcxproj", "{C5F80730-F44F-4478-BDAE-6634EFC2CA88}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2E6F448E-0966-4C65-8DA5-8AFD46F294D2}.Debug|x86.ActiveCfg = Debug|Win32
{2E6F448E-0966-4C65-8DA5-8AFD46F294D2}.Debug|x86.Build.0 = Debug|Win32
{2E6F448E-0966-4C65-8DA5-8AFD46F294D2}.Release|x86.ActiveCfg = Release|Win32
{2E6F448E-0966-4C65-8DA5-8AFD46F294D2}.Release|x86.Build.0 = Release|Win32
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Debug|x86.ActiveCfg = Debug|Win32
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Debug|x86.Build.0 = Debug|Win32
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Release|x86.ActiveCfg = Release|Win32
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {349760AA-D265-433D-A4B4-7278AE8A0FCC}
EndGlobalSection
EndGlobal

+ 119
- 0
Teensy4.1_Datalogger new.vcxproj
File diff suppressed because it is too large
View File


+ 25
- 0
Teensy4.1_Datalogger new.vcxproj.filters View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="Teensy4.1_Datalogger new.ino" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="__vm\.Teensy4.1_Datalogger new.vsarduino.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

+ 99
- 0
__vm/.Teensy4.1_Datalogger new.vsarduino.h View File

@@ -0,0 +1,99 @@
/*
Editor: https://www.visualmicro.com/
This file is for intellisense purpose only.
Visual micro (and the arduino ide) ignore this code during compilation. This code is automatically maintained by visualmicro, manual changes to this file will be overwritten
The contents of the _vm sub folder can be deleted prior to publishing a project
All non-arduino files created by visual micro and all visual studio project or solution files can be freely deleted and are not required to compile a sketch (do not delete your own code!).
Note: debugger breakpoints are stored in '.sln' or '.asln' files, knowledge of last uploaded breakpoints is stored in the upload.vmps.xml file. Both files are required to continue a previous debug session without needing to compile and upload again
Hardware: Teensy 4.0 (teensy40), Platform=teensy4, Package=teensy
*/

#if defined(_VMICRO_INTELLISENSE)

#ifndef _VSARDUINO_H_
#define _VSARDUINO_H_
#define __HARDWARE_imxrt1062__
#define __HARDWARE_IMXRT1062__
#define _VMDEBUG 1
#define __IMXRT1062__
#define TEENSYDUINO 148
#define ARDUINO 108010
#define F_CPU 600000000
#define USB_SERIAL
#define LAYOUT_US_ENGLISH
#define __cplusplus 201103L
#undef __cplusplus
#define __cplusplus 201103L


#define __arm__
#define __ARM__
#define __attribute__(x)
typedef void *__builtin_va_list;
#define __extension__
#define __ATTR_PURE__
#define __ATTR_CONST__
#define __inline__
#define __asm__(x)
#define __volatile__
#define NEW_H
#undef _WIN32
#define __STDC__
//#define __GNUC__ 2
//#define __GNUC_MINOR__ 5
#define __ARM_ARCH_7EM__

extern int at_quick_exit(void (*f)(void));
int at_quick_exit(void (*f)(void)) {
}
extern int quick_exit(void (*f)(void));
int quick_exit(void (*f)(void)) {
}



#define __INT64_TYPE__ 8
#define __INTPTR_TYPE__ 4
#define __INT32_TYPE__ 4

typedef long intptr_t;
typedef long __intptr_t;
typedef unsigned long __uintptr_t;
typedef long __int32_t;
typedef unsigned long __uint32_t;
typedef unsigned short __uint16_t;
typedef short __int16_t;
typedef unsigned short __uint8_t;
typedef short __int8_t;
typedef unsigned long __uint64_t;
typedef double __int64_t;
typedef unsigned long uint64_t;
typedef double int64_t;
typedef unsigned short uint8_t;
typedef short int8_t;

typedef unsigned int uint16_t;
typedef short int16_t;
typedef long __int32_t;
typedef unsigned long __uint32_t;

#define at_quick_exit(x)

#include "arduino.h"
#define abs(x) ((x)>0?(x):-(x))
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))

#define __asm__

#define __disable_irq() __asm__ volatile("");
#define __enable_irq() __asm__ volatile("");


#include "Teensy4.1_Datalogger new.ino"
#endif
#endif

+ 37
- 0
__vm/Compile.vmps.xml
File diff suppressed because it is too large
View File


+ 9
- 0
__vm/Configuration.Debug.vmps.xml
File diff suppressed because it is too large
View File


Loading…
Cancel
Save