fix instant rpm (#2886)

* fix instant rpm

* this is what it should look like!

* warning

* comment issue link

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2021-07-01 06:19:16 -07:00 committed by GitHub
parent 77f9c68733
commit 2cf2db8fb2
3 changed files with 17 additions and 18 deletions

View File

@ -278,12 +278,15 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
rpmState->setRpmValue(rpm > UNREALISTIC_RPM ? NOISY_RPM : rpm);
}
} else {
// we are here only once trigger is synchronized for the first time
// while transitioning from 'spinning' to 'running'
engine->triggerCentral.triggerState.movePreSynchTimestamps(PASS_ENGINE_PARAMETER_SIGNATURE);
}
rpmState->onNewEngineCycle();
}
#if EFI_SENSOR_CHART
// this 'index==0' case is here so that it happens after cycle callback so
// it goes into sniffer report into the first position
@ -294,13 +297,6 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
}
#endif /* EFI_SENSOR_CHART */
if (rpmState->isSpinningUp()) {
// we are here only once trigger is synchronized for the first time
// while transitioning from 'spinning' to 'running'
// Replace 'normal' RPM with instant RPM for the initial spin-up period
engine->triggerCentral.triggerState.movePreSynchTimestamps(PASS_ENGINE_PARAMETER_SIGNATURE);
}
// Always update instant RPM even when not spinning up
engine->triggerCentral.triggerState.updateInstantRpm(&engine->triggerCentral.triggerFormDetails, nowNt PASS_ENGINE_PARAMETER_SUFFIX);

View File

@ -44,6 +44,9 @@ TEST(cranking, realCrankingFromFile) {
while (reader.haveMore()) {
reader.processLine(&eth);
}
ASSERT_EQ( 0, eth.recentWarnings()->getCount())<< "warningCounter#realCranking";
ASSERT_EQ( 560, GET_RPM())<< reader.lineIndex;
// TODO: we should avoid this warning
// See https://github.com/rusefi/rusefi/issues/2889
ASSERT_EQ(1, eth.recentWarnings()->getCount())<< "warningCounter#realCranking";
ASSERT_EQ(560, GET_RPM())<< reader.lineIndex;
}

View File

@ -64,26 +64,26 @@ TEST(cranking, hardcodedRealCranking) {
/* 17 */ EVENT(/* timestamp*/1.30114225, T_PRIMARY, /*value*/true);
EXPECT_EQ(219, GET_RPM());
/* 18 */ EVENT(/* timestamp*/1.3341915, T_SECONDARY, /*value*/false);
EXPECT_EQ(88, GET_RPM());
EXPECT_EQ(228, GET_RPM());
/* 19 */ EVENT(/* timestamp*/1.383534, T_SECONDARY, /*value*/true);
EXPECT_EQ( 67, GET_RPM());
EXPECT_EQ( 248, GET_RPM());
// WHY DOES RPM GO SO LOW HERE?
// It doesn't look like it drops in the logic analyzer trace (hint: it doesn't, there's a bug)
// second synch
/* 22 */ EVENT(/* timestamp*/1.45352675, T_PRIMARY, /*value*/true);
EXPECT_EQ(33, GET_RPM());
EXPECT_EQ(224, GET_RPM());
/* 23 */ EVENT(/* timestamp*/1.46291525, T_SECONDARY, /*value*/false);
EXPECT_EQ(38, GET_RPM());
EXPECT_EQ(231, GET_RPM());
/* 25 */ EVENT(/* timestamp*/1.49939025, T_PRIMARY, /*value*/false);
EXPECT_EQ(54, GET_RPM());
EXPECT_EQ(239, GET_RPM());
/* 27 */ EVENT(/* timestamp*/1.511785, T_SECONDARY, /*value*/true);
EXPECT_EQ(57, GET_RPM());
EXPECT_EQ(234, GET_RPM());
/* 28 */ EVENT(/* timestamp*/1.5908545, T_SECONDARY, /*value*/false);
EXPECT_EQ(57, GET_RPM());
EXPECT_EQ(231, GET_RPM());
/* 31 */ EVENT(/* timestamp*/1.6399845, T_SECONDARY, /*value*/true);
EXPECT_EQ(35, GET_RPM());
EXPECT_EQ(234, GET_RPM());
/* 32 */ EVENT(/* timestamp*/1.70975875, T_PRIMARY, /*value*/true);
EXPECT_EQ(233, GET_RPM());
/* 33 */ EVENT(/* timestamp*/1.7194455, T_SECONDARY, /*value*/false);