From 266110ba14e29f5fba49479bdb304cde1befdc3f Mon Sep 17 00:00:00 2001 From: linuswck Date: Fri, 10 May 2024 11:34:46 +0800 Subject: [PATCH] pid: rm setpoint change kick - See Thermostat Firmware PR#107 --- src/thermostat/pid_state.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/thermostat/pid_state.rs b/src/thermostat/pid_state.rs index 5319b3c..99c41a0 100644 --- a/src/thermostat/pid_state.rs +++ b/src/thermostat/pid_state.rs @@ -96,7 +96,6 @@ impl PidState { // + x0 * (kp + ki + kd) // - x1 * (kp + 2kd) // + x2 * kd - // + kp * (u0 - u1) // y0 = clip(y0', ymin, ymax) pub fn update_pid(&mut self) -> Option { let input = self.get_temperature()?.get::(); @@ -107,8 +106,7 @@ impl PidState { self.controller.parameters.kp + self.controller.parameters.ki + self.controller.parameters.kd, ) - self.controller.x1 * f64::from(self.controller.parameters.kp + 2.0 * self.controller.parameters.kd) - + self.controller.x2 * f64::from(self.controller.parameters.kd) - + f64::from(self.controller.parameters.kp) * (setpoint as f64 - self.controller.u1); + + self.controller.x2 * f64::from(self.controller.parameters.kd); if output < self.controller.parameters.output_min.into() { output = self.controller.parameters.output_min.into(); }