Code om 4 EMG te filteren, thresholds te zetten met kalibratie en met putty te kijken of die thresholds overschreden worden

Dependencies:   MovingAverage mbed biquadFilter MODSERIAL

Files at this revision

API Documentation at this revision

Comitter:
aschut
Date:
Sat Apr 20 20:12:25 2019 +0000
Parent:
2:f6060b484caf
Commit message:
Code om 4 EMG te filteren, thresholds te zetten met kalibratie en met putty te kijken of die thresholds overschreden worden

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Apr 16 12:35:11 2019 +0000
+++ b/main.cpp	Sat Apr 20 20:12:25 2019 +0000
@@ -146,51 +146,31 @@
 
 void CalibrationEMG()
 {
-    
-    while(timer_calibration<39) {                           //Duim
-        if(timer_calibration>0 && timer_calibration<7) {
+    timer_calibration.reset();
+    timer_calibration.start();
+    while(timer_calibration<20) {                           //Duim
+        if(timer_calibration>0 && timer_calibration<20) {
             led1=!led1;
             if(emg1_filtered>temp_highest_emg1) {
                 temp_highest_emg1= emg1_filtered;
                 pc.printf("Highest value Duim= %f \r\n", temp_highest_emg1);
             }
-        }
-        if(timer_calibration>7 && timer_calibration<10) {    
-            led1=0;
-            led2=0;
-            led3=0;
-        }
-        if(timer_calibration>10 && timer_calibration<17) {  //Bicep
-            led2=!led2;
+        
             if(emg2_filtered>temp_highest_emg2) {
                 temp_highest_emg2= emg2_filtered;
                 pc.printf("Highest value Bicep= %f \r\n", temp_highest_emg2);
             }
-        }
-        if(timer_calibration>17 && timer_calibration<20) {
-            led1=0;
-            led2=0;
-            led3=0;
-        }
-        if(timer_calibration>20 && timer_calibration<27) {  //Dorsaal
-            led3=!led3;
+        
             if(emg3_filtered>temp_highest_emg3) {
                 temp_highest_emg3= emg3_filtered;
                 pc.printf("Highest value Dorsaal= %f \r\n", temp_highest_emg3);
             }
-        }
-        if(timer_calibration>27 && timer_calibration<30) {
-            led1=0;
-            led2=0;
-            led3=0;
-        }
-        if(timer_calibration>30 && timer_calibration<37) {  //Palmair
-            led2=!led2;
-            led3=!led3;
+        
             if(emg4_filtered>temp_highest_emg4) {
                 temp_highest_emg4= emg4_filtered;
                 pc.printf("Highest value Palmair= %f \r\n", temp_highest_emg4);
             }
+            
         }
         led1=1;
         led2=1;
@@ -317,34 +297,7 @@
 pc.printf("Bicep Right = %i\r\n",Bicep);
 pc.printf("Dorsaal Left = %i\r\n", Dorsaal);
 pc.printf("Palmair Left = %i\r\n", Palmair);           
-    if (Duim == 1){     //groen
-    led1 = 0;
-    }
-    else {
-    led1 = 1;
-    }
-    if (Bicep == 1){        //rood
-    led2 = 0;
-    }
-    else {
-    led2 = 1;
-    }
-    if (Dorsaal == 1){      //blauw
-    led3 = 0;
-    }
-    else {
-    led3 = 1;
-    }
-    if (Palmair == 1){
-    led1 = 0;
-    led2 = 0;
-    led3 = 0;
-    }
-    else {
-    led1 = 1;
-    led1 = 2;
-    led1 = 3;
-    }
+        
 }
 
 
@@ -353,7 +306,7 @@
                 led1 = 1;
                 led2 = 1;
                 led3 = 1;
-    sample_ticker.attach(&emgsample, ts);
+    sample_ticker.attach(&emgsample, 0.001);            // Leest het ruwe EMG signaal af met een frequentie van 1000Hz
     pc.baud(115200);
     
 //BiQuad Chain add
@@ -367,8 +320,7 @@
     temp_highest_emg3 = 0;
     temp_highest_emg4 = 0;
 
-    timer_calibration.reset();
-    timer_calibration.start();
+
     CalibrationEMG();
     pc.printf("threshold1 = %i, threshold1L = %f\r\n", threshold1, threshold1L);
     threshold_check_ticker.attach(&threshold_check, 0.01);