diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index be3a38a7b1..3f39a28e89 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -524,14 +524,6 @@ expected EtbController::getClosedLoop(percent_t target, percent_t obs etbDutyRateOfChange = m_dutyRocAverage.average(output - prevOutput); prevOutput = output; - // seems good enough to simply check for both TPS sensors - bool isInputError = isTps1Error() || isTps2Error() || isPedalError(); - // current basic implementation is to check for input error counter only while engine is not running - // we can make this logic smarter one day later - if (Sensor::getOrZero(SensorType::Rpm) == 0 && wasInputError != isInputError) { - wasInputError = isInputError; - etbInputErrorCounter++; - } return output; } } @@ -597,6 +589,22 @@ void EtbController::update() { && engine->etbAutoTune && m_function == ETB_Throttle1; + if (!m_isAutotune) { + // note that ClosedLoopController has it's own setpoint error validation so ours with the counter has to be here + // seems good enough to simply check for both TPS sensors + int errorState = (isTps1Error() ? 1 : 0) + (isTps2Error() ? 2 : 0) + + (isPedalError() ? 4 : 0); + + // current basic implementation is to check for input error counter only while engine is not running + // we can make this logic smarter one day later + if (Sensor::getOrZero(SensorType::Rpm) == 0 + && prevErrorState != errorState) { + prevErrorState = errorState; + etbInputErrorCounter++; + } + } + + ClosedLoopController::update(); }