diff options
author | Bernhard Tittelbach <xro@realraum.at> | 2013-10-15 00:53:11 +0000 |
---|---|---|
committer | Bernhard Tittelbach <xro@realraum.at> | 2013-10-15 00:53:11 +0000 |
commit | 5eb5a1d895695f7821868b34732d0d6eca2fdb23 (patch) | |
tree | 8ffdbf16bbd76b5f91d846669ec72cd3d0c510d1 /pcr-controller/pid_control.c | |
parent | json output experiment, etc (diff) |
various bugfixes and improvements + documentation
git-svn-id: https://svn.spreadspace.org/avr/trunk@245 aa12f405-d877-488e-9caf-2d797e2a1cc7
Diffstat (limited to 'pcr-controller/pid_control.c')
-rw-r--r-- | pcr-controller/pid_control.c | 6 |
1 files changed, 3 insertions, 3 deletions
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; |