Fehlerbehebung und File_write ergänzt
This commit is contained in:
parent
050977b49e
commit
43245b521a
@ -87,10 +87,14 @@ public:
|
|||||||
summ = summ + pow((speed_per_second[i] - arithmetic_mean), 2);
|
summ = summ + pow((speed_per_second[i] - arithmetic_mean), 2);
|
||||||
square_summ = square_summ + pow((speed_per_second[i] - square_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);
|
cubic_summ = cubic_summ + pow((speed_per_second[i] - cubic_mean), 2);
|
||||||
|
speed_min = min(speed_min, speed_per_second[i]);
|
||||||
|
speed_max = max(speed_max, speed_per_second[i]);
|
||||||
}
|
}
|
||||||
arithmetic_deviation = pow((summ / float(amount_saved - 1)), (1 / 2.0));
|
arithmetic_deviation = pow((summ / float(amount_saved - 1)), (1 / 2.0));
|
||||||
square_deviation = pow((square_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));
|
cubic_deviation = pow((cubic_summ / float(amount_saved - 1)), (1 / 2.0));
|
||||||
|
|
||||||
|
seconds_skipped = 60 - amount_saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
float arithmetic_mean;
|
float arithmetic_mean;
|
||||||
@ -101,14 +105,20 @@ public:
|
|||||||
|
|
||||||
float cubic_mean;
|
float cubic_mean;
|
||||||
float cubic_deviation;
|
float cubic_deviation;
|
||||||
|
|
||||||
|
float speed_min;
|
||||||
|
float speed_max;
|
||||||
|
|
||||||
|
int seconds_skipped;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct anemomenter_maessurement {
|
struct anemomenter_maessurement {
|
||||||
public:
|
public:
|
||||||
int pin = 0;
|
|
||||||
int seconds_saved = 0;
|
void setup(int pin) {
|
||||||
int minutes_saved = 0;
|
this->reed_contact = Bounce(pin, 10);
|
||||||
|
}
|
||||||
|
|
||||||
void meassure() {
|
void meassure() {
|
||||||
if (reed_contact.update() && reed_contact.fallingEdge()) {
|
if (reed_contact.update() && reed_contact.fallingEdge()) {
|
||||||
@ -117,20 +127,30 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void save_wind_speed() {
|
void save_wind_speed() {
|
||||||
wind_speed_per_second[seconds_saved] = 0.4 * count_per_second;
|
wind_speed_per_second[saved_seconds] = 0.4 * count_per_second;
|
||||||
seconds_saved++;
|
saved_seconds++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void calculate() {
|
void calculate() {
|
||||||
values[minutes_saved].calculate(wind_speed_per_second, seconds_saved);
|
values[saved_minutes].calculate(wind_speed_per_second, saved_seconds);
|
||||||
seconds_saved = 0;
|
saved_seconds = 0;
|
||||||
minutes_saved++;
|
saved_minutes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print() {
|
void file_print() {
|
||||||
|
|
||||||
|
for (int i = 0; i < saved_minutes; i++) {
|
||||||
|
file.printf("Min: %f,\tMax: %f,\t", values[i].speed_min, values[i].speed_max);
|
||||||
|
file.printf("Arith. Mittel: % f,\tStandard Abw.: %f\t", values[i].arithmetic_mean, values[i].arithmetic_deviation);
|
||||||
|
file.printf("Quadr. Mittel: % f,\tStandard Abw.: %f\t", values[i].square_mean, values[i].square_deviation);
|
||||||
|
file.printf("Kub. Mittel: %f,\tStandard Abw.: %f\t", values[i].cubic_mean, values[i].cubic_deviation);
|
||||||
|
file.printf("Übersprungene Sek.: %i\n", values[i].seconds_skipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file.printf("Übersprungene Min.: %i\n", 60 - saved_minutes);
|
||||||
|
|
||||||
|
saved_minutes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int count_per_second = 0;
|
int count_per_second = 0;
|
||||||
@ -138,11 +158,10 @@ private:
|
|||||||
int saved_minutes = 0;
|
int saved_minutes = 0;
|
||||||
float wind_speed_per_second[60];
|
float wind_speed_per_second[60];
|
||||||
|
|
||||||
|
Bounce reed_contact;
|
||||||
|
|
||||||
calculations values[60];
|
calculations values[60];
|
||||||
|
|
||||||
|
|
||||||
Bounce reed_contact = Bounce(pin, 10);
|
|
||||||
|
|
||||||
}anemometer_1, anemometer_2, anemometer_3;
|
}anemometer_1, anemometer_2, anemometer_3;
|
||||||
|
|
||||||
|
|
||||||
@ -178,11 +197,19 @@ void write_sd() {
|
|||||||
|
|
||||||
file.println("Messdaten von Windmessmasst");
|
file.println("Messdaten von Windmessmasst");
|
||||||
file.println();
|
file.println();
|
||||||
file.println("Data logger : Teensy 4.2");
|
file.println("Data logger : Teensy 4.1");
|
||||||
file.println(software_name);
|
file.println(software_name);
|
||||||
file.println();
|
file.println();
|
||||||
file.println("");
|
|
||||||
|
|
||||||
|
file.println("Anemometer_1 Werte:");
|
||||||
|
anemometer_1.file_print();
|
||||||
|
file.println("Anemometer_2 Werte:");
|
||||||
|
anemometer_2.file_print();
|
||||||
|
file.println("Anemometer_3 Werte:");
|
||||||
|
anemometer_3.file_print();
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
Serial.println("Ende des Schreibvorgangs");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -205,6 +232,7 @@ void every_minute() {
|
|||||||
|
|
||||||
void every_hour() {
|
void every_hour() {
|
||||||
|
|
||||||
|
write_sd();
|
||||||
last_hour = hour();
|
last_hour = hour();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,9 +266,9 @@ void setup()
|
|||||||
sd.initErrorHalt(&Serial);
|
sd.initErrorHalt(&Serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
anemometer_1.pin = 2;
|
anemometer_1.setup(2);
|
||||||
anemometer_2.pin = 9;
|
anemometer_2.setup(9);
|
||||||
anemometer_3.pin = 22;
|
anemometer_3.setup(22);
|
||||||
|
|
||||||
|
|
||||||
Serial.println("Messung startet");
|
Serial.println("Messung startet");
|
||||||
@ -260,13 +288,12 @@ void loop()
|
|||||||
anemometer_3.meassure();
|
anemometer_3.meassure();
|
||||||
|
|
||||||
if (second() != last_second) {
|
if (second() != last_second) {
|
||||||
|
every_second();
|
||||||
if (minute() != last_minute) {
|
if (minute() != last_minute) {
|
||||||
|
every_minute();
|
||||||
if (hour() != last_hour) {
|
if (hour() != last_hour) {
|
||||||
every_hour();
|
every_hour();
|
||||||
}
|
}
|
||||||
every_minute();
|
|
||||||
}
|
}
|
||||||
every_second();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user