groep 16 / Mbed 2 deprecated Project_BioRobotics_12

Dependencies:   mbed QEI HIDScope BiQuad4th_order biquadFilter MODSERIAL FastPWM

Revision:
10:3f93fdb90c29
Parent:
9:8b2d6ec577e3
Child:
12:3e084e1a699e
Child:
18:f36ac3ee081a
--- a/main.cpp	Wed Oct 31 10:30:34 2018 +0000
+++ b/main.cpp	Wed Oct 31 14:34:21 2018 +0000
@@ -68,6 +68,8 @@
 int need_to_move_2;                     // Does the robot needs to move in the second direction?
 double EMG_calibrated_max_1 = 2.00000;  // Maximum value of the first EMG signal found in the calibration state.
 double EMG_calibrated_max_2 = 2.00000;  // Maximum value of the second EMG signal found in the calibration state.
+double emg1_cal = 0.00000;              //measured value of the first emg
+double emg2_cal = 0.00000;              //measured value of the second emg
 
 // ----------------------------------------------
 // ------- FUNCTIONS ----------------------------
@@ -195,8 +197,18 @@
          // If enough time has passed (5 sec), and the EMG-signal drops below 10%
          // of the maximum measured value, we move to the Homing state.
                     
-         wait(5.0f); // time_in_this_state > 5.0f
-         // INSERT CALIBRATING
+        for (int i = 0; i <= 10; i++) //10 measuring points
+        {      
+        if (emg1_cal > EMG_calibrated_max_1){
+            EMG_calibrated_max_1 = emg1_cal;}
+            
+        if (emg2_cal > EMG_calibrated_max_2){
+            EMG_calibrated_max_2 = emg2_cal;}
+            
+        //pc.printf("EMG1 = %f, EMG2 = %f \r\n",EMG_calibrated_max_1,EMG_calibrated_max_2);
+        wait(0.5f);
+        }
+        
          currentState = HOMING;
         if (Fail_button == 0)
         {