De EMG Lowpass maakt alle signalen gelijk
Dependencies: HIDScope biquadFilter mbed
Fork of EMGfilter by
Diff: main.cpp
- Revision:
- 5:02b3550e1ff0
- Parent:
- 4:c7d1ba2fa48b
- Child:
- 6:da06585e106c
--- a/main.cpp Tue Oct 25 13:33:12 2016 +0000 +++ b/main.cpp Tue Oct 25 18:32:01 2016 +0000 @@ -22,6 +22,12 @@ BiQuad bq5( 0.86554941044,-1.73109882088, 0.86554941044, -1.74142633961, 0.78400451004); BiQuad bq6( 0.92490714701,-1.84981429401, 0.92490714701, -1.90032503529, 0.9352152620); +//Low pass filter +BiQuadChain low_pass; +BiQuad bq7( 0.00040400257, 0.00080800515, 0.00040400257,-1.92223307595, 0.92384908624); +BiQuad bq8( 0.00040816681, 0.00081633362, 0.00040816681,-1.94204639240, 0.94367905964); +BiQuad bq9( 0.00041558628, 0.00083117256, 0.00041558628,-1.97734803172, 0.9790103768); + //Ticker Ticker emgSampleTicker; @@ -44,7 +50,7 @@ double emg_sample[3]; double emg_notch[3]; double emg_high_passed[3]; -double emg_rectified; +double emg_low_passed[3]; double min_emg[3]; double max_emg[3]; @@ -87,6 +93,7 @@ //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 ).add( &bq6 ); + low_pass.add( &bq7 ).add( &bq8 ).add( &bq9 ); led.write(1); change_state.attach( &calibrate,5); @@ -113,6 +120,9 @@ //high pass the signal (removing motion artifacts and offset) emg_high_passed[i] = high_pass.step(emg_notch[i]); + + //low pass the rectified emg signal + emg_low_passed[i] = low_pass.step(fabs(emg_high_passed[i])); } //Calculating RMS @@ -183,8 +193,8 @@ //Send scope data scope.set(0,emg_sample[0]); - scope.set(1,input_force0); - //scope.set(2,input_force1); + scope.set(1,RMS0); + scope.set(2,emg_low_passed[0]); //scope.set(3,input_force2); scope.send();