met knopjes, voor Wubs, zit PID in dus restrictie.
Dependencies: HIDScope MODSERIAL QEI biquadFilter mbed
Fork of a_pid_kal_end_def by
Diff: main.cpp
- Revision:
- 8:cd0cb71b69f2
- Parent:
- 7:42d0e38196f1
- Child:
- 9:464c447ce82d
--- a/main.cpp Fri Oct 21 13:43:43 2016 +0000 +++ b/main.cpp Fri Oct 21 13:50:48 2016 +0000 @@ -6,7 +6,9 @@ //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( 3); //open 3 channels in hidscope +DigitalOut richting_motor1(D4); //motor1 direction output +PwmOut pwm_motor1(D5); //motor1 velocity output DigitalOut led(LED_GREEN); //define variables @@ -18,6 +20,7 @@ biquadFilter filterhigh1(-1.1430, 0.4128, 0.6389, -1.2779, 0.6389); + void filter(){ emg_0_value=emg0.read(); //read the emg value from the elektrodes emg_gefilterd= filterhigh1.step(emg_0_value); @@ -46,6 +49,20 @@ //endless loop while(1) - {} + { + if (onoffsignal==1) + { + richting_motor1 = 0; //motordirection (ccw) + pwm_motor1 = 1; //motorspeed 1 + + } + else if(onoffsignal==0) + { + richting_motor1 = 0; //motordirection (ccw) + pwm_motor1 = 0; //motorspeed 0 + + } + + } } \ No newline at end of file