Yeongsoo Kim / Mbed 2 deprecated Mecha_Speed_control

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
yeongsookim
Date:
Tue Nov 10 14:47:43 2020 +0000
Parent:
4:050d1efdee90
Commit message:
test

Changed in this revision

Controller/SpeedController.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Controller/SpeedController.cpp	Tue Nov 10 14:47:01 2020 +0000
+++ b/Controller/SpeedController.cpp	Tue Nov 10 14:47:43 2020 +0000
@@ -1,5 +1,6 @@
 #include "SpeedController.h"
 
+
 PIDController::PIDController(float kp, float ki, float kd, float max_windup,
                              float start_time, float umin, float umax)
 {
@@ -30,14 +31,14 @@
     // Fill in the blank
     
     float delta_time = timestamp - m_last_timestamp;
-    float error = /* fill in the blank */;
+    float error = m_set_point - measured_value;
     
     m_last_timestamp = timestamp;
     
     
-    m_error_sum = /* fill in the blank */;
+    m_error_sum += error*delta_time;
     
-    float delta_error = /* fill in the blank */;
+    float delta_error = error - m_last_error;
     
     if(delta_error > 10.0) {
         delta_error = 0.0;
@@ -94,4 +95,4 @@
 float PIDController::getLastTimeStamp()
 {
     return this->m_last_timestamp;
-}
+}
\ No newline at end of file