Timing Drift as rpm changes, with my Uno Ignition controller has been a huge problem. No matter what I did, for the longest time, I could not keep the system from losing about 8 degrees between about 300 and 3000 rpms. I have finally solved the problem and that’s what this update is about.

, https://i.ytimg.com/vi/U2_MIf4DJO8/hqdefault.jpg

source

8 Comments

  1. how did you calculated the dwell time for example if you want to spark at 45 TDC you have to trigger 3000 – 4000uS before the 45 degs before TDC. so you have to combine the dwell time with advance delay

  2. // DECLARATION OF VARIABLES //

    // COILS //
    int COIL1 = 4;
    int COIL2 = 5;
    int COIL3 = 6;
    int COIL4 = 7;
    //

    // GLOBALS //
    int FIRSTCOIL = 2;
    int NEXTCOIL = 0;
    int SYNCED = 0;
    int LED = 13;
    int DWELL = 2500;
    int RUNNING = 0;

    //

    // SYNCHRONIZATION //
    int COILTR = 8;
    int SYNCTR = 12;
    int SYNCNT = 0;
    unsigned long COILDUR;
    unsigned long SYNCDUR;
    //

    // READ RPM
    int SPARKS = 0;
    int RPM = 0;
    unsigned long LASTMILLIS = 0;
    //

    void setup() {
    //Serial.begin(115200);
    pinMode(COIL1, OUTPUT);
    pinMode(COIL2, OUTPUT);
    pinMode(COIL3, OUTPUT);
    pinMode(COIL4, OUTPUT);
    pinMode(LED,OUTPUT);
    //
    pinMode(COILTR, INPUT);
    pinMode(SYNCTR, INPUT);
    //
    }

    // the loop routine runs over and over again forever:
    void loop() {

    // SYNCHING ///
    if (SYNCED == 0){
    //
    SYNCDUR = pulseIn(SYNCTR, HIGH,800000);
    //
    if (SYNCDUR > 0){
    SYNCNT++;
    }

    if (SYNCDUR > 0 && SYNCNT > 1){ // AT LEAST 2 SYNCHS BEFORE SET AS SYNCED //
    NEXTCOIL = FIRSTCOIL;
    SYNCED = 1;
    digitalWrite(LED, HIGH);
    SYNCNT = 0;
    }

    }
    //

    if (SYNCED == 1){
    COILDUR = pulseIn(COILTR, HIGH);
    }

    if (COILDUR > 0 && SYNCED == 1){

    if (NEXTCOIL == 1){
    FIRE_COIL1();
    NEXTCOIL = 3;
    }else if (NEXTCOIL == 3){
    FIRE_COIL3();
    NEXTCOIL = 4;
    }else if (NEXTCOIL == 4){
    FIRE_COIL4();
    NEXTCOIL = 2;
    }else if (NEXTCOIL == 2){
    FIRE_COIL2();
    NEXTCOIL = 1;
    }

    if (RPM > 400 && RUNNING == 0){
    RUNNING = 1;
    }

    }

    if (SPARKS >= 8) {
    RPM = 30*1000/(millis() – LASTMILLIS)*SPARKS;
    LASTMILLIS = millis();
    SPARKS = 0;
    }

    if (RPM < 80 && RUNNING == 1){
    SYNCED = 0;
    RUNNING = 0;
    digitalWrite(LED, LOW);
    }

    if (RPM > 6000 ){
    DWELL = 2700;
    }

    if (RPM > 7000 ){
    DWELL = 2550;
    }

    if (RPM > 7600 ){
    DWELL = 2350;
    }

    SPARKS++;
    }

    void FIRE_COIL1(){
    digitalWrite(COIL1, HIGH);
    delayMicroseconds(DWELL);
    digitalWrite(COIL1, LOW);
    }

    void FIRE_COIL2(){
    digitalWrite(COIL2, HIGH);
    delayMicroseconds(DWELL);
    digitalWrite(COIL2, LOW);
    }

    void FIRE_COIL3(){
    digitalWrite(COIL3, HIGH);
    delayMicroseconds(DWELL);
    digitalWrite(COIL3, LOW);
    }

    void FIRE_COIL4(){
    digitalWrite(COIL4, HIGH);
    delayMicroseconds(DWELL);
    digitalWrite(COIL4, LOW);
    }

  3. Hi Pete! I'm sure you already know this, but if not – maybe this helps you in some way. There is an arduino powered standalone ECU being developed called Speeduino. For your project it is probably not the way to go, but you can definitely check out the source code of speeduino to see how that works.

  4. Hello Anders.  I think we are going to try an engine pretty soon.I am really glad to see that Josh Stewart has chimed in.I see him as THE expert on this sort of thing.  My simulator's little motor only goes to about 3300 rpms right now.  I have ordered and received a bunch of 6000-10,000 rpm motors so I can try it out at the "real" design speed.  But all that will have to wait a few weeks.  I did look at your code, but I didn't have time to read all of the responses in detail.  Looks like you are getting some good advice.  I can learn a lot from reading the comments.What kind of coil are you using? 
    We had a hard time finding a 2-tower, 4-wire Coil Near plug pak that we could easily get low voltage connectors for.The one we have chosen (so far) is from a 1999 Toyota RAV4.   There must be many others out there that will work, but we haven't found them yet.       We should have a common place for continuing these discussions and I hope that Josh continues to look in on us.UNO dedicated simple ECU guy,Pete Stanaitis———————-

  5. Hello Pete!
    I can't tell you how surprised I am when I see your video and your code! I live on the other side of the earth, working on almost exactly the same project as you are doing! You can read about my Arduino EIS here:[urlhttps://forum.arduino.cc/index.php?topic=369684.0[/url]

    I am having the same problem as you are. I hope we can help each other. I will try to use an other arduino to simulate the engine and a third arduino like an scope. I have a lot of trouble with high EMP. I will try to build an aluminum box and use all shielded cables. I will also try to use optocoupler between the coil ignitor and arduino.
    If you have any wiring diagram I would love to see it. I would be glad if you could join the arduino forum and discuss more.
    I also have an idea for making the system redundant. Using two of everything except the coilpack (VAG Bosch smart coil pack).
    Hope to hear from you!
    Greetings from Anders Stenhammar in Sweden.
    http://www.andersstenhammar.com

  6. As you can see, I did just add a link to my current code.  But I am not a programmer and so this code isn't professional in any sense of the word.  So you have to use it at your own discretion.   But I will entertain any questions that you might have about it.  Also, if you do use it and find any great stuff to add to it, please let me know.

Leave a Reply

Your email address will not be published. Required fields are marked *