Actually return a value when using the higher resolution cranking RPM

This commit is contained in:
Josh Stewart 2015-11-04 21:49:37 +11:00
parent 68f0ba8cfe
commit 4191e6e865
3 changed files with 13 additions and 10 deletions

View File

@ -13,7 +13,7 @@ volatile unsigned long toothOneTime = 0; //The time (micros()) that tooth 1 last
volatile unsigned long toothOneMinusOneTime = 0; //The 2nd to last time (micros()) that tooth 1 last triggered
volatile unsigned int toothHistory[TOOTH_LOG_BUFFER];
volatile unsigned int toothHistoryIndex = 0;
volatile long toothDeltaV; //Represents the change in time taken between the last 2 teeth compared to the previous 2. Positive value represents accleration, negative = deccleration
volatile long toothDeltaT; //Represents the change in time taken between the last 2 teeth compared to the previous 2. Positive value represents accleration, negative = deccleration
volatile byte secondaryToothCount; //Used for identifying the current secondary (Usually cam) tooth for patterns with multiple secondary teeth
volatile unsigned long secondaryLastToothTime = 0; //The time (micros()) that the last tooth was registered (Cam input)

View File

@ -96,7 +96,7 @@ void triggerPri_missingTooth()
startRevolutions++; //Counter
}
toothDeltaV = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime - toothLastToothTime); //Positive value = accleration, Negative = decceleration
toothDeltaT = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime - toothLastToothTime); //Positive value = accleration, Negative = decceleration
toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime;
}
@ -160,7 +160,7 @@ void triggerPri_DualWheel()
addToothLogEntry(curGap);
toothDeltaV = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime - toothLastToothTime); //Positive value = accleration, Negative = decceleration
toothDeltaT = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime - toothLastToothTime); //Positive value = accleration, Negative = decceleration
toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime;
}
@ -239,14 +239,14 @@ void triggerPri_BasicDistributor()
addToothLogEntry(curGap);
toothDeltaV = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime -toothLastToothTime); //Positive value = accleration, Negative = decceleration
toothDeltaT = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime -toothLastToothTime); //Positive value = accleration, Negative = decceleration
toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime;
}
void triggerSec_BasicDistributor() { return; } //Not required
int getRPM_BasicDistributor()
{
if(currentStatus.RPM < configPage2.crankRPM) { crankingGetRPM((configPage1.nCylinders >> 1)); }
if(currentStatus.RPM < configPage2.crankRPM) { return crankingGetRPM((configPage1.nCylinders >> 1)); }
else { return stdGetRPM(); }
}
int getCrankAngle_BasicDistributor(int timePerDegree)
@ -307,7 +307,7 @@ void triggerPri_GM7X()
}
}
toothDeltaV = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime - toothLastToothTime); //Positive value = accleration, Negative = decceleration
toothDeltaT = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime - toothLastToothTime); //Positive value = accleration, Negative = decceleration
toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime;
}
@ -399,7 +399,10 @@ void triggerPri_4G63()
addToothLogEntry(curGap);
toothDeltaV = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime - toothLastToothTime); //Positive value = accleration, Negative = decceleration
//Whilst this is an uneven tooth pattern, if the specific angle between the last 2 teeth is specified, 1st deriv prediction can be used
if(toothCurrentCount == 1 || toothCurrentCount == 3) { triggerToothAngle = 70; }
else { triggerToothAngle = 110; }
toothDeltaT = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime - toothLastToothTime); //Positive value = accleration, Negative = decceleration
toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime;
}
@ -427,7 +430,7 @@ void triggerSec_4G63()
int getRPM_4G63()
{
if(currentStatus.RPM < configPage2.crankRPM) { crankingGetRPM(2); }
if(currentStatus.RPM < configPage2.crankRPM) { return crankingGetRPM(2); }
else { return stdGetRPM(); }
}
int getCrankAngle_4G63(int timePerDegree)
@ -589,7 +592,7 @@ void triggerPri_Jeep2000()
addToothLogEntry(curGap);
toothDeltaV = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime - toothLastToothTime); //Positive value = accleration, Negative = decceleration
toothDeltaT = (toothLastToothTime - toothLastMinusOneToothTime) - (curTime - toothLastToothTime); //Positive value = accleration, Negative = decceleration
toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime;
}

View File

@ -730,7 +730,7 @@ void loop()
//Any decoder that has uneven spacing has its triggerToothAngle set to 0
if(triggerToothAngle > 0)
{
long toothAccel = toothDeltaV / triggerToothAngle; //An amount represengint the current acceleration or decceleration of the crank in degrees per uS per uS
long toothAccel = toothDeltaT / triggerToothAngle; //An amount represengint the current acceleration or decceleration of the crank in degrees per uS per uS
timePerDegree = ldiv( 166666L, currentStatus.RPM ).quot + (toothAccel * (micros() - toothLastToothTime)); //There is a small amount of rounding in this calculation, however it is less than 0.001 of a uS (Faster as ldiv than / )
}
else