fix: split inner-loop yi_max clamp to fix HOLD-state windup overshoot
Renames pid_hold/pid_heat/pid_cool to pid_outer/pid_inner/pid_inner_cool
to match what actually runs when, and splits inner-loop config into
Inner.Heat/Inner.Hold/Inner.Cool so the same PID instance gets a tight
yi_max ceiling only while HOLD drives it, without capping legitimate
1.5 K/min ramps. Fixes the overshoot from docs/overshoot_hold_windup.md
where a cold-water disturbance during HOLD wound up pid_heat's integral
term with no anti-windup engagement, taking ~35s+ to unwind naturally.
Breaking config change: Hold/Heat/Cool -> Outer/Inner.{Heat,Hold,Cool}
in config.json, both .tpl templates, the pid/sud demo scripts, and
replay_sim.py's CLI flags. Adds tests/components/pid/ (stdlib unittest)
covering the Pid clamp/recovery behavior and closed-loop disturbance,
ramp, and HOLD<->HEAT transition cases.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DGQhVQ2Y3yXAQTXhrxVd5u
This commit is contained in:
@@ -35,6 +35,9 @@ class Pid:
|
||||
kt = self.params['kt'] * scale
|
||||
|
||||
self.yi = self.yi + ki*dt * err + kt*dt * self.awu
|
||||
yi_max = self.params.get('yi_max')
|
||||
if yi_max is not None:
|
||||
self.yi = max(-yi_max, min(yi_max, self.yi))
|
||||
yd = kd/dt*(d - self.d)
|
||||
yp = kp * err
|
||||
|
||||
|
||||
Reference in New Issue
Block a user