From 34543c8660a518033a923cafd4f86bf6172530a0 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 18 Sep 2020 00:24:00 +0200 Subject: [PATCH] pid: only reset after target change --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index d3e7de6..60b058b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -361,8 +361,11 @@ fn main() -> ! { let pid = &mut channels.channel_state(channel).pid; use command_parser::PidParameter::*; match parameter { - Target => - pid.target = value, + Target => { + pid.target = value; + // reset pid.integral + pid.reset(); + } KP => pid.parameters.kp = value, KI => @@ -378,9 +381,6 @@ fn main() -> ! { IntegralMax => pid.parameters.integral_max = value, } - // TODO: really reset PID state - // after each parameter change? - pid.reset(); let _ = writeln!(socket, "PID parameter updated"); } Command::SteinhartHart { channel, parameter, value } => {