robot
Dependencies: Encoder HIDScope MODSERIAL TouchButton mbed-dsp mbed
Fork of Robot2false by
Diff: main.cpp
- Revision:
- 50:43ead068c523
- Parent:
- 49:7ae21c58ba92
- Child:
- 51:26a2af57b8e9
--- a/main.cpp Sun Nov 02 14:14:35 2014 +0000 +++ b/main.cpp Sun Nov 02 14:19:53 2014 +0000 @@ -447,8 +447,6 @@ myled3=1; groen=0; blauw=0; - - pid(0,0,true); } } //} @@ -728,25 +726,21 @@ } //end if break; case TERUGKEREN: - //positieregeling rond anglemax!!! + if (motor1.getPosition()<=ANGLEMAX) { + new_pwmpos = pidpositie(ANGLEMAX, motor1.getPosition()); + pwm_motor1.write(new_pwmpos); //mogelijk moet dit -new_pwm zijn??? + motordir1 = 0; + } + if (motor1.getPosition()>= ANGLEMAX) { + new_pwmpos = pidpositie(ANGLEMAX, motor1.getPosition()); + pwm_motor1.write(new_pwmpos); //mogelijk moet dit -new_pwm zijn??? + motordir1 = 1; + } break; } //end switch scope.set(0,motor1.getPosition()); scope.set(1,motor1.getPosition()); scope.send(); - - /* if (toestand == TERUGKEREN) { - pidpositie(ANGLEMIN, motor1.getPosition()); - } - - - if (toestand == TERUGKEREN) { - new_pwm = pid(setspeed, motor1.getSpeed(),false); - pwm_motor1.write(new_pwm); - motordir1 = 0; - pc.printf("motor gaat terugkeren\n\r"); - pc.printf("new pwm %f\r\n",new_pwm); - }*/ } void motor1aansturingdeel2()