met printstatements 1
Dependencies: HIDScope MODSERIAL PID QEI biquadFilter mbed
Fork of EMG_5 by
Diff: main.cpp
- Revision:
- 37:6ac3e70787d1
- Parent:
- 36:2fbc53a2747c
- Child:
- 38:32c7e08bb281
diff -r 2fbc53a2747c -r 6ac3e70787d1 main.cpp --- a/main.cpp Fri Nov 03 01:50:10 2017 +0000 +++ b/main.cpp Fri Nov 03 02:04:58 2017 +0000 @@ -668,14 +668,14 @@ filter(); count1 = Encoder1.getPulses(); angle1 += (0.0981 * count1); - if (angle1<setpoint1){ - motor1direction = 1; // counterclockwise rotation - } - else { - motor1direction = 0; // clockwise rotation - } - while (angle1<setpoint1 /*|| angle1>setpoint1*/) { - if (angle1<setpoint1 /*|| angle1>setpoint1*/) { + while (angle1<setpoint1 || angle1>setpoint1) { + if (angle1<setpoint1){ + motor1direction = 1; // counterclockwise rotation + } + else { + motor1direction = 0; // clockwise rotation + } + if (angle1<setpoint1 || angle1>setpoint1) { motor1pwm = 0.5; } else if (angle1 == setpoint1){ @@ -683,20 +683,21 @@ } } } + // check if motor1 needs to be activated void SetMotor2() { filter(); //PIDcalculation2(); count2 = Encoder2.getPulses(); angle2 += (0.0981 * count2); - if (angle2<setpoint2){ - motor2direction = 1; // counterclockwise rotation - } - else { - motor2direction = 0; // clockwise rotation - } - while (angle2<setpoint2 /*|| angle2>setpoint2*/) { - if (angle2<setpoint2 /*|| angle2>setpoint2*/) { + while (angle2<setpoint2 || angle2>setpoint2) { + if (angle2<setpoint1){ + motor1direction = 1; // counterclockwise rotation + } + else { + motor1direction = 0; // clockwise rotation + } + if (angle2<setpoint2 || angle2>setpoint2) { motor2pwm = 0.5; } else if (angle2 == setpoint2){