EMG original converter code
Dependencies: HIDScope MODSERIAL biquadFilter mbed
Fork of EMG_converter_code by
Diff: main.cpp
- Revision:
- 8:87b07f148124
- Parent:
- 7:87d9904c1c19
- Child:
- 9:07188eb1e8a1
--- a/main.cpp Tue Oct 27 10:49:59 2015 +0000 +++ b/main.cpp Fri Oct 21 08:23:08 2016 +0000 @@ -1,17 +1,18 @@ #include "mbed.h" -#include "HIDScope.h" -#include "biquadFilter.h" // Require the HIDScope library +#include "HIDScope.h" //Include the HIDScope library +#include "biquadFilter.h" #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; HIDScope scope(2); // Instantize a 2-channel HIDScope object -DigitalIn button1(PTA4);//test button for starting motor 1 -DigitalOut led1(LED_RED); -DigitalOut led2(LED_BLUE); -MODSERIAL pc(USBTX,USBRX); +DigitalIn button1(PTA4);//test button for starting motor 1 +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); @@ -40,7 +41,7 @@ onoffsignal=signalfinal/maxcal;//divide the emg signal by the max EMG to calibrate the signal per person scope.set(0,emg_value);//set emg signal to scope in channel 1 scope.set(1,onoffsignal);//set filtered signal to scope in channel 2 - scope.send();//send the signals to the scope + scope.send();//send the signals to the scope //pc.printf("emg signal %f, filtered signal %f \n",emg_value,onoffsignal); } }