1
0
forked from M-Labs/kirdy

pid: rm setpoint change kick

- See Thermostat Firmware PR#107
This commit is contained in:
linuswck 2024-05-10 11:34:46 +08:00
parent e8aaf5f66b
commit 266110ba14

View File

@ -96,7 +96,6 @@ impl PidState {
// + x0 * (kp + ki + kd) // + x0 * (kp + ki + kd)
// - x1 * (kp + 2kd) // - x1 * (kp + 2kd)
// + x2 * kd // + x2 * kd
// + kp * (u0 - u1)
// y0 = clip(y0', ymin, ymax) // y0 = clip(y0', ymin, ymax)
pub fn update_pid(&mut self) -> Option<f64> { pub fn update_pid(&mut self) -> Option<f64> {
let input = self.get_temperature()?.get::<degree_celsius>(); let input = self.get_temperature()?.get::<degree_celsius>();
@ -107,8 +106,7 @@ impl PidState {
self.controller.parameters.kp + self.controller.parameters.ki + self.controller.parameters.kd, 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.x1 * f64::from(self.controller.parameters.kp + 2.0 * self.controller.parameters.kd)
+ self.controller.x2 * f64::from(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);
if output < self.controller.parameters.output_min.into() { if output < self.controller.parameters.output_min.into() {
output = self.controller.parameters.output_min.into(); output = self.controller.parameters.output_min.into();
} }