lovely tiny bug which mostly affects NB2 with an impossible one tooth crank trigger wheel

This commit is contained in:
rusefi 2020-01-30 01:47:34 -05:00
parent cf087218c9
commit b6fe6555e0
2 changed files with 21 additions and 1 deletions

View File

@ -357,7 +357,9 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
// That's easy - trigger cycle matches engine cycle
triggerIndexForListeners = triggerState.getCurrentIndex();
} else {
int crankDivider = operationMode == FOUR_STROKE_CRANK_SENSOR ? 2 : 4;
// todo: should this logic reuse getCycleDuration?
bool isCrankDriven = operationMode == FOUR_STROKE_CRANK_SENSOR || operationMode == FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR;
int crankDivider = isCrankDriven ? 2 : 4;
int crankInternalIndex = triggerState.getTotalRevolutionCounter() % crankDivider;

View File

@ -110,3 +110,21 @@ TEST(sensors, testCamInput) {
ASSERT_EQ(0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testCamInput #3";
}
TEST(sensors, testNB2CamInput) {
WITH_ENGINE_TEST_HELPER(MAZDA_MIATA_2003);
// this crank trigger would be easier to test, crank shape is less important for this test
engineConfiguration->useOnlyRisingEdgeForTrigger = true;
eth.setTriggerType(TT_ONE PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_EQ( 0, GET_RPM()) << "testNB2CamInput RPM";
for (int i = 0; i < 5;i++) {
eth.fireRise(50);
}
ASSERT_EQ(1200, GET_RPM()) << "testNB2CamInput RPM";
hwHandleVvtCamSignal(TV_FALL, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
eth.moveTimeForwardUs(MS2US(20));
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
}