From 9dd0908d45d670719beb919bb1dc492339930fb7 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Fri, 9 Oct 2015 12:08:14 +1100 Subject: [PATCH] Minor safety checks added --- decoders.ino | 2 ++ speeduino.ino | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/decoders.ino b/decoders.ino index 744695e..f8d8b52 100644 --- a/decoders.ino +++ b/decoders.ino @@ -352,6 +352,7 @@ void triggerSetup_4G63() toothAngles[1] = 105; //Rising edge of tooth #2 toothAngles[2] = 175; //Falling edge of tooth #2 toothAngles[3] = 285; //Rising edge of tooth #1 + /* toothAngles[0] = 105; //Falling edge of tooth #1 toothAngles[1] = 175; //Rising edge of tooth #2 @@ -431,6 +432,7 @@ int getCrankAngle_4G63(int timePerDegree) int crankAngle = toothAngles[(tempToothCurrentCount - 1)] + configPage2.triggerAngle; //Perform a lookup of the fixed toothAngles array to find what the angle of the last tooth passed was. crankAngle += ldiv( (micros() - tempToothLastToothTime), timePerDegree).quot; //Estimate the number of degrees travelled since the last tooth if (crankAngle > 360) { crankAngle -= 360; } + if (crankAngle < 0) { crankAngle += 360; } return crankAngle; } diff --git a/speeduino.ino b/speeduino.ino index 6be80df..c9c2afc 100644 --- a/speeduino.ino +++ b/speeduino.ino @@ -820,7 +820,7 @@ void loop() if( tempCrankAngle < 0) { tempCrankAngle += 360; } tempStartAngle = ignition2StartAngle - channel2IgnDegrees; if ( tempStartAngle < 0) { tempStartAngle += 360; } - if (tempStartAngle > tempCrankAngle) + if ( (tempStartAngle > tempCrankAngle) && ign2LastRev != startRevolutions) { setIgnitionSchedule2(beginCoil2Charge, ((unsigned long)(tempStartAngle - tempCrankAngle) * (unsigned long)timePerDegree), @@ -895,6 +895,5 @@ void openInjector1and4() { digitalWrite(pinInjector1, HIGH); digitalWrite(pinInj void closeInjector1and4() { digitalWrite(pinInjector1, LOW); digitalWrite(pinInjector4, LOW);BIT_CLEAR(currentStatus.squirt, 0); } void openInjector2and3() { digitalWrite(pinInjector2, HIGH); digitalWrite(pinInjector3, HIGH); BIT_SET(currentStatus.squirt, 1); } void closeInjector2and3() { digitalWrite(pinInjector2, LOW); digitalWrite(pinInjector3, LOW); BIT_CLEAR(currentStatus.squirt, 1); } -