robot
Dependencies: Encoder HIDScope MODSERIAL TouchButton mbed-dsp mbed
Fork of Robot2false by
Diff: main.cpp
- Revision:
- 27:9dea548d6d6c
- Parent:
- 26:bee27c74a835
- Child:
- 28:488e24ed1cb1
--- a/main.cpp Sat Nov 01 12:11:02 2014 +0000 +++ b/main.cpp Sat Nov 01 12:33:16 2014 +0000 @@ -10,7 +10,7 @@ #define K_D (0 /TSAMP1) #define I_LIMIT 1. #define K_Pp (0.2) -#define K_Ip (0.002 *TSAMP1) +#define K_Ip (0.02 *TSAMP1) #define K_Dp (0 /TSAMP1) #define TSAMP1 0.01 @@ -437,7 +437,7 @@ float out_p = 0; static float out_i = 0; float out_d = 0; - error = setspeed-measurement; + error = setposition-measurement; out_p = error*K_Pp; out_i += error*K_Ip; out_d = (error-prev_error)*K_Dp; @@ -713,7 +713,7 @@ } if (toestand == TERUGKEREN) { new_pwm = pid(setspeed, motor1.getSpeed(),false); - pwm_motor1.write(new_pwm); + pwm_motor1.write(0.3); motordir1 = 0; pc.printf("motor2.getPosition %d\r\n", motor2.getPosition());