No.9 Robotics / Mbed 2 deprecated Robotics_Servo_control

Dependencies:   mbed

Fork of Robotics_Lab_Servo by LDSC_Robotics

Files at this revision

API Documentation at this revision

Comitter:
dg0704
Date:
Thu Mar 10 07:26:03 2016 +0000
Parent:
5:d495dc55f709
Child:
7:db4ddfc0cf4e
Commit message:
PI

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Mar 10 07:09:09 2016 +0000
+++ b/main.cpp	Thu Mar 10 07:26:03 2016 +0000
@@ -61,8 +61,8 @@
     
     //////code for PI control//////
     err = angle_ref - angle_read;
-    ierr = 0.01f - 0.01f*err;
-    PI_out = Kp * err + Ki * ierr;
+    ierr += err;
+    PI_out = Kp * err + Ki * 0.01f*(ierr - err);
     
     ////////////
     if(PI_out >= 0.5f)PI_out = 0.5;