Minor safety checks added

This commit is contained in:
Josh Stewart 2015-10-09 12:08:14 +11:00
parent 56b5fcd69d
commit 9dd0908d45
2 changed files with 3 additions and 2 deletions

View File

@ -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;
}

View File

@ -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); }