From: Federica Di Lauro Date: Tue, 17 Dec 2019 13:14:10 +0000 (+0100) Subject: pid derviative term X-Git-Url: http://git.leonardobizzoni.com/?a=commitdiff_plain;h=e51a2c36fe7d82dfdfb9bcccfcf3ead909bcd430;p=pioneer-stm32 pid derviative term --- diff --git a/otto_controller_source/Core/Inc/pid.h b/otto_controller_source/Core/Inc/pid.h index 2a43454..39649d6 100644 --- a/otto_controller_source/Core/Inc/pid.h +++ b/otto_controller_source/Core/Inc/pid.h @@ -50,7 +50,6 @@ class Pid { float output = this->error_ * this->kp_; //integral term - if (this->error_sum_index_ == 10) { this->error_sum_array_[0] = this->error_; this->error_sum_index_ = 0; @@ -67,7 +66,9 @@ class Pid { output += error_sum * this->ki_; - //TODO derivative term + //derivative term + output += (this->error_ - this->previous_error_); + this->previous_error_ = this->error_; int integer_output = (int) output;