EMG+filter
Dependencies: mbed HIDScope biquadFilter biquad
Diff: main.cpp
- Revision:
- 22:782e4eac9796
- Parent:
- 21:7932900d6e3b
- Child:
- 23:71103eda6fa2
--- a/main.cpp Fri Oct 11 06:55:39 2019 +0000 +++ b/main.cpp Tue Oct 15 12:55:03 2019 +0000 @@ -1,5 +1,6 @@ #include "mbed.h" #include "HIDScope.h" +#include "BiQuad.h" //Define objects AnalogIn emg0( A0 ); @@ -9,6 +10,13 @@ HIDScope scope( 2 ); DigitalOut led(LED1); +BiQuadChain bqc; +BiQuad bq1(b0, b1, b2, a1, a2); //bijvoorbeeld van rechterbiceps +BiQuad bq2(b00, b11, b22, a11, a22); //bijvoorbeeld van linkerbiceps + +Ticker emgSampleTicker; +AnalogIn emg(A0); //kloptA0 wel?? + /** Sample function * this function samples the emg and sends it to HIDScope **/ @@ -25,12 +33,26 @@ led = !led; } + + + + +void emgSample() +{ + double emgFiltered=bqc.step(emg.read()); +} + + + + int main() { /**Attach the 'sample' function to the timer 'sample_timer'. * this ensures that 'sample' is executed every... 0.002 seconds = 500 Hz */ sample_timer.attach(&sample, 0.002f); + bqc.add(&bq1).add(&bq2); + emgSampleTicker.attach(&emgSample,0.01); /*empty loop, sample() is executed periodically*/ while(1) {