PID controll for the robot motors.
Dependencies: BioroboticsMotorControl MODSERIAL mbed
Diff: main.cpp
- Revision:
- 4:fce8c7458e97
- Parent:
- 3:689f3f2e78e8
- Child:
- 5:fd4eaf3cb09d
diff -r 689f3f2e78e8 -r fce8c7458e97 main.cpp --- a/main.cpp Fri Oct 19 09:06:28 2018 +0000 +++ b/main.cpp Fri Oct 19 09:31:11 2018 +0000 @@ -7,14 +7,14 @@ const float PI = 3.14159265359; const int PULSES_PER_ROTATION = 6533; // Amount of motor encoder pulses per rotation. When using X4 encoding. -const float pid_period = 0.0001; // PID sample period in seconds. +const float pid_period = 0.001; // PID sample period in seconds. const double Kp = 10.0; -const double Ki = 0.5; +const double Ki = 0.1; const double Kd = 0.5; -const double motor_threshold_rps = 0.3; // Rad/s under which we send 0 to the motor, to prevent it from jittering around. -const double motor_stall_pwm = 0.5; // PWM fraction above which the motor starts to move. +const double motor_threshold_rps = 0.1; // Rad/s under which we send 0 to the motor, to prevent it from jittering around. +const double motor_stall_pwm = 0.45; // PWM fraction above which the motor starts to move. int printcount = 0;