From 0b7f591671ad9d03ff28e8e1b93f300b35c745dc Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sat, 31 Oct 2020 17:34:36 -0700 Subject: [PATCH] heater PID works --- firmware/heater_control.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/firmware/heater_control.cpp b/firmware/heater_control.cpp index 85eabb6..e8e07de 100644 --- a/firmware/heater_control.cpp +++ b/firmware/heater_control.cpp @@ -50,7 +50,7 @@ static HeaterState GetNextState(HeaterState state, float sensorEsr) return state; } -static Pid heaterPid(0.1f, 0, HEATER_CONTROL_PERIOD); +static Pid heaterPid(0.1f, 0.1f, HEATER_CONTROL_PERIOD); static float GetDutyForState(HeaterState state, float heaterEsr) { @@ -66,7 +66,8 @@ static float GetDutyForState(HeaterState state, float heaterEsr) return rampDuty; case HeaterState::ClosedLoop: - return heaterPid.GetOutput(HEATER_TARGET_ESR, heaterEsr); + // Negated because lower resistance -> hotter + return heaterPid.GetOutput(-HEATER_TARGET_ESR, -heaterEsr); } }