Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
f11:technik:arduino:programme:data-logger-dl2fp [2013/03/04 01:11] dd7dka angelegt |
f11:technik:arduino:programme:data-logger-dl2fp [2019/09/29 12:03] (aktuell) |
||
---|---|---|---|
Zeile 2: | Zeile 2: | ||
FIXME ToDo: DL2FP | FIXME ToDo: DL2FP | ||
+ | |||
+ | Zusätzlich wird noch die PC Software gobetwino benötigt. [[http:// | ||
+ | |||
+ | ===== Version 1 ===== | ||
<code c Womo_Volt_messen.ino> | <code c Womo_Volt_messen.ino> | ||
Zeile 132: | Zeile 136: | ||
} | } | ||
// ENDE | // ENDE | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Version 2 ===== | ||
+ | |||
+ | <code c Data_Logger.ino> | ||
+ | /* | ||
+ | (c) by DL2FP 2014-07-25 10:45:00 | ||
+ | Datenlogger für 2 x 6 Messtellen | ||
+ | | ||
+ | !! Die Pin Belgung ist am Ende des Programmes zu finden. !! | ||
+ | */ | ||
+ | // ------------- | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | # | ||
+ | # | ||
+ | | ||
+ | | ||
+ | const int Taster = 12; | ||
+ | int A=0; | ||
+ | void setup() | ||
+ | lcd.begin(16, | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | pinMode(13, OUTPUT); | ||
+ | pinMode (Taster, INPUT_PULLUP); | ||
+ | // initial Time | ||
+ | if (timeStatus() == timeNotSet) { // T1405944000 startzeit setzen | ||
+ | const long inittime=1405944000; | ||
+ | } | ||
+ | int A=0; | ||
+ | } | ||
+ | // ------------------------------ Ende VOID - SETUP ------------------------------------- | ||
+ | void loop(){ | ||
+ | // | ||
+ | | ||
+ | // Taster abfragen und die Menues durchschalten | ||
+ | int buttonState; | ||
+ | int lastButtonState = LOW; // the previous reading from the input pin | ||
+ | long lastDebounceTime = 0; // the last time the output pin was toggled | ||
+ | long debounceDelay = 50; // the debounce time; increase if the output flickers | ||
+ | int reading = digitalRead (Taster); | ||
+ | | ||
+ | if (reading != lastButtonState) { | ||
+ | lastDebounceTime = millis(); | ||
+ | } | ||
+ | if ((millis() - lastDebounceTime) > debounceDelay) { | ||
+ | // whatever the reading is at, it's been there for longer | ||
+ | // than the debounce delay, so take it as the actual current state: | ||
+ | buttonState = reading; | ||
+ | } | ||
+ | |||
+ | if (A > 7) { // variable A steuert die swich case Menues. | ||
+ | | ||
+ | } | ||
+ | if ((reading == LOW) && (reading == lastButtonState)) { // Taster gedrückt | ||
+ | | ||
+ | | ||
+ | } | ||
+ | else { | ||
+ | delay(1000); | ||
+ | } | ||
+ | | ||
+ | // swichcase schaltet in die Menues | ||
+ | switch (A) { | ||
+ | case 1: | ||
+ | | ||
+ | delay(500); | ||
+ | break; | ||
+ | case 2: // ??? | ||
+ | menue2(); | ||
+ | | ||
+ | break; | ||
+ | case 3: // ??? | ||
+ | menue3(); | ||
+ | | ||
+ | break; | ||
+ | case 4: // Jahr und sekunde aendern | ||
+ | menue4(); | ||
+ | | ||
+ | break; | ||
+ | case 5: // Datum aendern | ||
+ | menue5(); | ||
+ | | ||
+ | | ||
+ | case 6: // Zeit aendern | ||
+ | menue6(); | ||
+ | | ||
+ | break; | ||
+ | case 7: | ||
+ | hauptmenue(); | ||
+ | A=0; | ||
+ | | ||
+ | break; | ||
+ | default: | ||
+ | hauptmenue(); | ||
+ | delay(1000); | ||
+ | } | ||
+ | } | ||
+ | // ------------------------------ Ende VOID - LOOP --------------------------------------------------------- | ||
+ | // Unterprogramme: | ||
+ | // | ||
+ | void digitalClockSerial(){ | ||
+ | // digital clock display of the time | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | } | ||
+ | // | ||
+ | void digitalClockLcdDatum(){ | ||
+ | // digital clock display of the time | ||
+ | | ||
+ | |||
+ | | ||
+ | } | ||
+ | // | ||
+ | void digitalClockLcdZeit(){ | ||
+ | // digital clock display of the time | ||
+ | | ||
+ | |||
+ | | ||
+ | } | ||
+ | // | ||
+ | void digitalClockLcdyyyyss(){ | ||
+ | // digital clock display of the time | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | } | ||
+ | // | ||
+ | void digitalClockLcdHauptmenue(){ | ||
+ | // digital clock display of the time | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | } | ||
+ | // | ||
+ | void digitalClockDisplay(){ | ||
+ | // digital clock display of the time | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | } | ||
+ | // | ||
+ | void printDigits(int digits){ | ||
+ | // utility function for digital clock displaySerial: | ||
+ | | ||
+ | Serial.print(' | ||
+ | Serial.print(digits); | ||
+ | } | ||
+ | // | ||
+ | void printlcdDigits(int digits){ | ||
+ | // utility function for digital clock displayLCD: prints preceding colon and leading 0 | ||
+ | | ||
+ | lcd.print(' | ||
+ | lcd.print(digits); | ||
+ | } | ||
+ | // | ||
+ | void morseout() { | ||
+ | // Status Ausgabe auf Lautsprecher or LED Pin 13 in morsecode | ||
+ | // Meßwert einlesen und für die Anzeige umrechnen | ||
+ | int M06 = analogRead(A5); | ||
+ | Morse morse(13, 20, 1); | ||
+ | if (AnzM06 < 10.00) morse.sendmsg(" | ||
+ | if (AnzM06 > 14.40) morse.sendmsg(" | ||
+ | if (AnzM06 > 13.80 && AnzM06 < 14.40) morse.sendmsg(" | ||
+ | if (AnzM06 > 12.00 && AnzM06 < 13.80) morse.sendmsg(" | ||
+ | if (AnzM06 > 10.00 && AnzM06 < 12.00) morse.sendmsg(" | ||
+ | } | ||
+ | // | ||
+ | void AusgabeLcdMesswerte() { | ||
+ | // Meßwert einlesen und für die Anzeige umrechnen | ||
+ | int M01 = analogRead(A0); | ||
+ | int M02 = analogRead(A1); | ||
+ | int M03 = analogRead(A2); | ||
+ | int M04 = analogRead(A3); | ||
+ | int M05= analogRead(A4); | ||
+ | int M06= analogRead(A5); | ||
+ | int M07= analogRead(A0); | ||
+ | int M08= analogRead(A1); | ||
+ | int M09= analogRead(A2); | ||
+ | int M10= analogRead(A3); | ||
+ | int M11= analogRead(4); | ||
+ | int M12= analogRead(A5); | ||
+ | // | ||
+ | lcd.clear(); | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | // | ||
+ | lcd.clear(); | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | // | ||
+ | void AusgabeSerial() { | ||
+ | // Meßwert einlesen und für die Anzeige umrechnen | ||
+ | int M01 = analogRead(A0); | ||
+ | int M02 = analogRead(A1); | ||
+ | int M03 = analogRead(A2); | ||
+ | int M04 = analogRead(A3); | ||
+ | int M05= analogRead(A4); | ||
+ | int M06= analogRead(A5); | ||
+ | int M07= analogRead(A0); | ||
+ | int M08= analogRead(A1); | ||
+ | int M09= analogRead(A2); | ||
+ | int M10= analogRead(A3); | ||
+ | int M11= analogRead(4); | ||
+ | int M12= analogRead(A5); | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | Serial.println (); | ||
+ | } | ||
+ | // | ||
+ | void hauptmenue() { | ||
+ | // Display-LCD-hauptmenue | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print | ||
+ | lcd.setCursor(16, | ||
+ | lcd.println(" | ||
+ | lcd.setCursor(16, | ||
+ | digitalClockLcdHauptmenue(); | ||
+ | } | ||
+ | // | ||
+ | void menue1() { | ||
+ | // Display-LCD-menue1 | ||
+ | AusgabeLcdMesswerte(); | ||
+ | delay(500); | ||
+ | } | ||
+ | // | ||
+ | void menue2() { | ||
+ | // Display-LCD-menue2 | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(0, | ||
+ | lcd.println(" | ||
+ | lcd.setCursor(16, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(16, | ||
+ | digitalClockDisplay(); | ||
+ | } | ||
+ | // | ||
+ | void menue3() { | ||
+ | // Display-LCD-menue3 | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(0, | ||
+ | lcd.println(" | ||
+ | lcd.setCursor(16, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(16, | ||
+ | digitalClockDisplay(); | ||
+ | } | ||
+ | // | ||
+ | void menue4() { | ||
+ | // Display-LCD-menue4 Jahr + Sekunde aendern | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print | ||
+ | lcd.setCursor(16, | ||
+ | lcd.println(" | ||
+ | lcd.setCursor(16, | ||
+ | digitalClockLcdyyyyss(); | ||
+ | | ||
+ | long newRight; | ||
+ | long positionRight; | ||
+ | | ||
+ | if (newRight != positionRight) { | ||
+ | positionRight = newRight; | ||
+ | } | ||
+ | | ||
+ | // Datum aendern | ||
+ | // T1405944000 init-Time = 21.07.2014 12:00:00, 1405944000 wird mit (now) gelesen. | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | if (positionRight > 500&& | ||
+ | mytime=mytime+change_sec; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | if (positionRight < 500&& | ||
+ | mytime=mytime-change_sec; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | if (positionRight > 520) { | ||
+ | mytime=mytime+change_yy; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | if (positionRight < 480) { | ||
+ | mytime=mytime-change_yy; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | // | ||
+ | void menue5() { | ||
+ | // Display-LCD-menue5 Datum aendern | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(16, | ||
+ | lcd.println(" | ||
+ | lcd.setCursor(16, | ||
+ | digitalClockLcdDatum(); | ||
+ | | ||
+ | long newRight; | ||
+ | long positionRight; | ||
+ | | ||
+ | if (newRight != positionRight) { | ||
+ | positionRight = newRight; | ||
+ | } | ||
+ | | ||
+ | // Datum aendern | ||
+ | // T1405944000 init-Time = 21.07.2014 12:00:00, 1405944000 wird mit (now) gelesen. | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | if (positionRight > 500&& | ||
+ | mytime=mytime+change_dd; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | if (positionRight < 500&& | ||
+ | mytime=mytime-change_dd; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | if (positionRight > 520) { | ||
+ | mytime=mytime+change_mon; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | if (positionRight < 480) { | ||
+ | mytime=mytime-change_mon; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | // | ||
+ | void menue6() { | ||
+ | // Display-LCD-menue6 Zeit aendern | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print | ||
+ | lcd.setCursor(16, | ||
+ | lcd.println(" | ||
+ | lcd.setCursor(16, | ||
+ | digitalClockLcdZeit(); | ||
+ | | ||
+ | long newRight; | ||
+ | long positionRight; | ||
+ | | ||
+ | if (newRight != positionRight) { | ||
+ | positionRight = newRight; | ||
+ | } | ||
+ | | ||
+ | // Zeit aendern | ||
+ | // T1405944000 init-Time = 21.07.2014 12:00:00, 1405944000 wird mit (now) gelesen. | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | if (positionRight > 500&& | ||
+ | mytime=mytime+change_min; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | if (positionRight < 500&& | ||
+ | mytime=mytime-change_min; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | if (positionRight > 510) { // schnell rechtsrum drehen | ||
+ | mytime=mytime+change_hh; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | if (positionRight < 490) { // schnell linksrum drehen | ||
+ | mytime=mytime-change_hh; | ||
+ | | ||
+ | knob.write(0); | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | // ------------------------------ Ende VOID - Unterprogramme ------------------------------------- | ||
+ | //END | ||
+ | /* | ||
+ | ----------------------------Benötigte Hardware------------------------- | ||
+ | 1 x PC, Laptop o.ä. zum Daten speichern und zum programmieren des Arduino | ||
+ | 1 x Arduino Leonardo | ||
+ | 1x LCD-Display 16x4 | ||
+ | 1x Poti 1k Ohm für LCD-Display-Contrast | ||
+ | 1x Lautsprecher | ||
+ | 1x LED und R 1K Ohm | ||
+ | 1x Drehimpulsgeber mit Taster | ||
+ | 1x LDR und 2 Wiederstaende , Werte ???? | ||
+ | 1x Temeraturfühler, | ||
+ | sowie Vorwiederstände an den Messtellen für Spannungs-Messung, | ||
+ | sowie Shunt-Widerstände bei den Strom Messungen. | ||
+ | */ | ||
+ | // ------------------------- | ||
+ | /* | ||
+ | Arduino V 1.0.5-r2 | ||
+ | RS232 Datalogger, zu finden auf http:// | ||
+ | */ | ||
+ | // --- PIN Belegungen ----------------------------------------------- | ||
+ | // vom Arduino Leonardo | ||
+ | /* | ||
+ | | ||
+ | | ||
+ | mini USB !!! EPC | ||
+ | DC Buchse | ||
+ | ISP 6 POL | ||
+ | |||
+ | IOREF | ||
+ | | ||
+ | +3,3 V (Power) | ||
+ | +5 V (Power) !!! Versorgungsspannung | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | A0 analog in (MUB1), (MIB1) | ||
+ | A1 analog in (MUB2), (MIB2) | ||
+ | A2 analog in (MUS1), (MIS1) | ||
+ | A3 analog in (MUS2), (MIS2) | ||
+ | A4 analog in (MUNT), (MINT) | ||
+ | A5 analog in (Temp), (Light) | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | GND | ||
+ | -13 digital PWM Lautsprecher(morse) or LED (intern LED) | ||
+ | 12 digital | ||
+ | -11 digital PWM !!! LCD-Display | ||
+ | -10 digital PWM !!! LCD-Display | ||
+ | -9 digital PWM !!! LCD-Display 11 DATA 4 | ||
+ | 8 digital | ||
+ | |||
+ | 7 digital | ||
+ | -6 digital PWM !!! LCD-Display 14 DATA 7 | ||
+ | -5 digital PWM Reset | ||
+ | 4 digital | ||
+ | -3 digital PWM | ||
+ | 2 digital | ||
+ | TX->1 | ||
+ | RX<-0 | ||
+ | */ | ||
+ | // vom LCD Display | ||
+ | /* | ||
+ | LCD - Display pins: | ||
+ | | ||
+ | 4K7 Ohm nach GND, 1k2 Ohm nach +5V, Mitte an Pin3 anstelle des Poti! | ||
+ | Contrast Pin 3 benötigt ca. 1V + | ||
+ | --------------- | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | 10 DATA 3 | ||
+ | 11 DATA 4 || pin 9 am Arduino | ||
+ | 12 DATA 5 || pin 8 am Arduino | ||
+ | 13 DATA 6 || pin 7 am Arduino | ||
+ | 14 DATA 7 || pin 6 am Arduino | ||
+ | 15 (Backlight +5V) | ||
+ | 16 (Backlight GND) | ||
+ | */ | ||
+ | // Belegung der Mess-Stellen | ||
+ | /* | ||
+ | -------- Messwerte für erstes Display---------- | ||
+ | M01 = U Womo Batterie | ||
+ | M02 = U Auto Batterie | ||
+ | M03 = U Slo1 | ||
+ | M04 = U Sol2 | ||
+ | M05 = U Ladegerät +14,4V | ||
+ | M06 = U 230V | ||
+ | -------- Messwerte für zweites Display---------- | ||
+ | M07 = I Womo | ||
+ | M08 = I Auto | ||
+ | M09 = I Sol1 | ||
+ | M10 = I Sol2 | ||
+ | M11 = Temp | ||
+ | M12 = Licht | ||
+ | */ | ||
</ | </ |