now with PID controler XXXD
Dependencies: HIDScope MODSERIAL QEI biquadFilter mbed
Fork of another_try_from_scratch_on_emg by
Diff: main.cpp
- Revision:
- 4:7d9ca9c1dcce
- Parent:
- 3:79b95226a608
- Child:
- 5:688b1b5530d8
--- a/main.cpp Fri Oct 21 12:49:15 2016 +0000 +++ b/main.cpp Fri Oct 21 13:26:36 2016 +0000 @@ -1,32 +1,32 @@ //libraries #include "mbed.h" #include "HIDScope.h" -#include "biquadFilter.h" -#include "MODSERIAL.h" +#include "biquadFilter.h" //Define objects AnalogIn emg0( A0 ); //analog in to get EMG in to c++ Ticker sample_timer; //ticker -HIDScope scope( 2); //open 3 channels in hidscope +HIDScope scope( 3); //open 3 channels in hidscope DigitalOut led(LED_GREEN); -MODSERIAL pc(USBTX,USBRX); // connection with pc - //define variables double emg_0_value; -biquadFilter biqfilter(-1.1430, 0.4128, 0.6389, -1.2779, 0.6389); //initialize filter - +double emg_gefilterd; +double emg_abs +biquadFilter filterhigh1(-1.1430, 0.4128, 0.6389, -1.2779, 0.6389); //eerste hoogdoorlaat filter void filter(){ emg_0_value=emg0.read(); //read the emg value from the elektrodes + emg_filtered= filterhigh1.step(emg_0_value); + emg_abs=abs(emg_filtered); + led=!led; - double emg_filter=biqfilter.step(emg_0_value) ; + //send signals to scope scope.set(0, emg_0_value ); //set emg signal to scope in channel 1 - scope.set(1, emg_filter ); + scope.set(1, emg_gefilterd ); + scope.set(2, emg_abs); scope.send(); //send all the signals to the scope - - pc.printf("emg raw: %f, emg filter %f \r\n",emg_0_value,emg_filter); } //program @@ -34,7 +34,7 @@ int main() { sample_timer.attach(&filter, 0.001); //continously execute the EMG reader and filter, it ensures that filter and sampling is executed every 1/frequency seconds -pc.baud(115200); //connection with pc at 115200 rate + //endless loop while(1)