KZR's Bikes of the Month for 2024

Auto canceling turn signal diagnosis

More
05 Sep 2024 01:25 #903982 by wim2584
Replied by wim2584 on topic Auto canceling turn signal diagnosis
I have a 440 LTD with this cancel turn system, first i had a problem (soldering), inside the switch, after repair this the self canceling was working, but not reliable  (some times ok , other time not working), I changen the elektronic unit, now not working at all....

Then I decided to make myself "new: electronics " with a arduino.   this works fine!!

see below the code:
  /*wim lemson FSM machine voor Kawasaki Z440 auto cancel turn signal 1-2-2024 Update 9-1-2024, nieuwe versie gemaakt, met een voedingfilter (schotky diode, spoel condensator en een 7808 met kleine condensator),verder de code aangepast en fouten eruitgehaald  arduino pro mini 5V 16 Mhz 328P programmeerstekker: version 1         version 2  blauw= DTR                              Groen= DRT Geel=RX                                 rood = TX arduino. (RX naar computer) paars = TX                              wit = RX (TX naar computer) GND naar ground (massa 12 V)           Zwart = masaa  werking: band voorwiel is 100/90X19 +- 2,13 Meter / omw   12 pulsen bij 1 omwenteling voorwiel (tellerkabel 3 pulsen per omwenteling) nu 300 pulsen   dus 300/ 12 = 25 omw = 25x 2,13= 53 meter  dus arduino vervanger knipperlicht aan, dan 4 sec wachten dan tellen 300 pulsen (53 Meter) de originele 4 sec wachten dan 50 meter iets gewijzigd, nu: 5 sex wachten en 350 pulsen (63Meter)  verder als de solenoid meer dan 10 sec bekrachtigd: alles outputs uit, error rode led aan,en arduino stop, (reset noddzakelijk)  knipperlicht schakelaar:  wit/rood met Blauw/wit verbonden als Links of rechter knipperlicht werkt zwart naar massa al knipperlicht uit (wordt niet gebruikt in arduino vervanger */ // PIN definitions#define knipper 3#define solenoid 12#define knipperon 10#define error 6#define puls 5#define delayt 7 const int input = 9;  // This is where the input is fed.int pulse = 0;        // Variable for saving pulses count.int var = 0;

// FSM states                                              // de diverse state van de FSM#define idle_state 0#define delay_state 10#define tel_state 20#define solenoid_state 30


// variablesint fsm_state = 0; // beschrijving timers  voorbeeld(millis()-nalooptimer >= 10000?)unsigned long delaytimer;unsigned long solenoidtimer;


void setup() {   // beschrijvng van de in en outputs  pinMode(knipper, INPUT_PULLUP);  pinMode(input, INPUT);  pinMode(solenoid, OUTPUT);  pinMode(knipperon, OUTPUT);  pinMode(error, OUTPUT);  pinMode(puls, OUTPUT);  pinMode(delayt, OUTPUT);   digitalWrite(delayt, LOW);   Serial.begin(9600);} void loop() {   if (digitalRead(knipper) == LOW)  // linker of rechter knipperlicht actief?  {    digitalWrite(knipperon, HIGH);  // als linker of rechter knipperlicht actief zet controle aan  } else {    digitalWrite(knipperon, LOW);  // als linker of rechter knipperlicht niet actief zet controle uit  }   // FSM states  switch (fsm_state) {     case idle_state:  // idle_state, wacht op knipperlicht aktie       Serial.println("idle_state");       if (digitalRead(knipperon) == HIGH)  // kijk of knipperon aan is      {        delaytimer = millis();  // start delaytimer        digitalWrite(delayt, HIGH);        delay(10);         fsm_state = delay_state;      }      break;     case delay_state:       Serial.println("delay_state");       if (digitalRead(knipperon) == LOW) {         fsm_state = idle_state;      }       else if (millis() - delaytimer >= 5000) {        digitalWrite(delayt, LOW);        pulse = 0;        Serial.println("tel_state");        delay(200);         fsm_state = tel_state;      }       break;     case tel_state:       if (digitalRead(knipperon) == LOW) {        digitalWrite(solenoid, LOW);        digitalWrite(delayt, LOW);        fsm_state = idle_state;       } else if (digitalRead(input) == HIGH) {         digitalWrite(puls, HIGH);      } else {        digitalWrite(puls, LOW);        digitalWrite(delayt, LOW);      }       if (digitalRead(input) > var) {         var = 1;        pulse++;         Serial.println(pulse);        //delay(500);      }       if (digitalRead(input) == 0) {        var = 0;      }       if ((pulse) >= 350) {         pulse = 0;        digitalWrite(solenoid, HIGH);        Serial.println("solenoid on");        digitalWrite(puls, LOW);        delay(200);        solenoidtimer = millis();  // start solenoid timer        fsm_state = solenoid_state;      }       break;     case solenoid_state:       Serial.println("solenoid_state");      delay(300);       if (digitalRead(knipperon) == LOW) {        digitalWrite(solenoid, LOW);        Serial.println("solenoid off");        solenoidtimer = millis();        delay(200);        fsm_state = idle_state;      }else if ((digitalRead(solenoid) == HIGH) && (millis() - (solenoidtimer) >= 10000)) {        delay(10);        digitalWrite(solenoid, LOW);        delay(10);        digitalWrite(puls, LOW);        delay(10);        digitalWrite(delayt, LOW);        delay(10);        digitalWrite(knipperon, LOW);        delay(10);        digitalWrite(error, HIGH);        delay(1000);         Serial.println("error timeout");        delay(1000);        exit(0);  // exit program, restart arduino nodig, terugzetten niet gelukt binnen de solenoid time      }      break;  }}

owner of a Kawasaki Z440, 1982.
built from two Kawasaki's 1983 gemany, and a 1982 from Netherlands.
elektrical/electronical engineer, with mechanic as hobby
The following user(s) said Thank You: Wookie58

Please Log in or Create an account to join the conversation.

More
05 Sep 2024 10:24 #903996 by wim2584
Replied by wim2584 on topic Auto canceling turn signal diagnosis
hereby the INO (arduino) file,

I change the file name from .INO  to .DOC  (otherwise upload not possible), So before opening chang extension to .ino

  

File Attachment:

File Name: kawasaki_z...nal .doc
File Size:5 KB

owner of a Kawasaki Z440, 1982.
built from two Kawasaki's 1983 gemany, and a 1982 from Netherlands.
elektrical/electronical engineer, with mechanic as hobby

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum

If you like KZR Please consider making a donation. Thank you.

KZRider is free, but not without cost.

Please consider chipping in a few bucks to help cover the cost of running the KZR servers.