heater_control: do not preheat on low voltages (#286)

Co-authored-by: Andrey Gusakov <dron0gus@gmail.com>
This commit is contained in:
rusefillc 2023-11-15 19:21:16 -06:00 committed by GitHub
parent 2469315a35
commit 982cd32ee7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -42,6 +42,7 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA
if (batteryVoltage < HEATER_BATTETY_OFF_VOLTAGE) if (batteryVoltage < HEATER_BATTETY_OFF_VOLTAGE)
{ {
batteryStabTime = batteryStabTimeCounter; batteryStabTime = batteryStabTimeCounter;
return HeaterState::NoHeaterSupply;
} }
// measured voltage is high enougth to auto-start heating, wait some time to stabilize // measured voltage is high enougth to auto-start heating, wait some time to stabilize
if ((batteryVoltage > HEATER_BATTERY_ON_VOLTAGE) && (batteryStabTime > 0)) 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 // TODO: heater PID should operate on temperature, not ESR
return 7.5f - heaterPid.GetOutput(m_targetEsr, sensorEsr); return 7.5f - heaterPid.GetOutput(m_targetEsr, sensorEsr);
case HeaterState::Stopped: case HeaterState::Stopped:
case HeaterState::NoHeaterSupply:
// Something has gone wrong, turn off the heater. // Something has gone wrong, turn off the heater.
return 0; return 0;
case HeaterState::NoHeaterSupply:
// No/too low heater supply - disable output
return 0;
} }
// should be unreachable // should be unreachable