Hidscope + EMG
Dependencies: HIDScope biquadFilter mbed
Diff: main.cpp
- Revision:
- 1:7eadfb7fd5c9
- Parent:
- 0:5ad817857e29
- Child:
- 2:b2d117949de7
--- a/main.cpp Mon Oct 22 10:47:44 2018 +0000 +++ b/main.cpp Mon Oct 22 11:19:47 2018 +0000 @@ -1,26 +1,35 @@ #include "mbed.h" #include "HIDScope.h" +#include "BiQuad.h" // Define the HIDScope and Ticker object -HIDScope scope(2); +HIDScope scope(3); Ticker scopeTimer; +BiQuad bq1(0.2928920553392428, 0.5857841106784856, 0.2928920553392428, -1.3007020142696517e-16,0.17156822135697122); // Read the analog input AnalogIn emg1(A0); AnalogIn emg2(A1); - + +double emgSample() +{ + double emgFiltered = bq1.step(emg1.read()); + return emgFiltered; +} + // The data read and send function void scopeSend() { scope.set(0,emg1.read()); scope.set(1,emg2.read()); + scope.set(2,emgSample()); scope.send(); } int main() { // Attach the data read and send function at 100 Hz - scopeTimer.attach_us(&scopeSend, 1e4); + scopeTimer.attach_us(&scopeSend, 2e3); while(1) { } } \ No newline at end of file