State machine

Dependencies:   mbed Adafruit_GFX BioroboticsMotorControl MODSERIAL BioroboticsEMGFilter

Revision:
18:71a5cc9353af
Parent:
16:9c5ef6fe6780
Child:
19:53b9729fbab5
diff -r 1fe276ff17db -r 71a5cc9353af motor_calibration.h
--- a/motor_calibration.h	Wed Oct 31 13:46:34 2018 +0000
+++ b/motor_calibration.h	Wed Oct 31 14:17:03 2018 +0000
@@ -3,7 +3,8 @@
 #include "mbed.h"
 #include "motor.h"
 
-const double motor_calibration_threshold = 0.5*0.0174533;
+const double motor_rad_per_angle = 0.0174533;
+const double motor_calibration_threshold = 0.1*motor_rad_per_angle;
 
 
 // Returns whether this motor is considered to be calibrated.
@@ -17,13 +18,13 @@
     else
     {
         double motor_angle = current_angle;
-        motor_angle = motor_angle - 30 * motor_calibration_threshold;    // Subtracting five degree angle from the current angle
+        motor_angle = motor_angle - 10 * motor_rad_per_angle;    // Subtracting five degree angle from the current angle
         motor.set_target_angle(motor_angle); 
         iterations_not_moving = 0;            // Set time passed in this state back to zero
         //calibLED2 = !calibLED2;                              // LED turns red
     }
     
-    if (iterations_not_moving >= 10)           // After 5 seconds have passed (10 times Ticker motor_calib)
+    if (iterations_not_moving >= 20)           // After 5 seconds have passed (10 times Ticker motor_calib)
     {
         return true;
         //alibLED3 = !calibLED3;                              // LED becomes red (purple if both motors are calibrated)