Initial commit of dynamic stall time.

This commit is contained in:
Josh Stewart 2016-04-26 17:43:19 +10:00
parent 4b3f60bd78
commit 310ecd0b4c
2 changed files with 16 additions and 5 deletions

View File

@ -82,6 +82,7 @@ void triggerSetup_missingTooth()
triggerFilterTime = (int)(1000000 / (MAX_RPM / 60 * configPage2.triggerTeeth)); //Trigger filter time is the shortest possible time (in uS) that there can be between crank teeth (ie at max RPM). Any pulses that occur faster than this time will be disgarded as noise
secondDerivEnabled = false;
decoderIsSequential = false;
MAX_STALL_TIME = (3333UL * triggerToothAngle * (configPage2.triggerMissingTeeth + 1)); //Minimum 50rpm. (3333uS is the time per degree at 50rpm)
}
void triggerPri_missingTooth()
@ -164,6 +165,7 @@ void triggerSetup_DualWheel()
triggerSecFilterTime = (int)(1000000 / (MAX_RPM / 60 * 2)) / 2; //Same as above, but fixed at 2 teeth on the secondary input and divided by 2 (for cam speed)
secondDerivEnabled = false;
decoderIsSequential = true;
MAX_STALL_TIME = (3333UL * triggerToothAngle); //Minimum 50rpm. (3333uS is the time per degree at 50rpm)
}
@ -253,6 +255,7 @@ void triggerSetup_BasicDistributor()
triggerFilterTime = triggerFilterTime / 2; //Safety margin
secondDerivEnabled = false;
decoderIsSequential = false;
MAX_STALL_TIME = (1851UL * triggerToothAngle); //Minimum 90rpm. (1851uS is the time per degree at 90rpm). This decoder uses 90rpm rather than 50rpm due to the potentially very high stall time on a 4 cylinder if we wait that long.
}
void triggerPri_BasicDistributor()
@ -325,6 +328,7 @@ void triggerSetup_GM7X()
triggerToothAngle = 360 / 6; //The number of degrees that passes from tooth to tooth
secondDerivEnabled = false;
decoderIsSequential = false;
MAX_STALL_TIME = (3333UL * triggerToothAngle); //Minimum 50rpm. (3333uS is the time per degree at 50rpm)
}
void triggerPri_GM7X()
@ -415,6 +419,7 @@ void triggerSetup_4G63()
toothCurrentCount = 99; //Fake tooth count represents no sync
secondDerivEnabled = false;
decoderIsSequential = true;
MAX_STALL_TIME = 366667UL; //Minimum 50rpm based on the 110 degree tooth spacing
//Note that these angles are for every rising and falling edge
@ -559,6 +564,7 @@ void triggerSetup_24X()
toothAngles[22] = 342;
toothAngles[23] = 357;
MAX_STALL_TIME = (3333UL * triggerToothAngle); //Minimum 50rpm. (3333uS is the time per degree at 50rpm)
toothCurrentCount = 25; //We set the initial tooth value to be something that should never be reached. This indicates no sync
secondDerivEnabled = false;
decoderIsSequential = true;
@ -647,9 +653,10 @@ void triggerSetup_Jeep2000()
toothAngles[10] = 454;
toothAngles[11] = 474;
MAX_STALL_TIME = (3333UL * 60); //Minimum 50rpm. (3333uS is the time per degree at 50rpm). Largest gap between teeth is 60 degrees.
toothCurrentCount = 13; //We set the initial tooth value to be something that should never be reached. This indicates no sync
secondDerivEnabled = false;
decoderIsSequential = true;
decoderIsSequential = false;
}
void triggerPri_Jeep2000()
@ -727,6 +734,7 @@ void triggerSetup_Audi135()
toothSystemCount = 0;
triggerFilterTime = (unsigned long)(1000000 / (MAX_RPM / 60 * 135UL)); //Trigger filter time is the shortest possible time (in uS) that there can be between crank teeth (ie at max RPM). Any pulses that occur faster than this time will be disgarded as noise
triggerSecFilterTime = (int)(1000000 / (MAX_RPM / 60 * 2)) / 2; //Same as above, but fixed at 2 teeth on the secondary input and divided by 2 (for cam speed)
MAX_STALL_TIME = (3333UL * triggerToothAngle); //Minimum 50rpm. (3333uS is the time per degree at 50rpm)
secondDerivEnabled = false;
decoderIsSequential = true;
}
@ -814,6 +822,7 @@ Note:
void triggerSetup_HondaD17()
{
triggerToothAngle = 360 / 12; //The number of degrees that passes from tooth to tooth
MAX_STALL_TIME = (3333UL * triggerToothAngle); //Minimum 50rpm. (3333uS is the time per degree at 50rpm)
secondDerivEnabled = false;
decoderIsSequential = false;
}
@ -914,6 +923,7 @@ void triggerSetup_Miata9905()
toothAngles[2] = 170; //Falling edge of tooth #2
toothAngles[3] = 280; //Rising edge of tooth #1
MAX_STALL_TIME = (3333UL * triggerToothAngle); //Minimum 50rpm. (3333uS is the time per degree at 50rpm)
triggerFilterTime = 1500; //10000 rpm, assuming we're triggering on both edges off the crank tooth.
triggerSecFilterTime = (int)(1000000 / (MAX_RPM / 60 * 2)) / 2; //Same as above, but fixed at 2 teeth on the secondary input and divided by 2 (for cam speed)
}

View File

@ -111,6 +111,7 @@ byte deltaToothCount = 0; //The last tooth that was used with the deltaV calc
int rpmDelta;
byte ignitionCount;
unsigned long secCounter; //The next time to incremen 'runSecs' counter.
unsigned long MAX_STALL_TIME = 500000UL; //The maximum time (in uS) that the system will continue to function before the engine is considered stalled/stopped. This is unique to each decoder, depending on the number of teeth etc. 500000 (half a second) is used as the default value, most decoders will be much less.
int channel1IgnDegrees; //The number of crank degrees until cylinder 1 is at TDC (This is obviously 0 for virtually ALL engines, but there's some weird ones)
int channel2IgnDegrees; //The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC
int channel3IgnDegrees; //The number of crank degrees until cylinder 3 (and 5/6/7/8) is at TDC
@ -631,7 +632,7 @@ void loop()
previousLoopTime = currentLoopTime;
currentLoopTime = micros();
unsigned long timeToLastTooth = (currentLoopTime - toothLastToothTime);
if ( (timeToLastTooth < 500000L) || (toothLastToothTime > currentLoopTime) ) //Check how long ago the last tooth was seen compared to now. If it was more than half a second ago then the engine is probably stopped. toothLastToothTime can be greater than currentLoopTime if a pulse occurs between getting the lastest time and doing the comparison
if ( (timeToLastTooth < MAX_STALL_TIME) || (toothLastToothTime > currentLoopTime) ) //Check how long ago the last tooth was seen compared to now. If it was more than half a second ago then the engine is probably stopped. toothLastToothTime can be greater than currentLoopTime if a pulse occurs between getting the lastest time and doing the comparison
{
int lastRPM = currentStatus.RPM; //Need to record this for rpmDOT calculation
currentStatus.RPM = getRPM();