heater PID works

This commit is contained in:
Matthew Kennedy 2020-10-31 17:34:36 -07:00
parent 0e350c9f66
commit 0b7f591671
1 changed files with 3 additions and 2 deletions

View File

@ -50,7 +50,7 @@ static HeaterState GetNextState(HeaterState state, float sensorEsr)
return state; 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) static float GetDutyForState(HeaterState state, float heaterEsr)
{ {
@ -66,7 +66,8 @@ static float GetDutyForState(HeaterState state, float heaterEsr)
return rampDuty; return rampDuty;
case HeaterState::ClosedLoop: case HeaterState::ClosedLoop:
return heaterPid.GetOutput(HEATER_TARGET_ESR, heaterEsr); // Negated because lower resistance -> hotter
return heaterPid.GetOutput(-HEATER_TARGET_ESR, -heaterEsr);
} }
} }