BUG: phase sensor validation attending - detect missing CAM signal fix #659
This commit is contained in:
parent
35964c064c
commit
8b74476c1b
|
@ -807,6 +807,6 @@ int getRusEfiVersion(void) {
|
|||
if (initBootloader() != 0)
|
||||
return 123;
|
||||
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
||||
return 20190509;
|
||||
return 20190510;
|
||||
}
|
||||
#endif /* EFI_UNIT_TEST */
|
||||
|
|
|
@ -496,6 +496,9 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
|
|||
#endif
|
||||
|
||||
if (trgEventIndex == 0) {
|
||||
if (HAVE_CAM_INPUT()) {
|
||||
engine->triggerCentral.triggerState.validateCamVvtCounters();
|
||||
}
|
||||
|
||||
if (checkIfTriggerConfigChanged(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
||||
engine->ignitionEvents.isReady = false; // we need to rebuild ignition schedule
|
||||
|
|
|
@ -99,6 +99,7 @@ void hwHandleVvtCamSignal(trigger_value_e front DECLARE_ENGINE_PARAMETER_SUFFIX)
|
|||
}
|
||||
|
||||
TriggerCentral *tc = &engine->triggerCentral;
|
||||
tc->triggerState.vvtCamCounter++;
|
||||
|
||||
efitick_t nowNt = getTimeNowNt();
|
||||
|
||||
|
|
|
@ -293,6 +293,17 @@ int TriggerState::getCurrentIndex() const {
|
|||
return currentCycle.current_index;
|
||||
}
|
||||
|
||||
void TriggerState::validateCamVvtCounters() {
|
||||
// micro-optimized 'totalRevolutionCounter % 256'
|
||||
int camVvtValidationIndex = totalRevolutionCounter & 0xFF;
|
||||
if (camVvtValidationIndex == 0) {
|
||||
vvtCamCounter = 0;
|
||||
} else if (camVvtValidationIndex == 0xFE && vvtCamCounter < 60) {
|
||||
// magic logic: we expect at least 60 CAM/VVT events for each 256 trigger cycles, otherwise throw a code
|
||||
warning(OBD_Camshaft_Position_Sensor_Circuit_Range_Performance, "no CAM signals");
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerState::incrementTotalEventCounter() {
|
||||
totalRevolutionCounter++;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
* this is important for crank-based virtual trigger and VVT magic
|
||||
*/
|
||||
bool isEvenRevolution() const;
|
||||
void validateCamVvtCounters();
|
||||
void incrementTotalEventCounter();
|
||||
efitime_t getTotalEventCounter() const;
|
||||
efitime_t getStartOfRevolutionIndex() const;
|
||||
|
@ -109,6 +110,7 @@ public:
|
|||
* for virtual double trigger see timeAtVirtualZeroNt
|
||||
*/
|
||||
efitick_t startOfCycleNt;
|
||||
int vvtCamCounter = 0;
|
||||
private:
|
||||
void resetCurrentCycleState();
|
||||
|
||||
|
@ -117,7 +119,6 @@ private:
|
|||
efitime_t totalEventCountBase;
|
||||
uint32_t totalRevolutionCounter;
|
||||
bool isFirstEvent;
|
||||
|
||||
};
|
||||
|
||||
// we only need 90 degrees of events so /4 or maybe even /8 should work?
|
||||
|
|
|
@ -88,25 +88,25 @@ TEST(sensors, testCamInput) {
|
|||
|
||||
ASSERT_EQ( 0, GET_RPM()) << "testCamInput RPM";
|
||||
|
||||
eth.fireRise(50);
|
||||
eth.fireRise(50);
|
||||
eth.fireRise(50);
|
||||
eth.fireRise(50);
|
||||
eth.fireRise(50);
|
||||
for (int i = 0; i < 5;i++) {
|
||||
eth.fireRise(50);
|
||||
}
|
||||
|
||||
ASSERT_EQ(1200, GET_RPM()) << "testCamInput RPM";
|
||||
ASSERT_EQ(0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testCamInput";
|
||||
|
||||
for (int i = 0; i < 50;i++) {
|
||||
for (int i = 0; i < 600;i++) {
|
||||
eth.fireRise(50);
|
||||
}
|
||||
|
||||
ASSERT_EQ(0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testCamInput #2";
|
||||
ASSERT_EQ(1, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testCamInput #2";
|
||||
ASSERT_EQ(OBD_Camshaft_Position_Sensor_Circuit_Range_Performance, unitTestWarningCodeState.recentWarnings.get(0)) << "@0";
|
||||
unitTestWarningCodeState.recentWarnings.clear();
|
||||
|
||||
for (int i = 0; i < 50;i++) {
|
||||
for (int i = 0; i < 600;i++) {
|
||||
eth.fireRise(50);
|
||||
hwHandleVvtCamSignal(TV_FALL PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
|
||||
ASSERT_EQ(0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testCamInput #3";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue