From 1bf3929b6020a2c5f62dbab7477bda7932252467 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Thu, 18 Jun 2026 21:06:35 +0200 Subject: [PATCH] Drop model_params from base, enable Smith predictor delay correction TempControllerBase no longer threads model_params through (only the Smith subclass needs it, for its own Pot model and Kalman filters). Enable the Smith predictor's actual delay-compensated error term (theta_err now uses theta_ist_plant - theta_ist_model_delay + theta_ist_model instead of the plain plant reading), which is the correction this controller is named for. Co-Authored-By: Claude Sonnet 4.6 --- components/pid/temp_controller.py | 4 ++-- components/pid/temp_controller_base.py | 3 +-- components/pid/temp_controller_smith.py | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/components/pid/temp_controller.py b/components/pid/temp_controller.py index ac769cb..f7146e4 100644 --- a/components/pid/temp_controller.py +++ b/components/pid/temp_controller.py @@ -7,8 +7,8 @@ import numpy as np class TempController(TempControllerBase): - def __init__(self, dt, params, model_params=None): - TempControllerBase.__init__(self, dt, params, model_params) + def __init__(self, dt, params): + TempControllerBase.__init__(self, dt, params) self.kalman = Kalman(dt, params['Kalman']) def init_kalman(self, value): diff --git a/components/pid/temp_controller_base.py b/components/pid/temp_controller_base.py index 828c6e8..c81cae4 100644 --- a/components/pid/temp_controller_base.py +++ b/components/pid/temp_controller_base.py @@ -5,7 +5,7 @@ from components.pid.tc_constants import States, THRESH_HOLD_IDLE, THRESH_HOLD_HE class TempControllerBase(APid): - def __init__(self, dt, params, model_params=None): + def __init__(self, dt, params): APid.__init__(self) self.pid_hold = Pid(dt) self.pid_rate = Pid(dt) @@ -17,7 +17,6 @@ class TempControllerBase(APid): self.theta_ist = 0 self.heatrate_ist = 0 self.params = params - self.model_params = model_params self.y = -1 self.state = States.INIT self.use_kalman = True diff --git a/components/pid/temp_controller_smith.py b/components/pid/temp_controller_smith.py index b2943fd..e1dbe19 100755 --- a/components/pid/temp_controller_smith.py +++ b/components/pid/temp_controller_smith.py @@ -8,7 +8,7 @@ import numpy as np class TempController(TempControllerBase): def __init__(self, dt, params, model_params): - TempControllerBase.__init__(self, dt, params, model_params) + TempControllerBase.__init__(self, dt, params) self.kalman_model = Kalman(dt, params['Kalman']) self.kalman_model_delay = Kalman(dt, params['Kalman']) self.kalman_plant = Kalman(dt, params['Kalman']) @@ -72,7 +72,7 @@ class TempController(TempControllerBase): self.heatrate_soll = self.heatrate_soll_set * self.pid_hold.get_y() - if 0: + if 1: theta_err = self.theta_soll_set - (theta_ist_plant - theta_ist_model_delay + theta_ist_model) else: theta_err = self.theta_soll_set - theta_ist_plant