From d3f90f205495a9710cd6c8de0eba3f4b5a0fb130 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Fri, 9 Jul 2021 23:15:24 -0700 Subject: [PATCH] heater fiddling --- firmware/heater_control.cpp | 29 ++++++++++++++++++++++++----- firmware/wideband_config.h | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/firmware/heater_control.cpp b/firmware/heater_control.cpp index 562db4c..7391e64 100644 --- a/firmware/heater_control.cpp +++ b/firmware/heater_control.cpp @@ -34,8 +34,8 @@ static HeaterState GetNextState(HeaterState state, float sensorEsr) if (timeCounter <= 0 || sensorEsr < HEATER_CLOSED_LOOP_THRESHOLD_ESR) { // If enough time has elapsed, start the ramp - // Start the ramp at 50% duty - ~6-7 volts - rampDuty = 0.5f; + // Start the ramp at 30% duty - ~3-4 volts + rampDuty = 0.3f; // Next phase times out at 15 seconds timeCounter = HEATER_WARMUP_TIMEOUT / HEATER_CONTROL_PERIOD; @@ -78,7 +78,21 @@ static HeaterState GetNextState(HeaterState state, float sensorEsr) return state; } -static Pid heaterPid(0.003f, 0.005f, 0.0005f, 0.6f, HEATER_CONTROL_PERIOD); +// oscillates at 0.04 kP + +//static Pid heaterPid(0.04f,0, 0, 0.6f, HEATER_CONTROL_PERIOD); + +// "no overshoot" PID +//static Pid heaterPid(0.008f, 0.0288f, 0.0015f, 0.6f, HEATER_CONTROL_PERIOD); + +// PI +//static Pid heaterPid(0.02f, 0.0576f, 0.0015f, 0.6f, HEATER_CONTROL_PERIOD); + +// rusefi ETB autotune +//static Pid heaterPid(0.014f, 0.018f, 0.0018f, 0.6f, HEATER_CONTROL_PERIOD); + +// rusefi ETB autotune with more PD +static Pid heaterPid(0.02f, 0.018f, 0.003f, 0.6f, HEATER_CONTROL_PERIOD); static float GetDutyForState(HeaterState state, float heaterEsr) { @@ -88,8 +102,8 @@ static float GetDutyForState(HeaterState state, float heaterEsr) case HeaterState::WarmupRamp: if (rampDuty < 0.75f) { - // 0.4 volt per second, divided by battery voltage and update rate - constexpr float rampRateVoltPerSecond = 0.4f; + // 0.3 volt per second, divided by battery voltage and update rate + constexpr float rampRateVoltPerSecond = 0.3f; constexpr float heaterFrequency = 1000.0f / HEATER_CONTROL_PERIOD; rampDuty += ((rampRateVoltPerSecond / 14) / heaterFrequency); } @@ -125,6 +139,11 @@ static void HeaterThread(void*) state = GetNextState(state, heaterEsr); float duty = GetDutyForState(state, heaterEsr); + // Limit to 80% duty + if (duty > 0.8) { + duty = 0.8; + } + // Pipe the output to the heater driver heaterPwm.SetDuty(duty); diff --git a/firmware/wideband_config.h b/firmware/wideband_config.h index 5aa58cf..3f556cb 100644 --- a/firmware/wideband_config.h +++ b/firmware/wideband_config.h @@ -46,5 +46,5 @@ #define HEATER_CLOSED_LOOP_THRESHOLD_ESR 2000 #define HEATER_TARGET_ESR 300 -#define HEATER_OVERHEAT_ESR 200 +#define HEATER_OVERHEAT_ESR 150 #define HEATER_UNDERHEAT_ESR 3000