De EMG Lowpass maakt alle signalen gelijk

Dependencies:   HIDScope biquadFilter mbed

Fork of EMGfilter by Pascal van Baardwijk

Revision:
3:cdac0bfafc80
Parent:
1:7fb4a74d33ff
Child:
4:c7d1ba2fa48b
--- a/main.cpp	Mon Oct 24 18:34:06 2016 +0000
+++ b/main.cpp	Tue Oct 25 13:17:46 2016 +0000
@@ -8,18 +8,19 @@
 states state = STATE_DEFAULT;
 
 //Creating two scope channels
-HIDScope scope(2);
+HIDScope scope(3);
 
 //Notch filter
 BiQuadChain notch_50;
-BiQuad bq1( 1.00000000000, -1.60956348896,  1.00000000000, -1.40195621505,  0.74203282402);
-BiQuad bq2( 1.00000000000, -1.60724786352,  1.00000000000, -1.33646101015,  0.85967899264);
-BiQuad bq3( 1.00000000000, -1.61186693071,  1.00000000000, -1.64415455961,  0.89726621230);
+BiQuad bq1( 1.00007369335,-1.61815834791, 1.00007369335, -1.60983662066, 0.98986119869);
+BiQuad bq2( 1.00000000000,-1.61803910919, 1.00000000000, -1.60936554071, 0.99545624832);
+BiQuad bq3( 0.99035034846,-1.60242559561, 0.99035034846, -1.61934542233, 0.9955088075);
 
 //High pass filter
 BiQuadChain high_pass;
-BiQuad bq4( 1.00000000000, -1.99999967822,  1.00000000000, -1.98388291862,  0.98395921205);
-BiQuad bq5( 1.00000000000, -1.99999812453,  1.00000000000, -1.99324612474,  0.99332432675);
+BiQuad bq4( 0.83315051810,-1.66630103620, 0.83315051810, -1.55025104412, 0.60696783282);
+BiQuad bq5( 0.86554941044,-1.73109882088, 0.86554941044, -1.74142633961, 0.78400451004);
+BiQuad bq6( 0.92490714701,-1.84981429401, 0.92490714701, -1.90032503529, 0.9352152620);
 
 //Ticker
 Ticker emgSampleTicker;
@@ -85,7 +86,7 @@
 int main() {
     //combine biquads in biquad chains for notch/high- low-pass filters
     notch_50.add( &bq1 ).add( &bq2 ).add( &bq3 );
-    high_pass.add( &bq4 ).add( &bq5 );
+    high_pass.add( &bq4 ).add( &bq5 ).add( &bq6 );
     led.write(1);
     
     change_state.attach( &calibrate,5);
@@ -108,10 +109,10 @@
             
             for (int i = 0; i < 3; i++){
                 //filter out the 50Hz components with a notch filter
-                //emg_notch[i] = notch_50.step(emg_sample[i]);
+                emg_notch[i] = notch_50.step(emg_sample[i]);
             
                 //high pass the signal (removing motion artifacts and offset)
-                emg_high_passed[i] = high_pass.step(emg_sample[i]);
+                emg_high_passed[i] = high_pass.step(emg_notch[i]);
             }
             
             //Calculating RMS
@@ -183,7 +184,7 @@
             //Send scope data
             scope.set(0,emg_sample[0]);
             scope.set(1,input_force0);
-            //scope.set(2,input_force1);
+            scope.set(2,RMS0);
             //scope.set(3,input_force2);
             scope.send();