now with PID controler XXXD
Dependencies: HIDScope MODSERIAL QEI biquadFilter mbed
Fork of another_try_from_scratch_on_emg by
Diff: main.cpp
- Revision:
- 13:6c2daab3547b
- Parent:
- 12:a76f9b33fbcb
- Child:
- 14:5b17697cf775
--- a/main.cpp Mon Oct 24 09:41:19 2016 +0000 +++ b/main.cpp Mon Oct 24 09:55:48 2016 +0000 @@ -6,7 +6,7 @@ //Define objects AnalogIn emg0( A0 ); //analog in to get EMG in to c++ Ticker sample_timer; //ticker -HIDScope scope( 3); //open 3 channels in hidscope +HIDScope scope(1); //open 3 channels in hidscope DigitalOut richting_motor1(D4); //motor1 direction output PwmOut pwm_motor1(D5); //motor1 velocity output DigitalOut led(LED_GREEN); @@ -14,23 +14,20 @@ //define variables double emg_0_value; double emg_gefilterd; -double emg_gefilterd_2; double emg_abs; int onoffsignal=0; -double cut_off_value=0.05; //gespecifeerd door floortje +double cut_off_value=0.; //gespecifeerd door floortje -biquadFilter filterhigh1(0.9565, -1.9131, 0.9565, -1.9112, 0.9150); -biquadFilter filterlow(-1.9645, 0.9651, 1.5515e-4, 3.1030e-4, 1.5515e-4); +biquadFilter filterhigh1(9.5654e-01,-1.9131e+00,9.5654e-01,-1.9112e+00,9.1498e-01); void filter(){ - emg_0_value=emg0.read(); //read the emg value from the electrodes + emg_0_value=emg0.read(); //read the emg value from the elektrodes emg_gefilterd= filterhigh1.step(emg_0_value); emg_abs=abs(emg_gefilterd); - emg_gefilterd_2=filterlow.step(emg_abs); led=!led; - if (emg_gefilterd_2>cut_off_value) + if (emg_abs>cut_off_value) {onoffsignal=1;} else @@ -38,8 +35,6 @@ //send signals to scope scope.set(0, emg_0_value ); //set emg signal to scope in channel 1 - scope.set(1, emg_gefilterd_2 ); - scope.set(2, onoffsignal); scope.send(); //send all the signals to the scope }