Schau Dir einfach mal den Spannungsteiler an. Denk dran, Ladespannung Lichtmaschine 14,4V. https://forum.arduino.cc/index.php?topic=489118.0
LG Roland

caferacer-forum.de - Das Forum für Petrolheads, Garagenschrauber, Ölfinger, Frickelracer und Alteisentreiber
Elektronik Bastelei mit Arduino (Selbstbau Tacho, DZM etc)
-
- Beiträge: 1289
- Registriert: 2. Sep 2015
- Motorrad:: ..
- Wohnort: Vaterstetten
Re: Elektronik Bastelei mit Arduino (Selbstbau Tacho, DZM etc)
Hallo Leute, nach unzähligen Rückschlägen geht mein Boldor Umbau in die finale Phase. Heute durfte der Eigenbau Tacho zum ersten Mal im Motorrad Platz nehmen. Aber leider zeigt der Tacho nur Müll sobald der Motor läuft. Irgendwann hängt er sich sogar auf. Sehr ärgerlich.
Mal schauen ob ich das in den Griff bekomme; ansonsten muss ich wohl oder übel einen anderen Tacho kaufen. Im August muss das bike zum TÜV
Mal schauen ob ich das in den Griff bekomme; ansonsten muss ich wohl oder übel einen anderen Tacho kaufen. Im August muss das bike zum TÜV

- k3po
- Beiträge: 298
- Registriert: 25. Apr 2015
- Motorrad:: Honda CB900F, Bol d'Or (1982)
Honda CB400NC (1983) - Wohnort: ....am Rand des Nordschwarzwald ;-)
Re: Elektronik Bastelei mit Arduino (Selbstbau Tacho, DZM etc)
Naja, saubere Spannungsversorgung ist wichtig in diesem Umfeld.
LG Kurt
LG Kurt
-
- Beiträge: 1289
- Registriert: 2. Sep 2015
- Motorrad:: ..
- Wohnort: Vaterstetten
Re: Elektronik Bastelei mit Arduino (Selbstbau Tacho, DZM etc)
Daran liegt es nicht. Auch bei versorgung via powerbank treten die Probleme auf
- k3po
- Beiträge: 298
- Registriert: 25. Apr 2015
- Motorrad:: Honda CB900F, Bol d'Or (1982)
Honda CB400NC (1983) - Wohnort: ....am Rand des Nordschwarzwald ;-)
Re: Elektronik Bastelei mit Arduino (Selbstbau Tacho, DZM etc)
Hast dir mal die Signale direkt am Tacho mit dem Oszi angeschaut? Da muss ja dann irgendwo was reinspucken und als Tachoimpuls interpretiert werden. Leitungsführung vom Impulsgeber in der Nähe der Zündspulen o.ä.?
LG Kurt
LG Kurt
-
- Beiträge: 721
- Registriert: 22. Sep 2013
- Motorrad:: Kawasaki Gpz900R, Bj85
Ducati 900SS, Bj 92
Honda CX500, Bj 82
Honda CBX750, Bj 86
Re: Elektronik Bastelei mit Arduino (Selbstbau Tacho, DZM etc)
Hi,
ich hatte mal bei meiner Duc unentstörte Zündkerzen und -stecker ausprobiert. Die Folge war, daß mein Navi dann nach einiger Zeit (15-30min) erst Displaysörungen zeigete und sich dann aufhängte (auch im Akkubetrieb). Nach Rückrüstung auf original trat das dann nicht mehr auf.
Gruß
Jürgen
ich hatte mal bei meiner Duc unentstörte Zündkerzen und -stecker ausprobiert. Die Folge war, daß mein Navi dann nach einiger Zeit (15-30min) erst Displaysörungen zeigete und sich dann aufhängte (auch im Akkubetrieb). Nach Rückrüstung auf original trat das dann nicht mehr auf.
Gruß
Jürgen
-
- Beiträge: 2
- Registriert: 26. Okt 2020
- Motorrad:: Simson S50 Bj78 Komplettumbau
Re: Elektronik Bastelei mit Arduino (Selbstbau Tacho, DZM etc)
ich find das mega, habe vor es an meine Simson zu bauen allerdings würde ich gerne das Caferacer Logo ändern. Bekomme es aber nicht hin. Könntest du mir helfen ?
SebastianM hat geschrieben: 13. Aug 2018 Soooo.... in den letzten Wochen hab ich endlcih auch mal den Arsch hochgekriegt und habe meinen Tacho auf Arduino-Basis fertiggestellt.
Das Konzept basiert (wie auch bei NyFAZ) darauf, dass jede Radumdrehung ein Interrupt (derzeit noch über einen Taster simuliert) ausgelöst wird - hier bin ich mir allerdings noch nicht sicher, ob ich einen Hall- oder Reedschalter benutzen soll. Aus der Zeitdifferenz zwischen zwei Interrupts wird die Geschwindigkeit berechnet, außerdem wird pro Radumdrehung die Wegstrecke (Trip und Gesamt) um den Radumfang (in meinem Fall 1862mm) hochgezählt.
Des Weiteren habe ich meinem Tacho noch eine DS3231 Real-Time-Clock spendiert, die die Uhrzeit batteriegepuffert bis zu 4 Jahren behält und pro Jahr nur 1-2 Sekunden Abweichung hat. Positiver Nebeneffekt dieser RTC ist auch noch ein eingebautes Thermometer, so dass mein Tacho neben der Uhrzeit auch noch die Umgebungstemperatur anzeigen kann.
Über einen Taster kann ich zwischen den unterschiedlichen Screens umschalten; hier bin ich mir noch nicht sicher, ob ich je einen separaten Screen für Trip und Gesamt-Kilometer umsetzen soll (hätte den Charme, dass man noch kleine Grafiken einbauen könnte - siehe Video), oder einen Screen mit beiden Kilometerständen (siehe ebenfalls Video).
Die Kilometerstände werden sowohl alle 500Meter als auch nach einem Anhaltevorgang ins EEPROM weggeschrieben, damit sie nicht verloren gehen. Da pro EEPROM Zelle nur 100.000 Schreibzugriffe garantiert werden, habe ich mir einen simplen Ringspeicher-Mechanismus ausgedacht, um alle Zellen gleichmäßig zu nutzen: Bei jedem Schreibzugriff wird die EEPROM-Adresse hochgezählt; wenn man am Ende ist beginnt es wieder bei Adresse=0. Bei jedem Aufstart sucht der Tacho das EEPROM nach der Zelle mit dem höchsten Speicherstand ab und macht dann damit weiter.
Die größte Herausforderung wird meines Erachtens aber noch die mechanische Integration ins Mopped; das Ganze muss in einen Becher mit 40mm Außendurchmesser gepresst werden, damit es in die Gabelbrücke meiner Bolle passt (siehe Photo unten). Ob ich diesen Becher aus Alu drehen lasse oder im 3D-Drucker anfertige, ist noch offen. Oben soll ein Uhrenglas den Abschluss bilden.
Jetzt aber genug geredet - seht selbst:![]()
IMG_8396.JPGCode: Alles auswählen
#include <EEPROM.h> #include <RunningAverage.h> #include <Wire.h> #include "OneButton.h" #include <U8g2lib.h> #include "RTClib.h" U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping RTC_DS3231 rtc; const uint16_t Entprellzeit = 20; // in ms volatile uint32_t lastMillis = 0; RunningAverage myRA(5); volatile short geschwindigkeit; const int buttonPin = 4; const int reedPin = 3; int screen = 0; volatile int RotationCounter = 0; OneButton button(buttonPin, true); const int RadUmfang = 1862; char Speed[10]; uint64_t GesamtMillimeter; uint32_t TripMillimeter; int GesamtMillimeter_ADDR = 0; int TripMillimeter_ADDR = GesamtMillimeter_ADDR + 8; //Gesamtmillimeter ist 64bit Zahl --> braucht 8 Byte im EEPROM char TripKm[10]; char GesamtKm[10]; boolean reset = false; boolean MotorradFaehrt = false; boolean ShowLogo = false; boolean beimNaechstenStopDatenSichern = false; #define logo_width 128 #define logo_height 62 const unsigned char logo[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x7f, 0x3c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xc0, 0xfd, 0xff, 0xff, 0x3d, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x78, 0xff, 0xff, 0xff, 0x7b, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xcc, 0xff, 0xff, 0xff, 0x7b, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x1f, 0x00, 0x00, 0xcc, 0xff, 0xff, 0xff, 0x7b, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x1f, 0x00, 0x00, 0xf6, 0xff, 0xff, 0xff, 0xff, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0x00, 0xfa, 0xff, 0xff, 0xff, 0xff, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xe3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xe3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0xc7, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x03, 0xc0, 0x01, 0x00, 0x07, 0xc3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x01, 0xe0, 0x0f, 0x00, 0x03, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x80, 0x01, 0x63, 0x9e, 0x01, 0x03, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x80, 0x0c, 0x6f, 0xc8, 0x87, 0x01, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xe0, 0x7c, 0xef, 0xef, 0x8d, 0x01, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0xc0, 0x00, 0xe0, 0x7c, 0xef, 0xef, 0x8d, 0x01, 0x1c, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x07, 0x80, 0x01, 0xe0, 0xfc, 0xe3, 0x6f, 0xf8, 0x00, 0xbe, 0xff, 0x03, 0x00, 0x00, 0xf0, 0xff, 0x3f, 0x00, 0x07, 0x60, 0xfc, 0xe3, 0xf0, 0xfd, 0x00, 0xbc, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x00, 0x0e, 0x70, 0x3c, 0xaf, 0x77, 0x7e, 0x00, 0x3d, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0x01, 0x0e, 0x10, 0x04, 0xe3, 0xb7, 0x73, 0x80, 0x73, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0xff, 0x03, 0x18, 0x18, 0x00, 0xe0, 0xd9, 0x19, 0xc0, 0x73, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, 0x03, 0x18, 0x18, 0x00, 0xe0, 0xd9, 0x19, 0xc0, 0x73, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xe3, 0xff, 0x0f, 0x30, 0x08, 0x00, 0xa0, 0x69, 0x7a, 0xf0, 0xf3, 0xe0, 0xff, 0x03, 0xc0, 0x7f, 0xe0, 0xf8, 0x1f, 0x20, 0x0c, 0x00, 0xe0, 0xf1, 0x69, 0xf8, 0xef, 0x30, 0xfe, 0x03, 0xe0, 0x3f, 0xe0, 0xf0, 0x1f, 0x60, 0x1c, 0x30, 0x00, 0x7e, 0x7c, 0xf8, 0xef, 0x31, 0xf8, 0x07, 0xe0, 0x0f, 0xf0, 0xc0, 0x33, 0xc0, 0x1f, 0xfc, 0x61, 0x30, 0x7c, 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1f, 0xf8, 0xc7, 0xff, 0x07, 0x7f, 0x60, 0x82, 0x03, 0x00, 0x90, 0x0d, 0xfe, 0xf0, 0xff, 0xe3, 0x0f, 0xf0, 0xe7, 0xff, 0x83, 0x7f, 0xf0, 0x03, 0xfe, 0xff, 0xdf, 0x07, 0xfe, 0xf1, 0xff, 0xe1, 0x0f, 0xf0, 0xe7, 0xff, 0x83, 0x7f, 0xf0, 0x03, 0xfe, 0xff, 0xdf, 0x07, 0xfe, 0xf1, 0xff, 0xe1, 0x0f, 0xf0, 0xef, 0xff, 0x83, 0x3f, 0xf0, 0x0f, 0xf8, 0xff, 0x6f, 0x06, 0xfc, 0xfd, 0x7f, 0xf0, 0x0f, 0xe0, 0x7f, 0xe0, 0xc3, 0x3f, 0xf8, 0x1f, 0x00, 0x00, 0xb0, 0x03, 0xfc, 0x1f, 0x70, 0xf0, 0x07, 0xe0, 0x3f, 0x80, 0xf3, 0x1f, 0xc0, 0xff, 0x02, 0xfe, 0x9f, 0x03, 0xf8, 0x0f, 0x70, 0xf8, 0x07, 0xc0, 0x7f, 0x00, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x0f, 0xc0, 0x01, 0xf8, 0x3f, 0x60, 0xfe, 0x03, 0xc0, 0xff, 0x07, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0xff, 0x7f, 0x00, 0xf0, 0xff, 0xe0, 0xff, 0x03, 0x80, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x0f, 0x00, 0x00, 0xc0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; #define tachoSymbol_width 48 #define tachoSymbol_height 30 const unsigned char tachoSymbol[] PROGMEM = { 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x03, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfe, 0xcf, 0xf3, 0x7f, 0x00, 0x00, 0xff, 0xc1, 0x83, 0xff, 0x00, 0x80, 0x7f, 0xc0, 0x03, 0xfe, 0x01, 0xc0, 0x1f, 0xc0, 0x03, 0xf8, 0x03, 0xe0, 0x0f, 0xc0, 0x03, 0xf0, 0x07, 0xf0, 0x87, 0x81, 0x01, 0xe0, 0x0f, 0xf8, 0x83, 0x03, 0x00, 0xc0, 0x0f, 0xf8, 0x81, 0x07, 0x00, 0x80, 0x1f, 0xfc, 0x80, 0x07, 0x00, 0x00, 0x3f, 0x7c, 0x00, 0x0f, 0x00, 0x00, 0x3e, 0x7e, 0x00, 0x1f, 0x00, 0x00, 0x7e, 0x3e, 0x00, 0x3e, 0x00, 0x00, 0x7c, 0x3e, 0x00, 0x3e, 0x00, 0x00, 0x7c, 0x3e, 0x00, 0x7c, 0x00, 0x00, 0x7c, 0x1f, 0x00, 0xfc, 0x03, 0x00, 0xf8, 0x1f, 0x00, 0xf8, 0x0f, 0x00, 0xf8, 0x1f, 0x00, 0xf8, 0x1f, 0x00, 0xf8, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xfe, 0xff, 0x3f, 0xfc, 0xff, 0x7f, 0xfe, 0xff, 0x3f, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00 }; #define thermometer_width 24 #define thermometer_height 64 const unsigned char thermometer_Symbol[] PROGMEM = { 0x00, 0x3c, 0x00, 0x00, 0xff, 0x00, 0x80, 0xc3, 0x01, 0xc0, 0x81, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xe0, 0x3c, 0x07, 0x70, 0x3c, 0x0e, 0x38, 0x7e, 0x1c, 0x18, 0xff, 0x18, 0x8c, 0xff, 0x31, 0xcc, 0xff, 0x33, 0xcc, 0xff, 0x33, 0xce, 0xff, 0x73, 0xc6, 0xff, 0x63, 0xce, 0xff, 0x73, 0xcc, 0xff, 0x33, 0xcc, 0xff, 0x33, 0x9c, 0xff, 0x39, 0x18, 0xff, 0x18, 0x38, 0x3c, 0x1c, 0x70, 0x00, 0x0e, 0xe0, 0xc3, 0x07, 0x80, 0xff, 0x01, 0x00, 0x7e, 0x00 }; #define route_width 34 #define route_height 34 const unsigned char route_bits[] PROGMEM = { 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xee, 0x00, 0x00, 0x00, 0x00, 0xbb, 0x01, 0x00, 0x00, 0x00, 0x7d, 0x03, 0x00, 0x00, 0x80, 0xc7, 0x03, 0x00, 0x00, 0x80, 0x87, 0x02, 0x00, 0x00, 0x80, 0xc7, 0x03, 0x00, 0x00, 0x00, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x7b, 0x01, 0x00, 0x00, 0x00, 0x83, 0x01, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x1e, 0x00, 0xfa, 0x02, 0xe0, 0x0f, 0x00, 0xdf, 0x06, 0x7f, 0x00, 0x00, 0x8d, 0xc7, 0x07, 0x00, 0x00, 0x85, 0x07, 0x3f, 0x00, 0x00, 0x8f, 0x07, 0xf8, 0x01, 0x00, 0xfa, 0x02, 0x80, 0x1f, 0x00, 0x26, 0x03, 0x00, 0x7e, 0x00, 0x04, 0xe1, 0xff, 0x7f, 0x00, 0x8c, 0xf1, 0x00, 0x00, 0x00, 0x88, 0xc0, 0x00, 0x00, 0x00, 0xd8, 0x80, 0x01, 0x00, 0x00, 0x70, 0x00, 0x03, 0x00, 0x00, 0x30, 0x00, 0x06, 0x00, 0x00, 0x20, 0xff, 0x07, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x00 }; void setup() { // Serial.begin(9600); // open the serial port at 9600 bps: if (reset) { resetEEPROM(); } //alles auf 0 setzen pinMode(reedPin, INPUT_PULLUP); // Reed-Sensor an Pin 3 pinMode(buttonPin, INPUT_PULLUP); // Taster an Pin 2 EIFR = (1 << INTF1); //verhindert fälschliches Aufrufen der ISR revs() bei Startup --> https://github.com/arduino/Arduino/issues/510 attachInterrupt(digitalPinToInterrupt(reedPin), revs, RISING); getMileage(); //gespeicherten Tachostand abrufen (eeprom-adresse mit höchstem Zählerstand suchen) myRA.clear(); button.attachClick(klick); button.attachLongPressStop(langDruck); u8g2.begin(); u8g2_prepare(); u8g2.clearBuffer(); u8g2.drawXBMP( 0, 0, logo_width, logo_height, logo); u8g2.sendBuffer(); delay(2000); } void loop() { button.tick(); u8g2.clearBuffer(); if (MotorradFaehrt) { myRA.addValue(geschwindigkeit); // Wert zur Mittelwerberechnung hinzufügen GesamtMillimeter += RadUmfang; TripMillimeter += RadUmfang; MotorradFaehrt = false; if (geschwindigkeit > 30) beimNaechstenStopDatenSichern = true; //Flag setzen um Tachostand beim nächsten Stop wegzuschreiben } if (millis()-lastMillis >= 10000) { //wenn keine Radumdrehung innerhalb von 10 Sek stattgefunden hat --> Logo zeigen u8g2.drawXBMP( 0, 0, logo_width, logo_height, logo); ShowLogo = true; if (beimNaechstenStopDatenSichern) { //Tachostand nur dann ins EEPROM schreiben, wenn vorher über 30km/h gefahren wurde saveMileage(); beimNaechstenStopDatenSichern = false; } } else { draw(); } u8g2.sendBuffer(); if (millis()-lastMillis >= 2000) { myRA.clear(); //wenn keine Radumdrehung innerhalb von 2 Sek stattgefunden hat --> Geschwindigkeit nullen } if (RotationCounter >= 10) { //Tachostand ca. alle 500m sichern (260 umdrehungen); RotationCounter = 0; saveMileage(); } } void draw() { short VAnzeige = myRA.getAverage(); // Mittelwert errechnen DateTime now = rtc.now(); int hunderter = (TripMillimeter / 100000) % 10; int tausender = TripMillimeter / 1000000; sprintf(GesamtKm, "%6lukm",(uint32_t)(GesamtMillimeter/1000000)); sprintf(TripKm, "%5d.%dkm", tausender, hunderter); sprintf(Speed, "%3d", VAnzeige); switch (screen) { case 0: u8g2.drawXBMP( 80, 0, tachoSymbol_width, tachoSymbol_height, tachoSymbol); u8g2.setFont(u8g2_font_logisoso38_tn); u8g2.drawStr( 0, 15, Speed); u8g2.setFont(u8g2_font_logisoso20_tr); u8g2.drawStr( 75, 32, "kmh"); break; case 1: u8g2.setFont(u8g2_font_logisoso38_tn); u8g2.setCursor(5,15); if (now.hour() < 10) u8g2.print("0"); u8g2.print(now.hour()); u8g2.print(":"); if (now.minute() < 10) u8g2.print("0"); u8g2.print(now.minute()); break; case 2: u8g2.setFont(u8g2_font_logisoso20_tr); u8g2.drawStr( 0, 10, "Trip:"); u8g2.drawStr( 0, 40, TripKm); u8g2.drawXBMP( 80, 0, route_width, route_height, route_bits); break; case 3: u8g2.drawStr( 0, 40, TripKm); u8g2.drawStr( 5, 10, GesamtKm); break; case 4: u8g2.setFont(u8g2_font_logisoso38_tn); u8g2.setCursor(0, 15); u8g2.print(tempDS3231(), 1); u8g2.drawCircle(98, 20, 5, U8G2_DRAW_ALL); //nicht besonders schön, aber speicher-optimalste Veriante ?? u8g2.drawCircle(98, 20, 4, U8G2_DRAW_ALL); u8g2.drawXBMP( 105, 0, thermometer_width, thermometer_height, thermometer_Symbol); break; } } void u8g2_prepare(void) { u8g2.setFontRefHeightExtendedText(); u8g2.setDrawColor(1); u8g2.setFontPosTop(); u8g2.setFontDirection(0); } void revs() { // Interrupt-Routine uint32_t jetztMillis = millis(); if (jetztMillis - lastMillis >= Entprellzeit) { // ignorieren wenn <= 10ms (Kontaktpreller) geschwindigkeit = RadUmfang*3.6/(jetztMillis-lastMillis); // Geschwindigkeit: 1 Interrupt alle 1861mm (Radumfang) lastMillis = millis(); RotationCounter += 1; MotorradFaehrt = true; } } void klick() { //durchtoggeln der Screens screen++; if (screen > 4) screen= 0; if (ShowLogo) { //falls Logo angezeigt und Knopf gedrückt wird --> Logo-Timer wieder auf 10sek setzen und Geschwindigkeit anzeigen ShowLogo = false; lastMillis = millis(); screen = 0; } } void langDruck() { if (screen == 2) { TripMillimeter = 0; //Trip zurücksetzen EEPROM.put(TripMillimeter_ADDR, TripMillimeter); } } float tempDS3231() { // Die Temperatur des DS3231 auslesen float temp; int msb, lsb; Wire.beginTransmission(0x68); Wire.write(0x11); Wire.endTransmission(); Wire.requestFrom(0x68, 2); msb = Wire.read(); lsb = Wire.read(); temp=((msb << 2) + (lsb >> 6) ) /4.0; return temp; } void getMileage(){ //EEPROM-Adresse mit dem höchsten Tachostand suchen uint64_t GesamtMillimeter_vgl; EEPROM.get(GesamtMillimeter_ADDR, GesamtMillimeter); //Absprungbasis bei Adresse=0 for (int pos=0; pos<=1008; pos=pos + 12){ //EEProm.length = 0-1023 EEPROM.get(pos, GesamtMillimeter_vgl); if (GesamtMillimeter_vgl > GesamtMillimeter){ //falls höherer KM-Stand gefunden wurde, diesen übernehmen und weitersuchen GesamtMillimeter = GesamtMillimeter_vgl; GesamtMillimeter_ADDR = pos; } } TripMillimeter_ADDR=GesamtMillimeter_ADDR + 8; EEPROM.get(GesamtMillimeter_ADDR, GesamtMillimeter); EEPROM.get(TripMillimeter_ADDR, TripMillimeter); } void saveMileage() { GesamtMillimeter_ADDR += 12; //immer in neue Zelle schreiben --> verlängert EEPROM Lebensdauer (Gesamtmillimeter 8 Byte, TripMillimeter 4 Byte -> Sprung um 12Byte if (GesamtMillimeter_ADDR > 1008) {GesamtMillimeter_ADDR = 0;} TripMillimeter_ADDR = GesamtMillimeter_ADDR + 8; //Gesamtmillimeter ist 64bit Zahl --> braucht 8 Byte im EEPROM EEPROM.put(GesamtMillimeter_ADDR, GesamtMillimeter); EEPROM.put(TripMillimeter_ADDR, TripMillimeter); } void resetEEPROM() { for (unsigned int i = 0 ; i < EEPROM.length() ; i++) { EEPROM.write(i, 0); } GesamtMillimeter = 0; TripMillimeter = 0; //Serial.println(F("FACTORY-RESET")); }
-
- Beiträge: 2
- Registriert: 26. Okt 2020
- Motorrad:: Simson S50 Bj78 Komplettumbau
Re: Elektronik Bastelei mit Arduino (Selbstbau Tacho, DZM etc)
Hey, ich nochmal, habe dS Logo hinbekommen aber er speichert bei mir den Km stand nicht. Nach jedem Starten immer wieder auf 0. Hab zur Zeit nur ein Taster dran und hab mal bis 3km "gefahren" gewartet und gehofft aber nach dem Neustart stand wieder 0 da. Kannst du mir helfen?
SebastianM hat geschrieben: 13. Aug 2018 Soooo.... in den letzten Wochen hab ich endlcih auch mal den Arsch hochgekriegt und habe meinen Tacho auf Arduino-Basis fertiggestellt.
Das Konzept basiert (wie auch bei NyFAZ) darauf, dass jede Radumdrehung ein Interrupt (derzeit noch über einen Taster simuliert) ausgelöst wird - hier bin ich mir allerdings noch nicht sicher, ob ich einen Hall- oder Reedschalter benutzen soll. Aus der Zeitdifferenz zwischen zwei Interrupts wird die Geschwindigkeit berechnet, außerdem wird pro Radumdrehung die Wegstrecke (Trip und Gesamt) um den Radumfang (in meinem Fall 1862mm) hochgezählt.
Des Weiteren habe ich meinem Tacho noch eine DS3231 Real-Time-Clock spendiert, die die Uhrzeit batteriegepuffert bis zu 4 Jahren behält und pro Jahr nur 1-2 Sekunden Abweichung hat. Positiver Nebeneffekt dieser RTC ist auch noch ein eingebautes Thermometer, so dass mein Tacho neben der Uhrzeit auch noch die Umgebungstemperatur anzeigen kann.
Über einen Taster kann ich zwischen den unterschiedlichen Screens umschalten; hier bin ich mir noch nicht sicher, ob ich je einen separaten Screen für Trip und Gesamt-Kilometer umsetzen soll (hätte den Charme, dass man noch kleine Grafiken einbauen könnte - siehe Video), oder einen Screen mit beiden Kilometerständen (siehe ebenfalls Video).
Die Kilometerstände werden sowohl alle 500Meter als auch nach einem Anhaltevorgang ins EEPROM weggeschrieben, damit sie nicht verloren gehen. Da pro EEPROM Zelle nur 100.000 Schreibzugriffe garantiert werden, habe ich mir einen simplen Ringspeicher-Mechanismus ausgedacht, um alle Zellen gleichmäßig zu nutzen: Bei jedem Schreibzugriff wird die EEPROM-Adresse hochgezählt; wenn man am Ende ist beginnt es wieder bei Adresse=0. Bei jedem Aufstart sucht der Tacho das EEPROM nach der Zelle mit dem höchsten Speicherstand ab und macht dann damit weiter.
Die größte Herausforderung wird meines Erachtens aber noch die mechanische Integration ins Mopped; das Ganze muss in einen Becher mit 40mm Außendurchmesser gepresst werden, damit es in die Gabelbrücke meiner Bolle passt (siehe Photo unten). Ob ich diesen Becher aus Alu drehen lasse oder im 3D-Drucker anfertige, ist noch offen. Oben soll ein Uhrenglas den Abschluss bilden.
Jetzt aber genug geredet - seht selbst:![]()
IMG_8396.JPGCode: Alles auswählen
#include <EEPROM.h> #include <RunningAverage.h> #include <Wire.h> #include "OneButton.h" #include <U8g2lib.h> #include "RTClib.h" U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping RTC_DS3231 rtc; const uint16_t Entprellzeit = 20; // in ms volatile uint32_t lastMillis = 0; RunningAverage myRA(5); volatile short geschwindigkeit; const int buttonPin = 4; const int reedPin = 3; int screen = 0; volatile int RotationCounter = 0; OneButton button(buttonPin, true); const int RadUmfang = 1862; char Speed[10]; uint64_t GesamtMillimeter; uint32_t TripMillimeter; int GesamtMillimeter_ADDR = 0; int TripMillimeter_ADDR = GesamtMillimeter_ADDR + 8; //Gesamtmillimeter ist 64bit Zahl --> braucht 8 Byte im EEPROM char TripKm[10]; char GesamtKm[10]; boolean reset = false; boolean MotorradFaehrt = false; boolean ShowLogo = false; boolean beimNaechstenStopDatenSichern = false; #define logo_width 128 #define logo_height 62 const unsigned char logo[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x7f, 0x3c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xc0, 0xfd, 0xff, 0xff, 0x3d, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x78, 0xff, 0xff, 0xff, 0x7b, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xcc, 0xff, 0xff, 0xff, 0x7b, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x1f, 0x00, 0x00, 0xcc, 0xff, 0xff, 0xff, 0x7b, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x1f, 0x00, 0x00, 0xf6, 0xff, 0xff, 0xff, 0xff, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0x00, 0xfa, 0xff, 0xff, 0xff, 0xff, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xe3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xe3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0xc7, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x03, 0xc0, 0x01, 0x00, 0x07, 0xc3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x01, 0xe0, 0x0f, 0x00, 0x03, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x80, 0x01, 0x63, 0x9e, 0x01, 0x03, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x80, 0x0c, 0x6f, 0xc8, 0x87, 0x01, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xe0, 0x7c, 0xef, 0xef, 0x8d, 0x01, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0xc0, 0x00, 0xe0, 0x7c, 0xef, 0xef, 0x8d, 0x01, 0x1c, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x07, 0x80, 0x01, 0xe0, 0xfc, 0xe3, 0x6f, 0xf8, 0x00, 0xbe, 0xff, 0x03, 0x00, 0x00, 0xf0, 0xff, 0x3f, 0x00, 0x07, 0x60, 0xfc, 0xe3, 0xf0, 0xfd, 0x00, 0xbc, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x00, 0x0e, 0x70, 0x3c, 0xaf, 0x77, 0x7e, 0x00, 0x3d, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0x01, 0x0e, 0x10, 0x04, 0xe3, 0xb7, 0x73, 0x80, 0x73, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0xff, 0x03, 0x18, 0x18, 0x00, 0xe0, 0xd9, 0x19, 0xc0, 0x73, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, 0x03, 0x18, 0x18, 0x00, 0xe0, 0xd9, 0x19, 0xc0, 0x73, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xe3, 0xff, 0x0f, 0x30, 0x08, 0x00, 0xa0, 0x69, 0x7a, 0xf0, 0xf3, 0xe0, 0xff, 0x03, 0xc0, 0x7f, 0xe0, 0xf8, 0x1f, 0x20, 0x0c, 0x00, 0xe0, 0xf1, 0x69, 0xf8, 0xef, 0x30, 0xfe, 0x03, 0xe0, 0x3f, 0xe0, 0xf0, 0x1f, 0x60, 0x1c, 0x30, 0x00, 0x7e, 0x7c, 0xf8, 0xef, 0x31, 0xf8, 0x07, 0xe0, 0x0f, 0xf0,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ff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x0f, 0x00, 0x00, 0xc0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; #define tachoSymbol_width 48 #define tachoSymbol_height 30 const unsigned char tachoSymbol[] PROGMEM = { 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x03, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfe, 0xcf, 0xf3, 0x7f, 0x00, 0x00, 0xff, 0xc1, 0x83, 0xff, 0x00, 0x80, 0x7f, 0xc0, 0x03, 0xfe, 0x01, 0xc0, 0x1f, 0xc0, 0x03, 0xf8, 0x03, 0xe0, 0x0f, 0xc0, 0x03, 0xf0, 0x07, 0xf0, 0x87, 0x81, 0x01, 0xe0, 0x0f, 0xf8, 0x83, 0x03, 0x00, 0xc0, 0x0f, 0xf8, 0x81, 0x07, 0x00, 0x80, 0x1f, 0xfc, 0x80, 0x07, 0x00, 0x00, 0x3f, 0x7c, 0x00, 0x0f, 0x00, 0x00, 0x3e, 0x7e, 0x00, 0x1f, 0x00, 0x00, 0x7e, 0x3e, 0x00, 0x3e, 0x00, 0x00, 0x7c, 0x3e, 0x00, 0x3e, 0x00, 0x00, 0x7c, 0x3e, 0x00, 0x7c, 0x00, 0x00, 0x7c, 0x1f, 0x00, 0xfc, 0x03, 0x00, 0xf8, 0x1f, 0x00, 0xf8, 0x0f, 0x00, 0xf8, 0x1f, 0x00, 0xf8, 0x1f, 0x00, 0xf8, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xfe, 0xff, 0x3f, 0xfc, 0xff, 0x7f, 0xfe, 0xff, 0x3f, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00 }; #define thermometer_width 24 #define thermometer_height 64 const unsigned char thermometer_Symbol[] PROGMEM = { 0x00, 0x3c, 0x00, 0x00, 0xff, 0x00, 0x80, 0xc3, 0x01, 0xc0, 0x81, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xc0, 0x3c, 0x03, 0xe0, 0x3c, 0x07, 0x70, 0x3c, 0x0e, 0x38, 0x7e, 0x1c, 0x18, 0xff, 0x18, 0x8c, 0xff, 0x31, 0xcc, 0xff, 0x33, 0xcc, 0xff, 0x33, 0xce, 0xff, 0x73, 0xc6, 0xff, 0x63, 0xce, 0xff, 0x73, 0xcc, 0xff, 0x33, 0xcc, 0xff, 0x33, 0x9c, 0xff, 0x39, 0x18, 0xff, 0x18, 0x38, 0x3c, 0x1c, 0x70, 0x00, 0x0e, 0xe0, 0xc3, 0x07, 0x80, 0xff, 0x01, 0x00, 0x7e, 0x00 }; #define route_width 34 #define route_height 34 const unsigned char route_bits[] PROGMEM = { 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xee, 0x00, 0x00, 0x00, 0x00, 0xbb, 0x01, 0x00, 0x00, 0x00, 0x7d, 0x03, 0x00, 0x00, 0x80, 0xc7, 0x03, 0x00, 0x00, 0x80, 0x87, 0x02, 0x00, 0x00, 0x80, 0xc7, 0x03, 0x00, 0x00, 0x00, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x7b, 0x01, 0x00, 0x00, 0x00, 0x83, 0x01, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x1e, 0x00, 0xfa, 0x02, 0xe0, 0x0f, 0x00, 0xdf, 0x06, 0x7f, 0x00, 0x00, 0x8d, 0xc7, 0x07, 0x00, 0x00, 0x85, 0x07, 0x3f, 0x00, 0x00, 0x8f, 0x07, 0xf8, 0x01, 0x00, 0xfa, 0x02, 0x80, 0x1f, 0x00, 0x26, 0x03, 0x00, 0x7e, 0x00, 0x04, 0xe1, 0xff, 0x7f, 0x00, 0x8c, 0xf1, 0x00, 0x00, 0x00, 0x88, 0xc0, 0x00, 0x00, 0x00, 0xd8, 0x80, 0x01, 0x00, 0x00, 0x70, 0x00, 0x03, 0x00, 0x00, 0x30, 0x00, 0x06, 0x00, 0x00, 0x20, 0xff, 0x07, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x00 }; void setup() { // Serial.begin(9600); // open the serial port at 9600 bps: if (reset) { resetEEPROM(); } //alles auf 0 setzen pinMode(reedPin, INPUT_PULLUP); // Reed-Sensor an Pin 3 pinMode(buttonPin, INPUT_PULLUP); // Taster an Pin 2 EIFR = (1 << INTF1); //verhindert fälschliches Aufrufen der ISR revs() bei Startup --> https://github.com/arduino/Arduino/issues/510 attachInterrupt(digitalPinToInterrupt(reedPin), revs, RISING); getMileage(); //gespeicherten Tachostand abrufen (eeprom-adresse mit höchstem Zählerstand suchen) myRA.clear(); button.attachClick(klick); button.attachLongPressStop(langDruck); u8g2.begin(); u8g2_prepare(); u8g2.clearBuffer(); u8g2.drawXBMP( 0, 0, logo_width, logo_height, logo); u8g2.sendBuffer(); delay(2000); } void loop() { button.tick(); u8g2.clearBuffer(); if (MotorradFaehrt) { myRA.addValue(geschwindigkeit); // Wert zur Mittelwerberechnung hinzufügen GesamtMillimeter += RadUmfang; TripMillimeter += RadUmfang; MotorradFaehrt = false; if (geschwindigkeit > 30) beimNaechstenStopDatenSichern = true; //Flag setzen um Tachostand beim nächsten Stop wegzuschreiben } if (millis()-lastMillis >= 10000) { //wenn keine Radumdrehung innerhalb von 10 Sek stattgefunden hat --> Logo zeigen u8g2.drawXBMP( 0, 0, logo_width, logo_height, logo); ShowLogo = true; if (beimNaechstenStopDatenSichern) { //Tachostand nur dann ins EEPROM schreiben, wenn vorher über 30km/h gefahren wurde saveMileage(); beimNaechstenStopDatenSichern = false; } } else { draw(); } u8g2.sendBuffer(); if (millis()-lastMillis >= 2000) { myRA.clear(); //wenn keine Radumdrehung innerhalb von 2 Sek stattgefunden hat --> Geschwindigkeit nullen } if (RotationCounter >= 10) { //Tachostand ca. alle 500m sichern (260 umdrehungen); RotationCounter = 0; saveMileage(); } } void draw() { short VAnzeige = myRA.getAverage(); // Mittelwert errechnen DateTime now = rtc.now(); int hunderter = (TripMillimeter / 100000) % 10; int tausender = TripMillimeter / 1000000; sprintf(GesamtKm, "%6lukm",(uint32_t)(GesamtMillimeter/1000000)); sprintf(TripKm, "%5d.%dkm", tausender, hunderter); sprintf(Speed, "%3d", VAnzeige); switch (screen) { case 0: u8g2.drawXBMP( 80, 0, tachoSymbol_width, tachoSymbol_height, tachoSymbol); u8g2.setFont(u8g2_font_logisoso38_tn); u8g2.drawStr( 0, 15, Speed); u8g2.setFont(u8g2_font_logisoso20_tr); u8g2.drawStr( 75, 32, "kmh"); break; case 1: u8g2.setFont(u8g2_font_logisoso38_tn); u8g2.setCursor(5,15); if (now.hour() < 10) u8g2.print("0"); u8g2.print(now.hour()); u8g2.print(":"); if (now.minute() < 10) u8g2.print("0"); u8g2.print(now.minute()); break; case 2: u8g2.setFont(u8g2_font_logisoso20_tr); u8g2.drawStr( 0, 10, "Trip:"); u8g2.drawStr( 0, 40, TripKm); u8g2.drawXBMP( 80, 0, route_width, route_height, route_bits); break; case 3: u8g2.drawStr( 0, 40, TripKm); u8g2.drawStr( 5, 10, GesamtKm); break; case 4: u8g2.setFont(u8g2_font_logisoso38_tn); u8g2.setCursor(0, 15); u8g2.print(tempDS3231(), 1); u8g2.drawCircle(98, 20, 5, U8G2_DRAW_ALL); //nicht besonders schön, aber speicher-optimalste Veriante ?? u8g2.drawCircle(98, 20, 4, U8G2_DRAW_ALL); u8g2.drawXBMP( 105, 0, thermometer_width, thermometer_height, thermometer_Symbol); break; } } void u8g2_prepare(void) { u8g2.setFontRefHeightExtendedText(); u8g2.setDrawColor(1); u8g2.setFontPosTop(); u8g2.setFontDirection(0); } void revs() { // Interrupt-Routine uint32_t jetztMillis = millis(); if (jetztMillis - lastMillis >= Entprellzeit) { // ignorieren wenn <= 10ms (Kontaktpreller) geschwindigkeit = RadUmfang*3.6/(jetztMillis-lastMillis); // Geschwindigkeit: 1 Interrupt alle 1861mm (Radumfang) lastMillis = millis(); RotationCounter += 1; MotorradFaehrt = true; } } void klick() { //durchtoggeln der Screens screen++; if (screen > 4) screen= 0; if (ShowLogo) { //falls Logo angezeigt und Knopf gedrückt wird --> Logo-Timer wieder auf 10sek setzen und Geschwindigkeit anzeigen ShowLogo = false; lastMillis = millis(); screen = 0; } } void langDruck() { if (screen == 2) { TripMillimeter = 0; //Trip zurücksetzen EEPROM.put(TripMillimeter_ADDR, TripMillimeter); } } float tempDS3231() { // Die Temperatur des DS3231 auslesen float temp; int msb, lsb; Wire.beginTransmission(0x68); Wire.write(0x11); Wire.endTransmission(); Wire.requestFrom(0x68, 2); msb = Wire.read(); lsb = Wire.read(); temp=((msb << 2) + (lsb >> 6) ) /4.0; return temp; } void getMileage(){ //EEPROM-Adresse mit dem höchsten Tachostand suchen uint64_t GesamtMillimeter_vgl; EEPROM.get(GesamtMillimeter_ADDR, GesamtMillimeter); //Absprungbasis bei Adresse=0 for (int pos=0; pos<=1008; pos=pos + 12){ //EEProm.length = 0-1023 EEPROM.get(pos, GesamtMillimeter_vgl); if (GesamtMillimeter_vgl > GesamtMillimeter){ //falls höherer KM-Stand gefunden wurde, diesen übernehmen und weitersuchen GesamtMillimeter = GesamtMillimeter_vgl; GesamtMillimeter_ADDR = pos; } } TripMillimeter_ADDR=GesamtMillimeter_ADDR + 8; EEPROM.get(GesamtMillimeter_ADDR, GesamtMillimeter); EEPROM.get(TripMillimeter_ADDR, TripMillimeter); } void saveMileage() { GesamtMillimeter_ADDR += 12; //immer in neue Zelle schreiben --> verlängert EEPROM Lebensdauer (Gesamtmillimeter 8 Byte, TripMillimeter 4 Byte -> Sprung um 12Byte if (GesamtMillimeter_ADDR > 1008) {GesamtMillimeter_ADDR = 0;} TripMillimeter_ADDR = GesamtMillimeter_ADDR + 8; //Gesamtmillimeter ist 64bit Zahl --> braucht 8 Byte im EEPROM EEPROM.put(GesamtMillimeter_ADDR, GesamtMillimeter); EEPROM.put(TripMillimeter_ADDR, TripMillimeter); } void resetEEPROM() { for (unsigned int i = 0 ; i < EEPROM.length() ; i++) { EEPROM.write(i, 0); } GesamtMillimeter = 0; TripMillimeter = 0; //Serial.println(F("FACTORY-RESET")); }
Re: Elektronik Bastelei mit Arduino (Selbstbau Tacho, DZM etc)
Hi Sebastian, hast du die Probleme mittlerweile in den Griff bekommen?SebastianM hat geschrieben: 22. Jul 2020 Daran liegt es nicht. Auch bei versorgung via powerbank treten die Probleme auf
- brummbaehr
- Beiträge: 958
- Registriert: 27. Sep 2016
- Motorrad:: Honda CX 500/650
- Wohnort: 41836 Hückelhoven
- Kontaktdaten:
Re: Elektronik Bastelei mit Arduino (Selbstbau Tacho, DZM etc)
Bissel ruhig geworden hier im Fred.
Habe mir ein Blinker-Ei ähmm.. Blinkrelais
für Tasterbetätigung gebastelt.
Hier der Prototyp


Bei einem kurzen Tastendruck wird 4x geblinkt.
Bei einem längerem Tastendruck (>250ms) wird dauerhaft geblinkt
Bei einem Tastendruck länger als 2s Warnblinken.
Erneuter Tastendruck wenn Blinker an, -> Ausschalten
Zusätzlich wird der Neutral/Kupplungsschalter angeklemmt.
Ist der Leerlauf drin oder die Kupplung gezogen, so wird bei Tastendruck (Also egal ob lang oder kurz) dauerhaft geblinkt.
Wird ein Gang eingelegt und die Kupplung losgelassen, man also z.B. an der Ampel los fährt, dann geht der Blinker nach 5x blinken automatisch AUS. Zieht man innerhalb der 5 Blinkimpulse wieder die Kupplung, so wird natürlich weiter geblinkt
Den originalen Blinkhebel in der linken Armatur ohne Raste umgebaut zum Taster

Die Güllepumpe und das versteckte Ei :

Habe mir ein Blinker-Ei ähmm.. Blinkrelais

Hier der Prototyp


Bei einem kurzen Tastendruck wird 4x geblinkt.
Bei einem längerem Tastendruck (>250ms) wird dauerhaft geblinkt
Bei einem Tastendruck länger als 2s Warnblinken.
Erneuter Tastendruck wenn Blinker an, -> Ausschalten
Zusätzlich wird der Neutral/Kupplungsschalter angeklemmt.
Ist der Leerlauf drin oder die Kupplung gezogen, so wird bei Tastendruck (Also egal ob lang oder kurz) dauerhaft geblinkt.
Wird ein Gang eingelegt und die Kupplung losgelassen, man also z.B. an der Ampel los fährt, dann geht der Blinker nach 5x blinken automatisch AUS. Zieht man innerhalb der 5 Blinkimpulse wieder die Kupplung, so wird natürlich weiter geblinkt

Den originalen Blinkhebel in der linken Armatur ohne Raste umgebaut zum Taster

Die Güllepumpe und das versteckte Ei :

