Test code to calibrate EMG - MVC measurement

Dependencies:   HIDScope MODSERIAL mbed

Fork of emgCalibration by Martijn Kern

Revision:
2:174b10062c61
Parent:
1:93d79d6e96bc
Child:
3:3981bbe6d7b8
--- a/main.cpp	Thu Oct 15 21:25:23 2015 +0000
+++ b/main.cpp	Thu Oct 15 21:36:18 2015 +0000
@@ -10,6 +10,7 @@
 AnalogIn emg3(A2); // 3e board
 AnalogIn emg4(A3); // bovenste board
 
+int muscle;
 double tijd;
 double y5;
 Ticker sample_timer; // naam van de emg-ticker
@@ -85,10 +86,10 @@
 double y5 = biquad(y4, f4_v1, f4_v2, denlow_2, denlow_3, numlow_1, numlow_2, numlow_3);
 
     biceps_power=y5;
-    //scope.set(0,u1);
-    //scope.set(1,y4);
-    //scope.set(2,biceps_power);
-    //scope.send();
+    scope.set(0,u1);
+    scope.set(1,y4);
+    scope.set(2,biceps_power);
+    scope.send();
     
 }
 
@@ -107,7 +108,7 @@
     printf("stopped sampling \r\n");
 }
      
-void calibrate_emg(int muscle)
+void calibrate_emg()
 {  
     //double sampletime=0;
     //sampletime=+SAMPLE_RATE;
@@ -116,7 +117,7 @@
     //int muscle=1;
     //for(int index=0; index<2500;index++){   //measure 5 seconds@500hz = 2500 samples
      
-        //if(muscle=1){
+        if(muscle=1){
             
             if(biceps_power>bicepsMVC){
             printf("+ ");
@@ -124,7 +125,7 @@
             }    
             else
             printf("- ");
-       // }  
+        }  
         
         if(muscle==2){
             
@@ -158,6 +159,7 @@
 {
    pc.baud(115200);
    Ticker timer;
+   
    printf("Robot Started \r\n");
    printf("Testcode calibration \r\n");
    wait(1);
@@ -171,6 +173,7 @@
    printf(" \r\n  Starting in 1... \r\n"); wait(1);
    
    start_sampling();
+   muscle=1;
    timer.attach(&calibrate_emg,0.002);
    wait(5);
    timer.detach();
@@ -180,7 +183,9 @@
    printf("Calibrate_emg() exited \r\n");
    printf("Measured time: %f seconds \r\n",tijd);
    
+   // repeat for other muscles.
    
+   //stop_sampling();
    while (true){   
         
         wait(1);