No.9 Robotics / Mbed 2 deprecated Robotics_Servo_control

Dependencies:   mbed

Fork of Robotics_Lab_Servo by LDSC_Robotics

Revision:
5:d495dc55f709
Parent:
4:facfa2ac9a59
Child:
6:52f6c4d57d74
--- a/main.cpp	Thu Mar 10 06:32:13 2016 +0000
+++ b/main.cpp	Thu Mar 10 07:09:09 2016 +0000
@@ -7,9 +7,8 @@
 #define Kp 0.053f
 #define Ki 0.013f
 
-PwmOut servo(A0);
-PwmOut pwm1(PA_8);
-PwmOut pwm1n(PB_13);
+PwmOut pwm1(D7);
+PwmOut pwm1n(D11);
 
 AnalogIn adc(A2);//Temporary usage
 
@@ -35,8 +34,6 @@
 float ierr = 0.0;
 float PI_out = 0.0;
 float pwm1_duty = 0.5;
-float kp = 0.025;
-float ki = 0.025;
 
 int main (void)
 {    
@@ -64,8 +61,8 @@
     
     //////code for PI control//////
     err = angle_ref - angle_read;
-    ierr = 0.01f/(err-1);
-    PI_out = kp*err+ki*ierr;
+    ierr = 0.01f - 0.01f*err;
+    PI_out = Kp * err + Ki * ierr;
     
     ////////////
     if(PI_out >= 0.5f)PI_out = 0.5;