Update 'Teensy4.1_Datalogger new.ino'
This commit is contained in:
parent
89b080d235
commit
d5ee9e3b3f
@ -81,7 +81,7 @@ public:
|
||||
}
|
||||
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));
|
||||
cubic_mean = pow((cubic_summ / float(amount_saved)), (1 / 3.0));
|
||||
|
||||
summ = 0;
|
||||
square_summ = 0;
|
||||
@ -100,6 +100,10 @@ public:
|
||||
square_deviation = pow((square_summ / float(amount_saved - 1)), (1 / 2.0));
|
||||
cubic_deviation = pow((cubic_summ / float(amount_saved - 1)), (1 / 2.0));
|
||||
|
||||
time_stemp_seconds = second();
|
||||
time_stemp_minutes = minute();
|
||||
time_stemp_hours = hour();
|
||||
|
||||
seconds_skipped = 60 - amount_saved;
|
||||
}
|
||||
|
||||
@ -116,6 +120,10 @@ public:
|
||||
float speed_max;
|
||||
|
||||
int seconds_skipped;
|
||||
|
||||
short int time_stemp_seconds;
|
||||
short int time_stemp_minutes;
|
||||
short int time_stemp_hours;
|
||||
};
|
||||
|
||||
|
||||
@ -126,12 +134,27 @@ public:
|
||||
}
|
||||
|
||||
void setup_anemometer(int pin) {
|
||||
this->reed_contact = Bounce(pin, 10);
|
||||
anemometer_pin = pin;
|
||||
pinMode(pin, INPUT);
|
||||
//this->reed_contact = Bounce(pin, 1);
|
||||
}
|
||||
|
||||
void meassure() {
|
||||
if (reed_contact.update() && reed_contact.fallingEdge()) {
|
||||
/*if (reed_contact.update() && reed_contact.fallingEdge()) {
|
||||
count_per_second++;
|
||||
}*/
|
||||
if(digitalRead(anemometer_pin) == HIGH){
|
||||
this_signal = 1;
|
||||
}
|
||||
else{
|
||||
this_signal = 0;
|
||||
}
|
||||
|
||||
if(this_signal != last_signal){
|
||||
if(this_signal == 1){
|
||||
count_per_second++;
|
||||
}
|
||||
last_signal = this_signal;
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,16 +171,17 @@ public:
|
||||
}
|
||||
|
||||
void file_print() {
|
||||
file.printf("Min:\tMax:\tArith. Mittel:\tStandard Abw.:\tQuadr. Mittel:\tStandard Abw.:\tKub. Mittel:\tStandard Abw.:\tÜbersprungene Sek.:\n");
|
||||
file.printf("Time Stemp:\tMin:\tMax:\tArith. Mittel:\tStandard Abw.:\tQuadr. Mittel:\tStandard Abw.:\tKub. Mittel:\tStandard Abw.:\tÜbersprungene Sek.:\n");
|
||||
for (int i = 0; i < saved_minutes; i++) {
|
||||
file.printf("%d:%d:%d\t\t", values[i].time_stemp_hours, values[i].time_stemp_minutes, values[i].time_stemp_seconds);
|
||||
file.printf("%.2f\t%.2f\t", values[i].speed_min, values[i].speed_max);
|
||||
file.printf("%.2f\t%.2f\t", values[i].arithmetic_mean, values[i].arithmetic_deviation);
|
||||
file.printf("%.2f\t%.2f\t", values[i].square_mean, values[i].square_deviation);
|
||||
file.printf("%.2f\t%.2f\t", values[i].cubic_mean, values[i].cubic_deviation);
|
||||
file.printf("%.2f\t\t%.2f\t\t", values[i].arithmetic_mean, values[i].arithmetic_deviation);
|
||||
file.printf("%.2f\t\t%.2f\t\t", values[i].square_mean, values[i].square_deviation);
|
||||
file.printf("%.2f\t\t%.2f\t\t", values[i].cubic_mean, values[i].cubic_deviation);
|
||||
file.printf("%i\n", values[i].seconds_skipped);
|
||||
}
|
||||
|
||||
file.printf("Übersprungene Min.: %i\n", 60 - saved_minutes);
|
||||
file.printf("Übersprungene Min.: %i\n\n", 60 - saved_minutes);
|
||||
|
||||
saved_minutes = 0;
|
||||
}
|
||||
@ -166,9 +190,12 @@ private:
|
||||
int count_per_second = 0;
|
||||
int saved_seconds = 0;
|
||||
int saved_minutes = 0;
|
||||
int last_signal = 0;
|
||||
int this_signal = 0;
|
||||
float wind_speed_per_second[60];
|
||||
int anemometer_pin;
|
||||
|
||||
Bounce reed_contact = Bounce(2, 10);
|
||||
//Bounce reed_contact = Bounce(2, 1);
|
||||
|
||||
calculations values[60];
|
||||
|
||||
@ -229,7 +256,7 @@ public:
|
||||
saved_seconds = 0;
|
||||
}
|
||||
void file_print() {
|
||||
file.printf("\nWindruchtung in ° Winkel:\n");
|
||||
file.printf("\nWindrichtung in ° Winkel:\n");
|
||||
for (int i = 0; i < saved_minutes; i++) {
|
||||
file.printf("%.2f °\n", values[i]);
|
||||
}
|
||||
@ -333,7 +360,7 @@ void every_hour() {
|
||||
|
||||
static int first_time = 1;
|
||||
|
||||
if (hour() == 0 || first_time == 1) {
|
||||
if (hour() == 1 || first_time == 1) {
|
||||
write_sd(1);
|
||||
first_time = 0;
|
||||
}
|
||||
@ -376,7 +403,6 @@ void setup()
|
||||
anemometer_1.setup_anemometer(2);
|
||||
anemometer_2.setup_anemometer(9);
|
||||
anemometer_3.setup_anemometer(22);
|
||||
seconds_for_blink = 0;
|
||||
|
||||
Serial.println("Messung startet");
|
||||
last_second = second();
|
||||
|
Loading…
x
Reference in New Issue
Block a user