From fa042fb6f533793c4b81637b324aba44358f7f58 Mon Sep 17 00:00:00 2001 From: rusefillc <48498823+rusefillc@users.noreply.github.com> Date: Sun, 19 Nov 2023 16:10:42 -0500 Subject: [PATCH] heater: shortcut if sensor is hot enough (#277) * heater: shortcut if sensor is hot enough * heater: shortcut if sensor is hot enougth --------- Co-authored-by: Andrey Gusakov --- firmware/boards/f1_dual_rev1/wideband_board_config.h | 4 ++++ firmware/heater_control.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/firmware/boards/f1_dual_rev1/wideband_board_config.h b/firmware/boards/f1_dual_rev1/wideband_board_config.h index 2e990f4..ec03eb6 100644 --- a/firmware/boards/f1_dual_rev1/wideband_board_config.h +++ b/firmware/boards/f1_dual_rev1/wideband_board_config.h @@ -13,6 +13,10 @@ #define ADC_MAX_COUNT (4095) #define ADC_OVERSAMPLE 16 +// Algo settings +// TODO: move to settings +#define HEATER_FAST_HEATING_THRESHOLD_T 550 + // ******************************* // Nernst voltage & ESR sense // ******************************* diff --git a/firmware/heater_control.cpp b/firmware/heater_control.cpp index a0b5244..306459d 100644 --- a/firmware/heater_control.cpp +++ b/firmware/heater_control.cpp @@ -71,6 +71,18 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA switch (currentState) { case HeaterState::Preheat: + #ifdef HEATER_FAST_HEATING_THRESHOLD_T + if (sensorTemp >= HEATER_FAST_HEATING_THRESHOLD_T) { + // if sensor is already hot - we can start from higher heater voltage + rampVoltage = 7.5; + + // Reset the timer for the warmup phase + m_warmupTimer.reset(); + + return HeaterState::WarmupRamp; + } + #endif + // If preheat timeout, or sensor is already hot (engine running?) if (m_preheatTimer.hasElapsedSec(m_preheatTimeSec) || sensorTemp > closedLoopTemp) {