robot
Dependencies: Encoder HIDScope MODSERIAL TouchButton mbed-dsp mbed
Fork of Robot2false by
Diff: main.cpp
- Revision:
- 59:a5442a3811ed
- Parent:
- 58:9a56581d5298
- Child:
- 60:c4cf57749f2e
--- a/main.cpp Mon Nov 03 18:12:46 2014 +0000 +++ b/main.cpp Mon Nov 03 20:48:51 2014 +0000 @@ -11,14 +11,14 @@ #define I_LIMIT 1. #define K_Pp (0.003) //-------------------------------Deze drie waarden moeten anders!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #define K_Ip (0.0 *TSAMP2)//-----------------------------TSAMP1 veranderd naar TSAMP2 -#define K_Dp (0.0000003 /TSAMP2)//--------------------------------TSAMP1 veranderd naar TSAMP2 +#define K_Dp (0.000003 /TSAMP2)//--------------------------------TSAMP1 veranderd naar TSAMP2 #define TSAMP1 0.01 #define TSAMP2 0.01 #define WACHTEN 1 #define SLAAN 2 #define TERUGKEREN 3 -#define ANGLEMAX -50 +#define ANGLEMAX -280 #define ANGLEMIN 0 //initiating functions @@ -85,7 +85,7 @@ float new_pwm; float PWM2 = 0.3; //PWM voor instellen hoek batje, kan waarschijnlijk een stuk langzamer int toestand = WACHTEN; //terugkeren? -float setspeed = 0, V3=80, V2=40, V1 =30;//V in counts/s +float setspeed = 0, V3=150, V2=40, V1 =30;//V in counts/s Encoder motor1(PTD5,PTD3, true); @@ -342,8 +342,8 @@ // *** INPUT MOTOR 2 *** positie=yT1+yT2; */ - - /* //controle positie op scherm +positie=1; + //controle positie op scherm if (positie==0) { pc.printf("Motor 2 blijft op stand 1\n"); } else { @@ -360,8 +360,8 @@ looptimer2.attach(motor2aansturing,TSAMP1); wait(8); looptimer2.detach(); - pc.printf("Detach Motor 1\n"); - */ + pc.printf("Detach Motor 2\n"); + // ------------------------------------------------------------------------------------------------------------------------------- eind aansturing motor 2 wait(2); @@ -678,11 +678,11 @@ } break; case 1: - if (motor2.getPosition()>= 2) { + if (motor2.getPosition()>= 0) { motordir2 = 1; pwm_motor2.write(PWM2); } - if (motor2.getPosition()<= 2) { + if (motor2.getPosition()<= 20) { motordir2 = 0; pwm_motor2.write(PWM2); } else { @@ -710,7 +710,7 @@ case SLAAN: pc.printf("SLAAN\n"); new_pwm = pid(setspeed, omega); - pwm_motor1.write(new_pwm); + pwm_motor1.write(0.8); //=================================================================================================== motordir1 = 1; if (motor1.getPosition() <= ANGLEMAX) { toestand = TERUGKEREN;