diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 5b8507777b..e5ecaf8ab5 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -501,6 +501,7 @@ expected EtbController::getClosedLoop(percent_t target, percent_t obs } if (m_isAutotune) { + etbInputErrorCounter = 0; return getClosedLoopAutotune(target, observation); } else { // Check that we're not over the error limit @@ -517,7 +518,12 @@ expected EtbController::getClosedLoop(percent_t target, percent_t obs etbDutyRateOfChange = m_dutyIntegrator.accumulate(prevOutput - output); prevOutput = output; + static bool wasInputError = false; // 'static' meaning it's a global variable just with limited visibility bool isInputError = !Sensor::get(SensorType::Tps1).Valid || isTps2Error() || isPedalError(); + if (Sensor::getOrZero(SensorType::Rpm) == 0 && wasInputError != isInputError) { + wasInputError = isInputError; + etbInputErrorCounter++; + } return output; } }