Amending some decoders to work with 1st derive prediction

This commit is contained in:
Josh Stewart 2015-11-03 21:57:12 +11:00
parent 4b84e8bab8
commit 68f0ba8cfe
2 changed files with 16 additions and 8 deletions

View File

@ -303,6 +303,7 @@ void triggerPri_GM7X()
toothCurrentCount = 3;
currentStatus.hasSync = true;
startRevolutions++; //Counter
return; //We return here so that the tooth times below don't get set (The magical 3rd tooth should not be considered for any calculations that use those times)
}
}
@ -330,7 +331,7 @@ int getCrankAngle_GM7X(int timePerDegree)
int crankAngle;
if( tempToothCurrentCount < 3 )
{
crankAngle = (tempToothCurrentCount - 1) * 60 + 42; //Number of teeth that have passed since tooth 1, multiplied by the angle each tooth represents, plus the angle that tooth 1 is ATDC. This gives accuracy only to the nearest tooth.
crankAngle = (tempToothCurrentCount - 1) * triggerToothAngle + 42; //Number of teeth that have passed since tooth 1, multiplied by the angle each tooth represents, plus the angle that tooth 1 is ATDC. This gives accuracy only to the nearest tooth.
}
else if( tempToothCurrentCount == 3 )
{
@ -338,7 +339,7 @@ int getCrankAngle_GM7X(int timePerDegree)
}
else
{
crankAngle = (tempToothCurrentCount - 2) * 60 + 42; //Number of teeth that have passed since tooth 1, multiplied by the angle each tooth represents, plus the angle that tooth 1 is ATDC. This gives accuracy only to the nearest tooth.
crankAngle = (tempToothCurrentCount - 2) * triggerToothAngle + 42; //Number of teeth that have passed since tooth 1, multiplied by the angle each tooth represents, plus the angle that tooth 1 is ATDC. This gives accuracy only to the nearest tooth.
}
crankAngle += ldiv( (micros() - tempToothLastToothTime), timePerDegree).quot; //Estimate the number of degrees travelled since the last tooth
@ -459,7 +460,7 @@ Provided that the cam signal is used, this decoder simply counts the teeth and t
*/
void triggerSetup_24X()
{
triggerToothAngle = 180; //The number of degrees that passes from tooth to tooth (primary)
triggerToothAngle = 15; //The number of degrees that passes from tooth to tooth (primary)
toothAngles[0] = 12;
toothAngles[1] = 18;
toothAngles[2] = 33;
@ -550,7 +551,7 @@ http://speeduino.com/forum/download/file.php?id=205
*/
void triggerSetup_Jeep2000()
{
triggerToothAngle = 180; //The number of degrees that passes from tooth to tooth (primary)
triggerToothAngle = 0; //The number of degrees that passes from tooth to tooth (primary)
toothAngles[0] = 174;
toothAngles[1] = 194;
toothAngles[2] = 214;

View File

@ -726,9 +726,17 @@ void loop()
int tempStartAngle;
//How fast are we going? Need to know how long (uS) it will take to get from one tooth to the next. We then use that to estimate how far we are between the last tooth and the next one
long toothAccel = toothDeltaV / 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 / )
//timePerDegree = ldiv( 166666L, currentStatus.RPM ).quot; //There is a small amount of rounding in this calculation, however it is less than 0.001 of a uS (Faster as ldiv than / )
//We use a 1st Deriv accleration prediction, but only when there is an even spacing between primary sensor teeth
//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
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
{
timePerDegree = ldiv( 166666L, currentStatus.RPM ).quot; //There is a small amount of rounding in this calculation, however it is less than 0.001 of a uS (Faster as ldiv than / )
}
//Check that the duty cycle of the chosen pulsewidth isn't too high. This is disabled at cranking
if( !BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) )
@ -741,7 +749,6 @@ void loop()
//***********************************************************************************************
//BEGIN INJECTION TIMING
//Determine next firing angles
//1
int PWdivTimerPerDegree = div(currentStatus.PW, timePerDegree).quot; //How many crank degrees the calculated PW will take at the current speed
injector1StartAngle = configPage1.inj1Ang - ( PWdivTimerPerDegree ); //This is a little primitive, but is based on the idea that all fuel needs to be delivered before the inlet valve opens. See http://www.extraefi.co.uk/sequential_fuel.html for more detail
if(injector1StartAngle < 0) {injector1StartAngle += 360;}