emg2
Dependencies: HIDScope biquadFilter mbed QEI
Fork of EMG by
Diff: main.cpp
- Revision:
- 22:bcfee9594007
- Parent:
- 21:931fe86dbf5a
- Child:
- 23:dec549767006
--- a/main.cpp Mon Oct 29 19:09:11 2018 +0000 +++ b/main.cpp Mon Oct 29 19:38:48 2018 +0000 @@ -2,6 +2,9 @@ #include "HIDScope.h" #include "BiQuad.h" +HIDScope scope( 2 ); +Ticker sample_timer; + // inputs EMG AnalogIn emg0_in( A0 ); AnalogIn emg1_in( A1 ); @@ -49,9 +52,7 @@ BiQuad L3( c1, c2, d0, d1, d2); - - -// Filteren +// Filter of the first EMG signal void filter0() { double emg0; @@ -64,20 +65,10 @@ high = H1.step(notch); //Applying a high pass filter absolute = fabs(high); //Rectifying the data low = L1.step(absolute); //Applying low pass filter - filter0(); - - Ticker sample_timer; - HIDScope scope( 2 ); +} - scope.set(0, emg0_in.read() ); - scope.set(1, low); - scope.send(); - -} - - -void filter1() -{ +//Filter of the second EMG signal +void filter1(){ double emg1; double notch; double high; @@ -89,6 +80,8 @@ absolute = fabs(high); //Rectifying the data low = L2.step(absolute); //Applying low pass filter } + +//Filter of the third EMG signal void filter2() { double emg2; @@ -103,16 +96,18 @@ low = L3.step(absolute); //Applying low pass filter } +//Combining the filters in one fuction void filtered_emg() { + filter0(); + filter1(); + filter2(); } int main() { - Ticker sample_timer; - filter0(); - sample_timer.attach(filter0, 0.002); + sample_timer.attach(&filter0, 0.002); while(1) { }