fix instant rpm clearing bug (#4629)

* improve instant rpm

* changelog
This commit is contained in:
Matthew Kennedy 2022-09-29 04:15:59 -07:00 committed by GitHub
parent e6b8b08853
commit f2c8a0192c
5 changed files with 24 additions and 9 deletions

View File

@ -29,6 +29,9 @@ Release template (copy/paste this for new release):
### Added ### Added
- Flexible ignition adder/trim tables #4586 - Flexible ignition adder/trim tables #4586
### Fixed
- Slower than expected RPM information was slowing engine start #4629
## September 2022 Release - "Day 203" ## September 2022 Release - "Day 203"
### Added ### Added

View File

@ -209,11 +209,9 @@ uint32_t RpmCalculator::getRevolutionCounterM(void) const {
} }
void RpmCalculator::onSlowCallback() { void RpmCalculator::onSlowCallback() {
/** // Stop the engine if it's been too long since we got a trigger event
* Update engine RPM state if needed (check timeouts). if (!engine->triggerCentral.engineMovedRecently(getTimeNowNt())) {
*/ setStopSpinning();
if (!checkIfSpinning(getTimeNowNt())) {
engine->rpmCalculator.setStopSpinning();
} }
} }

View File

@ -294,5 +294,3 @@ void findTriggerPosition(
void setToothedWheelConfiguration(TriggerWaveform *s, int total, int skipped, operation_mode_e operationMode); void setToothedWheelConfiguration(TriggerWaveform *s, int total, int skipped, operation_mode_e operationMode);
#define TRIGGER_WAVEFORM(x) getTriggerCentral()->triggerShape.x #define TRIGGER_WAVEFORM(x) getTriggerCentral()->triggerShape.x
#define getTriggerSize() TRIGGER_WAVEFORM(wave.phaseCount)

View File

@ -280,6 +280,8 @@ float PrimaryTriggerDecoder::calculateInstantRpm(
// now let's get precise angle for that event // now let's get precise angle for that event
angle_t prevIndexAngle = triggerFormDetails->eventAngles[prevIndex]; angle_t prevIndexAngle = triggerFormDetails->eventAngles[prevIndex];
efitick_t time90ago = timeOfLastEvent[prevIndex]; efitick_t time90ago = timeOfLastEvent[prevIndex];
// No previous timestamp, instant RPM isn't ready yet
if (time90ago == 0) { if (time90ago == 0) {
return prevInstantRpmValue; return prevInstantRpmValue;
} }
@ -293,9 +295,10 @@ float PrimaryTriggerDecoder::calculateInstantRpm(
// Wrap the angle in to the correct range (ie, could be -630 when we want +90) // Wrap the angle in to the correct range (ie, could be -630 when we want +90)
fixAngle(angleDiff, "angleDiff", CUSTOM_ERR_6561); fixAngle(angleDiff, "angleDiff", CUSTOM_ERR_6561);
// just for safety // just for safety, avoid divide-by-0
if (time == 0) if (time == 0) {
return prevInstantRpmValue; return prevInstantRpmValue;
}
float instantRpm = (60000000.0 / 360 * US_TO_NT_MULTIPLIER) * angleDiff / time; float instantRpm = (60000000.0 / 360 * US_TO_NT_MULTIPLIER) * angleDiff / time;
assertIsInBoundsWithResult(current_index, instantRpmValue, "instantRpmValue", 0); assertIsInBoundsWithResult(current_index, instantRpmValue, "instantRpmValue", 0);

View File

@ -12,10 +12,23 @@ TEST(crankingGm24x, gmRealCrankingFromFile) {
eth.setTriggerType(TT_GM_24x); eth.setTriggerType(TT_GM_24x);
int eventCount = 0;
bool gotRpm = false;
while (reader.haveMore()) { while (reader.haveMore()) {
reader.processLine(&eth); reader.processLine(&eth);
eventCount++;
engine->rpmCalculator.onSlowCallback(); engine->rpmCalculator.onSlowCallback();
auto rpm = Sensor::getOrZero(SensorType::Rpm);
if (!gotRpm && rpm) {
gotRpm = true;
// We should get first RPM on exactly the first sync point - this means the instant RPM pre-sync event copy all worked OK
EXPECT_EQ(eventCount, 23);
EXPECT_NEAR(rpm, 77.0f, 0.1);
}
} }
ASSERT_EQ( 0, eth.recentWarnings()->getCount())<< "warningCounter#vwRealCranking"; ASSERT_EQ( 0, eth.recentWarnings()->getCount())<< "warningCounter#vwRealCranking";