PID Tuning

Hello,
I’m building a line follower and for this I need help with PID Tuning. The thing with which I’m struggling is that the bot is taking a wider path or say taking a wider curve when making a turn for the sharp turns with some curvature. I tune the PID gains and it is following the line without any problem but when it reaches a turn, it takes a wider turn but it should not lose the line in any case. Below are the hardware details:

Motor: 30:1 Micro Metal Gearmotor HPCB 6V
Wheels: 3PI 44mm wheels
Microcontroller: Arduino Nano
Sensor: QTR-8A
Motor Driver - Toshiba TB6612FNG
Voltage Regulators: LM2596 and XL6009
Battery: 360mAh Lipo

First I started with a slow speed i.e. 70 and for this speed, I could tune the PID gains perfectly. But Now I increased the speed to 100 and it has started giving problems. Below are my gains for various speeds.

Speed=70
Kp=2/100, Kd=5/100

Speed=100
Kp=2.2/100, Kd=7/100

What can be the issue?

PWM motor control is nonlinear, more so at low speeds, which violates one of the basic assumptions of PID theory. So “perfect” tuning over a wide range of speeds and loads is not possible, and people do the best they can.

But those coefficients are not very different. Please post some data showing the response to step changes in load or speed for both cases.

Also, consider adding a Ki term.

1 Like