Adds a configurable IIR pre-filter (beta, default 0.05, τ≈19 s at dt=1 s) applied to theta_ist before the derivative, so stirrer-induced temperature noise is attenuated before being amplified by differentiation rather than after. The shared filter/derivative/post-filter logic is factored into TempControllerBase._compute_heatrate(); both Normal and Smith subclasses call it, replacing their duplicated inline rate blocks. beta is read from TempCtrl.beta in the config (default 0.05 if absent) and added to config-sim.json.tpl and config-real.json.tpl. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
26 lines
879 B
Python
26 lines
879 B
Python
from components.pid.temp_controller_base import TempControllerBase
|
|
|
|
|
|
class TempController(TempControllerBase):
|
|
def __init__(self, dt):
|
|
TempControllerBase.__init__(self, dt)
|
|
# last_theta_ist / theta_ist_filtered / beta / dt all live in the base -
|
|
# see TempControllerBase.__init__ and _compute_heatrate().
|
|
|
|
def process(self):
|
|
self._require_params()
|
|
|
|
self.theta_ist = self.theta_ist_set
|
|
self._compute_heatrate(self.theta_ist)
|
|
|
|
# Compensate for max heat rate to reduce overshoot
|
|
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
|
|
heatrate_err = self.heatrate_soll - self.heatrate_ist
|
|
|
|
diff = self.theta_soll_set - self.theta_ist
|
|
self.process_fsm(diff)
|
|
self.process_pid(theta_err, heatrate_err, hold_scale)
|