]> git.leonardobizzoni.com Git - pioneer-stm32/commitdiff
pid derviative term
authorFederica Di Lauro <federicadilauro1998@gmail.com>
Tue, 17 Dec 2019 13:14:10 +0000 (14:14 +0100)
committerFederica Di Lauro <federicadilauro1998@gmail.com>
Tue, 17 Dec 2019 13:14:10 +0000 (14:14 +0100)
otto_controller_source/Core/Inc/pid.h

index 2a434541ed894af338686a65e8d42e33d9a3a68b..39649d640f46c8a7f90a0691cf41313c22d3f44a 100644 (file)
@@ -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;