to send emg signal to motor with test programm
Dependencies: HIDScope biquadFilter mbed
Fork of TestProgramm by
Diff: main.cpp
- Revision:
- 21:77998ce2c0dd
- Parent:
- 20:97059009a491
- Child:
- 22:a85b568a83e5
- Child:
- 23:b5a09f96c2d7
--- a/main.cpp Thu Sep 22 08:53:50 2016 +0000 +++ b/main.cpp Fri Oct 20 11:22:11 2017 +0000 @@ -1,5 +1,6 @@ #include "mbed.h" #include "HIDScope.h" +#include "BiQuad.h" //Define objects AnalogIn emg0( A0 ); @@ -25,12 +26,30 @@ led = !led; } +BiQuadChain bqc; +BiQuad bq1( 0.6844323315947305,1.368864663189461, 0.6844323315947305,1.2243497755555954,0.5133795508233265); +BiQuad bq2( 0.6844323315947306, -1.3688646631894612, 0.6844323315947306, -1.2243497755555959, 0.5133795508233266); +BiQuad bq3( 0.7566897754116633, -1.2243497755555959, 0.7566897754116633, -1.2243497755555959, 0.5133795508233266); + +Ticker emgSampleTicker; +AnalogIn emg( A0 ); + +void emgSample() { + +double emgFiltered = bqc.step( emg.read() ); +scope.set(0, emgFiltered ); + scope.send(); +} + + int main() { +bqc.add( &bq1 ).add( &bq2 ).add( &bq3 ); +emgSampleTicker.attach( &emgSample, 0.002 ); /**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.002); + //sample_timer.attach(&sample, 0.01); /*empty loop, sample() is executed periodically*/ while(1) {}