From 982cd32ee7e7f8af36e03a411f21530db4e52ee9 Mon Sep 17 00:00:00 2001 From: rusefillc <48498823+rusefillc@users.noreply.github.com> Date: Wed, 15 Nov 2023 19:21:16 -0600 Subject: [PATCH] heater_control: do not preheat on low voltages (#286) Co-authored-by: Andrey Gusakov --- firmware/heater_control.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/firmware/heater_control.cpp b/firmware/heater_control.cpp index 61cadcc..eec4523 100644 --- a/firmware/heater_control.cpp +++ b/firmware/heater_control.cpp @@ -42,6 +42,7 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA if (batteryVoltage < HEATER_BATTETY_OFF_VOLTAGE) { batteryStabTime = batteryStabTimeCounter; + return HeaterState::NoHeaterSupply; } // measured voltage is high enougth to auto-start heating, wait some time to stabilize if ((batteryVoltage > HEATER_BATTERY_ON_VOLTAGE) && (batteryStabTime > 0)) @@ -143,9 +144,11 @@ float HeaterControllerBase::GetVoltageForState(HeaterState state, float sensorEs // TODO: heater PID should operate on temperature, not ESR return 7.5f - heaterPid.GetOutput(m_targetEsr, sensorEsr); case HeaterState::Stopped: - case HeaterState::NoHeaterSupply: // Something has gone wrong, turn off the heater. return 0; + case HeaterState::NoHeaterSupply: + // No/too low heater supply - disable output + return 0; } // should be unreachable