alles in elkaar met de mooie manier van de regelaar
Dependencies: Encoder HIDScope MODSERIAL TouchButton mbed-dsp mbed
Fork of Robot2mooiemanier by
Diff: main.cpp
- Revision:
- 23:8f7ce4894c58
- Parent:
- 22:f3a827faa135
- Child:
- 24:a165dcd86710
--- a/main.cpp Fri Oct 31 13:59:31 2014 +0000 +++ b/main.cpp Fri Oct 31 14:33:13 2014 +0000 @@ -82,8 +82,10 @@ float setspeed = 0, V3=60, V2=40, V1 =30, Vreturn= 35;//V in counts/s -Encoder motor1(PTD5,PTD3); -Encoder motor2(PTD0,PTD2); +//Encoder motor1(PTD5,PTD3); //actual +//Encoder motor2(PTD0,PTD2); +//Encoder motor1(PTD5,PTD3); +//Encoder motor2(PTD0,PTD2); DigitalOut motordir1(PTA4); DigitalOut motordir2(PTC9); PwmOut pwm_motor1(PTA5); @@ -664,9 +666,7 @@ pwm_motor1.write(new_pwm); motordir1 = 1; pc.printf("SLAAN\n"); - scope.set(0,motor1.getPosition()); //ruwe data - scope.set(1,-244); //filtered - scope.send(); + /*if (toestand == TERUGKEREN) { new_pwm = pid(setspeed, motor1.getSpeed(),false); @@ -675,14 +675,17 @@ pc.printf("motor gaat terugkeren\n\r"); pc.printf("new pwm %f\r\n",new_pwm);*/ } + scope.set(0,motor1.getPosition()); //ruwe data + scope.set(1,motor1.getPosition()); //filtered + scope.send(); } void motor1aansturingdeel2() { - if (motor1.getPosition()>= ANGLEMAX && toestand != SLAAN) { + if (motor1.getPosition()>= ANGLEMIN && toestand != SLAAN) { toestand = WACHTEN; - motor1.setPosition(0); + //motor1.setPosition(0); pid(0,0,true); //pc.printf("if2\n"); } @@ -690,14 +693,15 @@ new_pwm = pid(setspeed, motor1.getSpeed(),false); pwm_motor1.write(new_pwm); motordir1 = 0; - //sturen naar HID Scope - scope.set(0,motor1.getPosition()); //ruwe data - scope.set(2,motor1.getPosition()); //filtered - scope.send(); + pc.printf("motor2.getPosition %d\r\n", motor2.getPosition()); } if (toestand == WACHTEN) { pwm_motor1.write(0); //pc.printf("ifwachten2\n"); } + //sturen naar HID Scope + scope.set(0,motor1.getPosition()); //ruwe data + scope.set(2,motor1.getPosition()); //filtered + scope.send(); } \ No newline at end of file