f
Dependencies: HIDScope biquadFilter mbed
main.cpp@0:6c6907217e7a, 2018-10-29 (annotated)
- Committer:
- JurrienBos
- Date:
- Mon Oct 29 15:06:12 2018 +0000
- Revision:
- 0:6c6907217e7a
hh
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JurrienBos | 0:6c6907217e7a | 1 | #include "mbed.h" |
JurrienBos | 0:6c6907217e7a | 2 | #include "BiQuad.h" |
JurrienBos | 0:6c6907217e7a | 3 | #include "HIDScope.h" |
JurrienBos | 0:6c6907217e7a | 4 | |
JurrienBos | 0:6c6907217e7a | 5 | Ticker sample_timer; |
JurrienBos | 0:6c6907217e7a | 6 | HIDScope scope(2); |
JurrienBos | 0:6c6907217e7a | 7 | |
JurrienBos | 0:6c6907217e7a | 8 | BiQuadChain bqc; |
JurrienBos | 0:6c6907217e7a | 9 | BiQuad BqNotch1( 9.98224e-01, -1.61516e+00, 9.98224e-01, -1.61555e+00, 9.98222e-01 ); |
JurrienBos | 0:6c6907217e7a | 10 | BiQuad BqNotch2( 1.00000e+00, -1.61804e+00, 1.00000e+00, -1.61764e+00, 9.98227e-01 ); |
JurrienBos | 0:6c6907217e7a | 11 | |
JurrienBos | 0:6c6907217e7a | 12 | BiQuad BqHP( 9.86760e-01, -1.97352e+00, 9.86760e-01, -1.97334e+00, 9.73695e-01 ); |
JurrienBos | 0:6c6907217e7a | 13 | //BiQuad BqLP( 3.46041e-04, 6.92083e-04, 3.46041e-04, -1.94670e+00, 9.48082e-01 ); |
JurrienBos | 0:6c6907217e7a | 14 | |
JurrienBos | 0:6c6907217e7a | 15 | Ticker emgSampleTicker; |
JurrienBos | 0:6c6907217e7a | 16 | AnalogIn emg0( A0 ); |
JurrienBos | 0:6c6907217e7a | 17 | AnalogIn emg1 (A1) ; |
JurrienBos | 0:6c6907217e7a | 18 | //volatile double emgFiltered; |
JurrienBos | 0:6c6907217e7a | 19 | //volatile double emgSampleabs; |
JurrienBos | 0:6c6907217e7a | 20 | |
JurrienBos | 0:6c6907217e7a | 21 | void emgSample() |
JurrienBos | 0:6c6907217e7a | 22 | { |
JurrienBos | 0:6c6907217e7a | 23 | double emgFiltered = bqc.step( emg0.read() ); |
JurrienBos | 0:6c6907217e7a | 24 | bqc.add( &BqNotch1 ).add( &BqNotch2 ).add( &BqHP ); |
JurrienBos | 0:6c6907217e7a | 25 | //emgSampleabs = fabs(emgFiltered); |
JurrienBos | 0:6c6907217e7a | 26 | } |
JurrienBos | 0:6c6907217e7a | 27 | |
JurrienBos | 0:6c6907217e7a | 28 | void sample() |
JurrienBos | 0:6c6907217e7a | 29 | { |
JurrienBos | 0:6c6907217e7a | 30 | scope.set(0, emg0.read() ); |
JurrienBos | 0:6c6907217e7a | 31 | scope.set(1, emg1.read() ); |
JurrienBos | 0:6c6907217e7a | 32 | scope.send(); |
JurrienBos | 0:6c6907217e7a | 33 | } |
JurrienBos | 0:6c6907217e7a | 34 | |
JurrienBos | 0:6c6907217e7a | 35 | int main() |
JurrienBos | 0:6c6907217e7a | 36 | { |
JurrienBos | 0:6c6907217e7a | 37 | emgSampleTicker.attach( &emgSample, 0.01 ); |
JurrienBos | 0:6c6907217e7a | 38 | sample_timer.attach(&sample, 0.002); |
JurrienBos | 0:6c6907217e7a | 39 | while( true ){} |
JurrienBos | 0:6c6907217e7a | 40 | } |