updated to fix resync and improve sync fail reporting (#1047)
Fixes #801
This commit is contained in:
parent
9a1c3e30c3
commit
d89cd532f9
|
@ -2849,8 +2849,10 @@ void triggerSetup_Subaru67(void)
|
|||
void triggerPri_Subaru67(void)
|
||||
{
|
||||
curTime = micros();
|
||||
//curGap = curTime - toothLastToothTime;
|
||||
//if ( curGap < triggerFilterTime ) { return; }
|
||||
curGap = curTime - toothLastToothTime;
|
||||
if ( curGap < triggerFilterTime )
|
||||
{ return; }
|
||||
|
||||
toothCurrentCount++; //Increment the tooth counter
|
||||
toothSystemCount++; //Used to count the number of primary pulses that have occurred since the last secondary. Is part of the noise filtering system.
|
||||
BIT_SET(decoderState, BIT_DECODER_VALID_TRIGGER); //Flag this pulse as being a valid trigger (ie that it passed filters)
|
||||
|
@ -2858,9 +2860,13 @@ void triggerPri_Subaru67(void)
|
|||
toothLastMinusOneToothTime = toothLastToothTime;
|
||||
toothLastToothTime = curTime;
|
||||
|
||||
if ( (currentStatus.hasSync == false) || (configPage4.useResync == true) )
|
||||
|
||||
if(toothCurrentCount > 13) //can't have more than 12 teeth so have lost sync
|
||||
{
|
||||
if(toothCurrentCount > 12) { toothCurrentCount = toothCurrentCount % 12; } //Because toothCurrentCount is not being reset when hitting tooth 1, we manually loop it here.
|
||||
toothCurrentCount = 0;
|
||||
currentStatus.hasSync = false;
|
||||
currentStatus.syncLossCounter++;
|
||||
}
|
||||
|
||||
//Sync is determined by counting the number of cam teeth that have passed between the crank teeth
|
||||
switch(secondaryToothCount)
|
||||
|
@ -2871,20 +2877,37 @@ void triggerPri_Subaru67(void)
|
|||
|
||||
case 1:
|
||||
//Can't do anything with a single pulse from the cam either (We need either 2 or 3 pulses)
|
||||
if(toothCurrentCount == 5 || toothCurrentCount == 11)
|
||||
{ currentStatus.hasSync = true; }
|
||||
else
|
||||
{
|
||||
currentStatus.hasSync = false;
|
||||
currentStatus.syncLossCounter++;
|
||||
toothCurrentCount = 5; // we don't know if its 5 or 11, but we'll be right 50% of the time and speed up geting sync 50%
|
||||
}
|
||||
secondaryToothCount = 0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (toothCurrentCount == 8)
|
||||
{ currentStatus.hasSync = true; }
|
||||
else
|
||||
{
|
||||
currentStatus.hasSync = false;
|
||||
currentStatus.syncLossCounter++;
|
||||
toothCurrentCount = 8;
|
||||
//currentStatus.hasSync = true;
|
||||
}
|
||||
secondaryToothCount = 0;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
//toothCurrentCount = 2;
|
||||
if( toothCurrentCount == 2)
|
||||
{ currentStatus.hasSync = true; }
|
||||
else
|
||||
{
|
||||
currentStatus.hasSync = true;
|
||||
currentStatus.hasSync = false;
|
||||
currentStatus.syncLossCounter++;
|
||||
toothCurrentCount = 2;
|
||||
}
|
||||
secondaryToothCount = 0;
|
||||
break;
|
||||
|
@ -2896,8 +2919,6 @@ void triggerPri_Subaru67(void)
|
|||
currentStatus.syncLossCounter++;
|
||||
secondaryToothCount = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Check sync again
|
||||
|
@ -2910,7 +2931,7 @@ void triggerPri_Subaru67(void)
|
|||
else if( (toothCurrentCount == 4) || (toothCurrentCount == 10) ) { endCoil2Charge(); endCoil4Charge(); }
|
||||
}
|
||||
|
||||
if ( toothCurrentCount > 12 ) //2 complete crank revolutions
|
||||
if ( toothCurrentCount > 12 ) // done 720 degrees so increment rotation
|
||||
{
|
||||
toothCurrentCount = 1;
|
||||
toothOneMinusOneTime = toothOneTime;
|
||||
|
@ -2946,7 +2967,7 @@ void triggerPri_Subaru67(void)
|
|||
|
||||
void triggerSec_Subaru67(void)
|
||||
{
|
||||
if( (toothSystemCount == 0) || (toothSystemCount == 3) )
|
||||
if( ((toothSystemCount == 0) || (toothSystemCount == 3)) )
|
||||
{
|
||||
curTime2 = micros();
|
||||
curGap2 = curTime2 - toothLastSecToothTime;
|
||||
|
@ -2974,7 +2995,10 @@ void triggerSec_Subaru67(void)
|
|||
{
|
||||
toothSystemCount = 0;
|
||||
secondaryToothCount = 1;
|
||||
currentStatus.hasSync = false; // impossible to have more than 3 crank teeth between cam teeth - must have noise but can't have sync
|
||||
currentStatus.syncLossCounter++;
|
||||
}
|
||||
secondaryToothCount = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue