Replace Pid.scale()'s mutable gain factor with a stateless process() arg
Pid.scale(k) set self.k as persistent state, mutated from outside the class and never reset in reset(), so a stale scale factor could survive a state-transition reset. Replace it with a plain scale=1.0 argument on Pid.process(), and have temp_controller.py/temp_controller_smith.py compute the heat-rate-overshoot compensation factor themselves and pass it through process_pid() each tick instead of mutating pid_hold's state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -50,8 +50,7 @@ class TempController(TempControllerBase):
|
||||
self.last_theta_ist = self.theta_ist
|
||||
|
||||
# Compensate for max heat rate to reduce overshoot
|
||||
if self.heatrate_soll_set > 0:
|
||||
self.pid_hold.scale(1.0/self.heatrate_soll_set)
|
||||
hold_scale = 1.0/self.heatrate_soll_set if self.heatrate_soll_set > 0 else 1.0
|
||||
|
||||
self.heatrate_soll = self.heatrate_soll_set * self.pid_hold.get_y()
|
||||
theta_err = self.theta_soll_set - self.theta_ist
|
||||
@@ -59,4 +58,4 @@ class TempController(TempControllerBase):
|
||||
|
||||
diff = self.theta_soll_set - self.theta_ist
|
||||
self.process_fsm(diff)
|
||||
self.process_pid(theta_err, heatrate_err)
|
||||
self.process_pid(theta_err, heatrate_err, hold_scale)
|
||||
|
||||
Reference in New Issue
Block a user