//Still uses a last interval method (ie retrospective), but bases the interval on the gap between the 2 most recent teeth rather than the last full revolution
else{returnTime=angleToTime(angle,CRANKMATH_METHOD_INTERVAL_REV);}//Safety check. This can occur if the last tooth seen was outside the normal pattern etc
//A last interval method of calculating angle that does not take into account any acceleration. The interval used is the time taken to complete the last full revolution
//degreesPeruSx2048 is the number of degrees the crank moves per uS. This value is almost always <1uS, so it is multiplied by 2048. This allows an angle calcuation with only a multiply and a bitshift without any appreciable drop in accuracy
//Still uses a last interval method (ie retrospective), but bases the interval on the gap between the 2 most recent teeth rather than the last full revolution
else{returnAngle=timeToAngle(time,CRANKMATH_METHOD_INTERVAL_REV);}//Safety check. This can occur if the last tooth seen was outside the normal pattern etc
//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
//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((secondDerivEnabled>0)&&(toothHistoryIndex>=3)&&(currentStatus.RPM<2000))//toothHistoryIndex must be greater than or equal to 3 as we need the last 3 entries. Currently this mode only runs below 3000 rpm
{
//Only recalculate deltaV if the tooth has changed since last time (DeltaV stays the same until the next tooth)
//if (deltaToothCount != toothCurrentCount)
{
deltaToothCount=toothCurrentCount;
intangle1,angle2;//These represent the crank angles that are travelled for the last 2 pulses
if(configPage4.TrigPattern==4)
{
//Special case for 70/110 pattern on 4g63
angle2=triggerToothAngle;//Angle 2 is the most recent
if(angle2==70){angle1=110;}
else{angle1=70;}
}
elseif(configPage4.TrigPattern==0)
{
//Special case for missing tooth decoder where the missing tooth was one of the last 2 seen
timePerDegreex16=ldiv(2666656L,currentStatus.RPM+rpmDelta).quot;//This give accuracy down to 0.1 of a degree and can provide noticably better timing results on low res triggers
timePerDegree=timePerDegreex16/16;
}
else
{
//If we can, attempt to get the timePerDegree by comparing the times of the last two teeth seen. This is only possible for evenly spaced teeth
timePerDegreex16=ldiv(2666656L,currentStatus.RPM+rpm_adjust).quot;//The use of a x16 value gives accuracy down to 0.1 of a degree and can provide noticably better timing results on low res triggers