Add an enable/disable switch for the temperature controller

New TempControllerBase.enabled (default False) forces y=0 in
process_pid() when off, same mechanism as the existing cooling
override - the controller tries not to drive the heater at all.

tasks/tempctrl.py: new 'Enable' recv command and 'Enabled' broadcast
on the TempCtrl channel. tasks/sud.py: SudTask now enables the
controller on any non-IDLE/DONE Sud state and disables it (forcing
power back to 0) on IDLE/DONE, so automatic mode owns it for the
duration of a run and hands back manual control once it stops/finishes.

gui: new "Enabled" checkbox on the Manual tab's Controller group,
synced from the server; the temp/heatrate setpoint controls are
disabled whenever the controller itself is disabled.
This commit is contained in:
2026-06-21 12:54:09 +02:00
parent e2222dae5e
commit 3fea29cc58
6 changed files with 78 additions and 9 deletions
+9 -1
View File
@@ -43,6 +43,11 @@ class TempControllerBase(APid):
# transition, force y to 0 as soon as the caller (SudTask) knows
# the step needs to passively cool down.
self.cooling = False
# Master on/off switch: while disabled, the controller tries not to
# drive the heater at all (output forced to 0) regardless of the
# FSM/setpoints - off by default, enabled either by the user
# (manual mode) or by SudTask for the duration of a run.
self.enabled = False
def on_state_entered(self, state):
pass
@@ -79,6 +84,9 @@ class TempControllerBase(APid):
def set_cooling(self, value):
self.cooling = value
def set_enabled(self, value):
self.enabled = value
def get_heatrate_soll(self):
return self.heatrate_soll
@@ -118,7 +126,7 @@ class TempControllerBase(APid):
self.pid_hold.process(theta_err, -self.theta_ist, hold_scale)
self.pid_rate.process(heatrate_err, -self.heatrate_ist)
if self.state == States.IDLE or self.cooling:
if self.state == States.IDLE or self.cooling or not self.enabled:
self.y = 0
else:
self.y = self.pid_rate.get_y()