From ec508d8f9de333802a699b0e9187115abc0f2c6a Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Mon, 28 Dec 2020 05:03:10 -0800 Subject: [PATCH] don't write settings if cal didn't work (#2154) Co-authored-by: Matthew Kennedy --- firmware/controllers/actuators/electronic_throttle.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 7b5028f5f6..e5c59b75b8 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -605,6 +605,13 @@ struct EtbImpl final : public EtbController { // Finally disable and reset state motor->disable(); + // Check that the calibrate actually moved the throttle + if (absF(primaryMax - primaryMin) < 0.5f) { + firmwareError(OBD_Throttle_Position_Sensor_Circuit_Malfunction, "Auto calibrate failed, check your wiring!\r\nClosed voltage: %.1fv Open voltage: %.1fv", primaryMin, primaryMax); + m_isAutocal = false; + return; + } + // Write out the learned values to TS, waiting briefly after setting each to let TS grab it tsOutputChannels.calibrationMode = functionToCalModePriMax(myFunction); tsOutputChannels.calibrationValue = primaryMax;