filters aangepast en bepaling threshold

Dependencies:   HIDScope MODSERIAL biquadFilter mbed

Fork of EMGV3 by Margreeth de Breij

Revision:
20:a0642e983da9
Parent:
19:34456a1effc4
Child:
22:207d314523ef
--- a/main.cpp	Wed Oct 07 18:26:10 2015 +0000
+++ b/main.cpp	Thu Oct 08 09:50:11 2015 +0000
@@ -19,12 +19,15 @@
     double EMG_L_fh=0;
     double EMG_left_value;
     double EMG_f1;
-    double EMG_f2;    
+    double EMG_f2;
+    double Threshold = 0.08;    
 
 // coëfficiënten
     const double BiGainEMG_Lh = 0.723601, BiGainEMG_Ll=0.983892;
     const double EMGh_a1 = -1.74355513773*BiGainEMG_Lh, EMGh_a2 = 0.80079826172*BiGainEMG_Lh, EMGh_b0 = 1.0*BiGainEMG_Lh, EMGh_b1 = -1.99697722433*BiGainEMG_Lh, EMGh_b2 = 1.0*BiGainEMG_Lh; //coefficients for high-pass filter
     const double EMGl_a1 = 1.96775103303*BiGainEMG_Ll, EMGl_a2 = 0.96827054038*BiGainEMG_Ll, EMGl_b0 = 1.0*BiGainEMG_Ll, EMGl_b1 = 1.99999993582*BiGainEMG_Ll, EMGl_b2 = 1.0*BiGainEMG_Ll; // coefficients for low-pass filter
+    
+// Filter creation    
     biquadFilter EMG_highpass (EMGh_a1, EMGh_a2, EMGh_b0, EMGh_b1, EMGh_b2);        // creates the high pass filter
     biquadFilter EMG_lowpass (EMGl_a1, EMGl_a2, EMGl_b0, EMGl_b1, EMGl_b2);         // creates the low pass filter
     
@@ -58,7 +61,7 @@
     ScopeTimer.attach(&ScopeSend, 0.002);
     while(1) 
     {
-        if (EMG_f2 > 0.08)
+        if (fabs(EMG_f2) > Threshold)
         {
             led.write(0);
         }