fix #1740 the right way (#1741)

* fix

* put that back
This commit is contained in:
Matthew Kennedy 2020-08-31 18:05:04 -07:00 committed by GitHub
parent ec3ec9f40b
commit 5fc1b6902c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View File

@ -193,14 +193,11 @@ void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
slowCallBackWasInvoked = true;
#if HW_CHECK_MODE
// we need to skip some of the first measurments to have BiQuad filter happy
if (getSlowAdcCounter() > 1000) {
efiAssertVoid(OBD_PCM_Processor_Fault, CONFIG(clt).adcChannel != EFI_ADC_NONE, "No CLT setting");
assertCloseTo("clt", Sensor::get(SensorType::Clt).Value, 49.3);
assertCloseTo("iat", Sensor::get(SensorType::Iat).Value, 73.2);
assertCloseTo("aut1", Sensor::get(SensorType::AuxTemp1).Value, 13.8);
assertCloseTo("aut2", Sensor::get(SensorType::AuxTemp2).Value, 6.2);
}
efiAssertVoid(OBD_PCM_Processor_Fault, CONFIG(clt).adcChannel != EFI_ADC_NONE, "No CLT setting");
assertCloseTo("clt", Sensor::get(SensorType::Clt).Value, 49.3);
assertCloseTo("iat", Sensor::get(SensorType::Iat).Value, 73.2);
assertCloseTo("aut1", Sensor::get(SensorType::AuxTemp1).Value, 13.8);
assertCloseTo("aut2", Sensor::get(SensorType::AuxTemp2).Value, 6.2);
#endif // HW_CHECK_MODE
}

View File

@ -25,6 +25,7 @@ struct AdcSubscriptionEntry {
float VoltsPerAdcVolt;
adc_channel_e Channel;
Biquad Filter;
bool HasUpdated = false;
};
static size_t s_nextEntry = 0;
@ -68,6 +69,14 @@ void AdcSubscription::UpdateSubscribers(efitick_t nowNt) {
float mcuVolts = getVoltage("sensor", entry.Channel);
float sensorVolts = mcuVolts * entry.VoltsPerAdcVolt;
// On the very first update, preload the filter as if we've been
// seeing this value for a long time. This prevents a slow ramp-up
// towards the correct value just after startup
if (!entry.HasUpdated) {
entry.Filter.cookSteadyState(sensorVolts);
entry.HasUpdated = true;
}
float filtered = entry.Filter.filter(sensorVolts);
entry.Sensor->postRawValue(filtered, nowNt);