Rename TempControllerBase.pid_rate to pid_heat, matching pid_hold/pid_cool naming
This commit is contained in:
@@ -23,7 +23,7 @@ class TempControllerBase(APid):
|
|||||||
def __init__(self, dt, params):
|
def __init__(self, dt, params):
|
||||||
APid.__init__(self)
|
APid.__init__(self)
|
||||||
self.pid_hold = Pid(dt)
|
self.pid_hold = Pid(dt)
|
||||||
self.pid_rate = Pid(dt)
|
self.pid_heat = Pid(dt)
|
||||||
# Separate gains for ramping down (negative diff) - the actuator
|
# Separate gains for ramping down (negative diff) - the actuator
|
||||||
# (e.g. a heat-only Pot/heater) is responsible for clamping the
|
# (e.g. a heat-only Pot/heater) is responsible for clamping the
|
||||||
# resulting negative power to whatever it's actually capable of;
|
# resulting negative power to whatever it's actually capable of;
|
||||||
@@ -42,7 +42,7 @@ class TempControllerBase(APid):
|
|||||||
self.y = -1
|
self.y = -1
|
||||||
self.state = States.INIT
|
self.state = States.INIT
|
||||||
self.pid_hold.set_params(params['Hold'])
|
self.pid_hold.set_params(params['Hold'])
|
||||||
self.pid_rate.set_params(params['Heat'])
|
self.pid_heat.set_params(params['Heat'])
|
||||||
self.pid_cool.set_params(params['Cool'])
|
self.pid_cool.set_params(params['Cool'])
|
||||||
self.is_startup = True
|
self.is_startup = True
|
||||||
# Master on/off switch: while disabled, the FSM is held in IDLE and
|
# Master on/off switch: while disabled, the FSM is held in IDLE and
|
||||||
@@ -105,16 +105,16 @@ class TempControllerBase(APid):
|
|||||||
elif self.state == States.IDLE:
|
elif self.state == States.IDLE:
|
||||||
# Just (re-)enabled - land in HOLD; the very next tick's
|
# Just (re-)enabled - land in HOLD; the very next tick's
|
||||||
# threshold check (below) moves it on to HEAT/COOL if the gap
|
# threshold check (below) moves it on to HEAT/COOL if the gap
|
||||||
# actually warrants it. pid_rate was frozen (see process_pid())
|
# actually warrants it. pid_heat was frozen (see process_pid())
|
||||||
# and possibly stale for as long as we were disabled - start it
|
# and possibly stale for as long as we were disabled - start it
|
||||||
# clean rather than resuming wherever it last left off.
|
# clean rather than resuming wherever it last left off.
|
||||||
state_next = States.HOLD
|
state_next = States.HOLD
|
||||||
self.pid_hold.reset()
|
self.pid_hold.reset()
|
||||||
self.pid_rate.reset()
|
self.pid_heat.reset()
|
||||||
elif self.state == States.HOLD:
|
elif self.state == States.HOLD:
|
||||||
if diff >= self.thresholds['HoldHeat']:
|
if diff >= self.thresholds['HoldHeat']:
|
||||||
state_next = States.HEAT
|
state_next = States.HEAT
|
||||||
self.pid_rate.reset()
|
self.pid_heat.reset()
|
||||||
elif diff <= -self.thresholds['HoldCool']:
|
elif diff <= -self.thresholds['HoldCool']:
|
||||||
state_next = States.COOL
|
state_next = States.COOL
|
||||||
self.pid_cool.reset()
|
self.pid_cool.reset()
|
||||||
@@ -128,15 +128,15 @@ class TempControllerBase(APid):
|
|||||||
elif self.state == States.COOL:
|
elif self.state == States.COOL:
|
||||||
if diff >= self.thresholds['CoolHeat']:
|
if diff >= self.thresholds['CoolHeat']:
|
||||||
state_next = States.HEAT
|
state_next = States.HEAT
|
||||||
self.pid_rate.reset()
|
self.pid_heat.reset()
|
||||||
elif diff >= -self.thresholds['CoolHold']:
|
elif diff >= -self.thresholds['CoolHold']:
|
||||||
state_next = States.HOLD
|
state_next = States.HOLD
|
||||||
self.pid_hold.reset()
|
self.pid_hold.reset()
|
||||||
# pid_rate was frozen during COOL (see process_pid()) -
|
# pid_heat was frozen during COOL (see process_pid()) -
|
||||||
# resume it clean rather than from whatever it last held
|
# resume it clean rather than from whatever it last held
|
||||||
# before COOL took over, which by now may be a stale fit
|
# before COOL took over, which by now may be a stale fit
|
||||||
# for a completely different part of the curve.
|
# for a completely different part of the curve.
|
||||||
self.pid_rate.reset()
|
self.pid_heat.reset()
|
||||||
|
|
||||||
if state_next != self.state:
|
if state_next != self.state:
|
||||||
self.state = state_next
|
self.state = state_next
|
||||||
@@ -146,7 +146,7 @@ class TempControllerBase(APid):
|
|||||||
self.pid_hold.process(theta_err, -self.theta_ist, hold_scale)
|
self.pid_hold.process(theta_err, -self.theta_ist, hold_scale)
|
||||||
|
|
||||||
# Only the PID actually driving y is advanced - otherwise the
|
# Only the PID actually driving y is advanced - otherwise the
|
||||||
# inactive one (e.g. pid_rate while COOL has pid_cool driving)
|
# inactive one (e.g. pid_heat while COOL has pid_cool driving)
|
||||||
# would keep silently integrating against a heatrate_err that
|
# would keep silently integrating against a heatrate_err that
|
||||||
# isn't actually under its control, building a stale windup that
|
# isn't actually under its control, building a stale windup that
|
||||||
# causes a discontinuity in y the moment it takes back over.
|
# causes a discontinuity in y the moment it takes back over.
|
||||||
@@ -156,8 +156,8 @@ class TempControllerBase(APid):
|
|||||||
self.pid_cool.process(heatrate_err, -self.heatrate_ist)
|
self.pid_cool.process(heatrate_err, -self.heatrate_ist)
|
||||||
self.y = self.pid_cool.get_y()
|
self.y = self.pid_cool.get_y()
|
||||||
else:
|
else:
|
||||||
self.pid_rate.process(heatrate_err, -self.heatrate_ist)
|
self.pid_heat.process(heatrate_err, -self.heatrate_ist)
|
||||||
self.y = self.pid_rate.get_y()
|
self.y = self.pid_heat.get_y()
|
||||||
|
|
||||||
self.post_pid()
|
self.post_pid()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user