Robotics ^___^ / Mbed 2 deprecated FINALFINALNORMAL

Dependencies:   mbed

Fork of FINAL by Robotics ^___^

Files at this revision

API Documentation at this revision

Comitter:
YutingHsiao
Date:
Thu Jun 08 13:44:26 2017 +0000
Parent:
2:ae0ba466c714
Commit message:
final final normal

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r ae0ba466c714 -r 6422dc6e8509 main.cpp
--- a/main.cpp	Tue Apr 25 09:20:23 2017 +0000
+++ b/main.cpp	Thu Jun 08 13:44:26 2017 +0000
@@ -72,11 +72,9 @@
 float ierr_2 = 0.0;
 float p_gain=0.002;
 float i_gain=0.05;
-float duty;
 
 float err_1_old=0;
 float err_2_old=0;
-bool servo=1;
 
 
 Serial pc(USBTX,USBRX);
@@ -118,32 +116,24 @@
         data_received_old[2] = data_received[2];
     }
 
-    /*
-    servo=1;
-    while(servo==1){
-       if(i==0 || i==100 || i==200 || i==300 || i==400 || i==500 || i==600){
-      
-        duty=0.113f-0.0000733f*(float)i;
-  
-        }
-        //pc.printf("duty= %f ,\n",duty);
-        //servo_cmd.period_ms(20);
-        servo_cmd.write( data_received_old[2]);
-        servo=0;
-        i=i+1;
-     }
-     if(i==601){
-        i=0; 
+    if( data_received_old[2] == 1)
+    {
+        //open
+        // servo_duty = xxx;
     }
-     
-     
-    */
-    /////////////////////////
+    
+    if( data_received_old[2] == 2)
+    {
+        //closed
+        // servo_duty = xxx;
+    }
     
     if(servo_duty >= 0.113f)servo_duty = 0.113;
     else if(servo_duty <= 0.025f)servo_duty = 0.025;
     servo_cmd.write(servo_duty);
-
+    
+   
+    
     // motor1
     rotation_speed_1 = (float)speed_count_1 * 100.0f / 12.0f * 60.0f / 29.0f;   //unit: rpm
     speed_count_1 = 0;