From e51a2c36fe7d82dfdfb9bcccfcf3ead909bcd430 Mon Sep 17 00:00:00 2001 From: Federica Di Lauro Date: Tue, 17 Dec 2019 14:14:10 +0100 Subject: [PATCH] pid derviative term --- otto_controller_source/Core/Inc/pid.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; -- 2.52.0