From ec516f5192fbb4511774d936823af70fc0ac3487 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Tue, 4 Sep 2018 19:47:04 +1000 Subject: [PATCH] Only use per tooth timing when fixed cranking isn't operational --- speeduino/decoders.ino | 43 ++++++++++++++++++++++------------------- speeduino/globals.h | 1 + speeduino/speeduino.ino | 1 - 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/speeduino/decoders.ino b/speeduino/decoders.ino index 8eb1d916..3b510897 100644 --- a/speeduino/decoders.ino +++ b/speeduino/decoders.ino @@ -116,27 +116,30 @@ If it's the correct tooth, but */ #define checkPerToothTiming(crankAngle, currentTooth) \ { \ - if ( (currentTooth == ignition1EndTooth) ) \ + if (fixedCrankingOverride != 0) \ { \ - if( (ignitionSchedule1.Status == RUNNING) ) { IGN1_COMPARE = IGN1_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition1EndAngle - crankAngle) ) ) ); } \ - else { ignitionSchedule1.endCompare = IGN1_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition1EndAngle - crankAngle) ) ) ); ignitionSchedule1.endScheduleSetByDecoder = true; } \ - } \ -\ - else if ( (currentTooth == ignition2EndTooth) ) \ - { \ - if( (ignitionSchedule2.Status == RUNNING) ) { IGN2_COMPARE = IGN2_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition2EndAngle - crankAngle) ) ) ); } \ - else { ignitionSchedule2.endCompare = IGN2_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition2EndAngle - crankAngle) ) ) ); ignitionSchedule2.endScheduleSetByDecoder = true; } \ - } \ -\ - else if ( (currentTooth == ignition3EndTooth) ) \ - { \ - if( (ignitionSchedule3.Status == RUNNING) ) { IGN3_COMPARE = IGN3_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition3EndAngle - crankAngle) ) ) ); } \ - else { ignitionSchedule3.endCompare = IGN3_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition3EndAngle - crankAngle) ) ) ); ignitionSchedule3.endScheduleSetByDecoder = true; } \ - } \ - else if ( (currentTooth == ignition4EndTooth) ) \ - { \ - if( (ignitionSchedule4.Status == RUNNING) ) { IGN4_COMPARE = IGN4_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition4EndAngle - crankAngle) ) ) ); } \ - else { ignitionSchedule4.endCompare = IGN4_COUNTER + uS_TO_TIMER_COMPARE_SLOW( fastDegreesToUS( ignitionLimits( (ignition4EndAngle - crankAngle) ) ) ); ignitionSchedule4.endScheduleSetByDecoder = true; } \ + if ( (currentTooth == ignition1EndTooth) ) \ + { \ + if( (ignitionSchedule1.Status == RUNNING) ) { IGN1_COMPARE = IGN1_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition1EndAngle - crankAngle) ) ) ); } \ + else { ignitionSchedule1.endCompare = IGN1_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition1EndAngle - crankAngle) ) ) ); ignitionSchedule1.endScheduleSetByDecoder = true; } \ + } \ + \ + else if ( (currentTooth == ignition2EndTooth) ) \ + { \ + if( (ignitionSchedule2.Status == RUNNING) ) { IGN2_COMPARE = IGN2_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition2EndAngle - crankAngle) ) ) ); } \ + else { ignitionSchedule2.endCompare = IGN2_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition2EndAngle - crankAngle) ) ) ); ignitionSchedule2.endScheduleSetByDecoder = true; } \ + } \ + \ + else if ( (currentTooth == ignition3EndTooth) ) \ + { \ + if( (ignitionSchedule3.Status == RUNNING) ) { IGN3_COMPARE = IGN3_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition3EndAngle - crankAngle) ) ) ); } \ + else { ignitionSchedule3.endCompare = IGN3_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition3EndAngle - crankAngle) ) ) ); ignitionSchedule3.endScheduleSetByDecoder = true; } \ + } \ + else if ( (currentTooth == ignition4EndTooth) ) \ + { \ + if( (ignitionSchedule4.Status == RUNNING) ) { IGN4_COMPARE = IGN4_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS( ignitionLimits( (ignition4EndAngle - crankAngle) ) ) ); } \ + else { ignitionSchedule4.endCompare = IGN4_COUNTER + uS_TO_TIMER_COMPARE_SLOW( fastDegreesToUS( ignitionLimits( (ignition4EndAngle - crankAngle) ) ) ); ignitionSchedule4.endScheduleSetByDecoder = true; } \ + } \ } \ } diff --git a/speeduino/globals.h b/speeduino/globals.h index 5338dd07..cc107c0b 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -295,6 +295,7 @@ volatile uint16_t mainLoopCount; unsigned long revolutionTime; //The time in uS that one revolution would take at current speed (The time tooth 1 was last seen, minus the time it was seen prior to that) volatile unsigned long timer5_overflow_count = 0; //Increments every time counter 5 overflows. Used for the fast version of micros() volatile unsigned long ms_counter = 0; //A counter that increments once per ms +uint16_t fixedCrankingOverride = 0; bool clutchTrigger; bool previousClutchTrigger; volatile uint16_t toothHistory[TOOTH_LOG_BUFFER]; diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index 77783fba..fa0df671 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -78,7 +78,6 @@ byte maxIgnOutputs = 1; //Used for rolling rev limiter byte curRollingCut = 0; //Rolling rev limiter, current ignition channel being cut byte rollingCutCounter = 0; //how many times (revolutions) the ignition has been cut in a row uint32_t rollingCutLastRev = 0; //Tracks whether we're on the same or a different rev for the rolling cut -uint16_t fixedCrankingOverride = 0; unsigned long secCounter; //The next time to incremen 'runSecs' counter.