Emg filter function script for a uni project. Made by Teun van der Molen

Dependencies:   HIDScope MODSERIAL mbed

Fork of frdm_EMG by Teun van der Molen

Revision:
9:2b9240084724
Parent:
8:54f0a76d35f4
Child:
10:b11eacb391ea
--- a/main.cpp	Wed Sep 23 14:51:13 2015 +0000
+++ b/main.cpp	Wed Sep 23 15:53:10 2015 +0000
@@ -7,7 +7,7 @@
 Ticker      biquadTicker;
 DigitalOut  light(LED2);
 DigitalIn    knop(SW3);
-
+int tel = 0; // timer thing for caliration length (see for loop in main)
 double c=5; //calibration value
 double n = 0; // counter for calibration
 bool calib = false; //changes into false when calibration is done (reset program for new calibration); 
@@ -44,13 +44,13 @@
    
     scope.send();
     
-    while(calib == true and n <= 2000.00) {
+    //while(calib == true and n <= 200.00) {
         
-        c = c + fy;
+      //  c = c + fy;
     
-        n ++;
+        //n ++;
         
-        }
+        //}
         
         
 }
@@ -98,15 +98,32 @@
         
       
       else if (knop == 0){
-          light = 0;
-          calib = true;
           c = 0;
           n = 0;
-          wait(5);
+          //for (tel = 0; tel == 20; tel ++){
+          light = 0;
+          calib = true;
+          for(;calib == true and n <= 20.00; n = n + 1) {
+        
+        c = c + fy;
+    
+        //n ++;
+        
+        wait(0.1);
+        
+        } //while
+        
+       // }
+        
+          
+          
           light = 1;
-          calib = false;
-          c = c/n;
-         }
+          calib = false; // shuts of calibration
+          c = c/n;  //take the average
+          tel = 0;
+          
+          wait(5); // you can only calibrate every this amount of seconds
+         } //if
           
           
       else{