From 5eb5a1d895695f7821868b34732d0d6eca2fdb23 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Tue, 15 Oct 2013 00:53:11 +0000 Subject: various bugfixes and improvements + documentation git-svn-id: https://svn.spreadspace.org/avr/trunk@245 aa12f405-d877-488e-9caf-2d797e2a1cc7 --- pcr-controller/pid_control.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pcr-controller/pid_control.c') diff --git a/pcr-controller/pid_control.c b/pcr-controller/pid_control.c index f1d7d3f..95d190e 100644 --- a/pcr-controller/pid_control.c +++ b/pcr-controller/pid_control.c @@ -85,12 +85,12 @@ int16_t pid_calc(int16_t current_value) if (pid_target_value_ == PID_DISABLED) return PID_DISABLED; - int32_t error = pid_target_value_ - current_value; + int32_t error = (int32_t) pid_target_value_ - (int32_t) current_value; // derivative // instead of derivative of error we take derivative on measurement // since dError/dt = - dInput/dt (note the - ) - int32_t d_measure = current_value - pid_last_input_; - pid_last_input_ = current_value; + int32_t d_measure = (int32_t) current_value - pid_last_input_; + pid_last_input_ = (int32_t) current_value; // integral (bring pid_i_ into integral, so we get smooth transfer if pid_i_ suddenly changes) pid_i_integralsum_ += pid_i_ * error; -- cgit v1.2.3