
EMG original converter code
Dependencies: HIDScope MODSERIAL biquadFilter mbed
Fork of EMG_converter_code by
Diff: main.cpp
- Revision:
- 9:07188eb1e8a1
- Parent:
- 8:87b07f148124
--- a/main.cpp Fri Oct 21 08:23:08 2016 +0000 +++ b/main.cpp Wed Oct 26 08:13:32 2016 +0000 @@ -1,10 +1,10 @@ #include "mbed.h" -#include "HIDScope.h" //Include the HIDScope library -#include "biquadFilter.h" +#include "HIDScope.h" +#include "biquadFilter.h" // Require the HIDScope library #include "MODSERIAL.h" //Define objects -AnalogIn emg(A0); //Analog of EMG input +AnalogIn emg(A0); //Analog of EMG input Ticker sample_timer; Ticker motor_timer; Ticker cal_timer; @@ -13,6 +13,7 @@ DigitalOut led1(LED_RED); DigitalOut led2(LED_BLUE); MODSERIAL pc(USBTX,USBRX); + /*The biquad filters required to transform the EMG signal into an usable signal*/ biquadFilter filterhigh1(-1.1430, 0.4128, 0.6389, -1.2779, 0.6389); biquadFilter filterlow1(1.9556, 0.9565, 0.9780, 1.9561, 0.9780); @@ -78,13 +79,13 @@ int main() { pc.baud(115200); - led1.write(1); - led2.write(1); + led1.write(0); + led2.write(0); - sample_timer.attach(&filter, 0.002);//continously execute the EMG reader and filter - motor_timer.attach(&checkmotor, 0.002);//continously execute the motor controller - cal_timer.attach(&calibri, 0.002);//ticker to check if motor is being calibrated - + sample_timer.attach(&filter, 0.05);//continously execute the EMG reader and filter + motor_timer.attach(&checkmotor, 0.05);//continously execute the motor controller + cal_timer.attach(&calibri, 0.05);//ticker to check if motor is being calibrated + //0.002 while(1){ //random while loop to keep system going