BUG: phase sensor validation attending - detect missing CAM signal fix #659

This commit is contained in:
rusefi 2019-05-11 00:21:37 -04:00
parent ff1d10dd2e
commit 812c61903a
6 changed files with 27 additions and 11 deletions

View File

@ -807,6 +807,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0) if (initBootloader() != 0)
return 123; return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */ #endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20190509; return 20190510;
} }
#endif /* EFI_UNIT_TEST */ #endif /* EFI_UNIT_TEST */

View File

@ -496,6 +496,9 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
#endif #endif
if (trgEventIndex == 0) { if (trgEventIndex == 0) {
if (HAVE_CAM_INPUT()) {
engine->triggerCentral.triggerState.validateCamVvtCounters();
}
if (checkIfTriggerConfigChanged(PASS_ENGINE_PARAMETER_SIGNATURE)) { if (checkIfTriggerConfigChanged(PASS_ENGINE_PARAMETER_SIGNATURE)) {
engine->ignitionEvents.isReady = false; // we need to rebuild ignition schedule engine->ignitionEvents.isReady = false; // we need to rebuild ignition schedule

View File

@ -99,6 +99,7 @@ void hwHandleVvtCamSignal(trigger_value_e front DECLARE_ENGINE_PARAMETER_SUFFIX)
} }
TriggerCentral *tc = &engine->triggerCentral; TriggerCentral *tc = &engine->triggerCentral;
tc->triggerState.vvtCamCounter++;
efitick_t nowNt = getTimeNowNt(); efitick_t nowNt = getTimeNowNt();

View File

@ -293,6 +293,17 @@ int TriggerState::getCurrentIndex() const {
return currentCycle.current_index; 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() { void TriggerState::incrementTotalEventCounter() {
totalRevolutionCounter++; totalRevolutionCounter++;
} }

View File

@ -56,6 +56,7 @@ public:
* this is important for crank-based virtual trigger and VVT magic * this is important for crank-based virtual trigger and VVT magic
*/ */
bool isEvenRevolution() const; bool isEvenRevolution() const;
void validateCamVvtCounters();
void incrementTotalEventCounter(); void incrementTotalEventCounter();
efitime_t getTotalEventCounter() const; efitime_t getTotalEventCounter() const;
efitime_t getStartOfRevolutionIndex() const; efitime_t getStartOfRevolutionIndex() const;
@ -109,6 +110,7 @@ public:
* for virtual double trigger see timeAtVirtualZeroNt * for virtual double trigger see timeAtVirtualZeroNt
*/ */
efitick_t startOfCycleNt; efitick_t startOfCycleNt;
int vvtCamCounter = 0;
private: private:
void resetCurrentCycleState(); void resetCurrentCycleState();
@ -117,7 +119,6 @@ private:
efitime_t totalEventCountBase; efitime_t totalEventCountBase;
uint32_t totalRevolutionCounter; uint32_t totalRevolutionCounter;
bool isFirstEvent; bool isFirstEvent;
}; };
// we only need 90 degrees of events so /4 or maybe even /8 should work? // we only need 90 degrees of events so /4 or maybe even /8 should work?

View File

@ -88,25 +88,25 @@ TEST(sensors, testCamInput) {
ASSERT_EQ( 0, GET_RPM()) << "testCamInput RPM"; ASSERT_EQ( 0, GET_RPM()) << "testCamInput RPM";
eth.fireRise(50); for (int i = 0; i < 5;i++) {
eth.fireRise(50); eth.fireRise(50);
eth.fireRise(50); }
eth.fireRise(50);
eth.fireRise(50);
ASSERT_EQ(1200, GET_RPM()) << "testCamInput RPM"; ASSERT_EQ(1200, GET_RPM()) << "testCamInput RPM";
ASSERT_EQ(0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testCamInput"; 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); 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); eth.fireRise(50);
hwHandleVvtCamSignal(TV_FALL PASS_ENGINE_PARAMETER_SUFFIX);
} }
ASSERT_EQ(0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testCamInput #3"; ASSERT_EQ(0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testCamInput #3";
} }