book collections email follower instructable user

Step 8: Tuning PID Constants

Picture of Tuning PID Constants

There are some established mathematical strategies of tuning the PID constants, like the Ziegler-Nichols method, or the Cohen-Coon method. However, we have found it difficult to implement these methods in our system, and have therefore opted for tuning with a few simpler rules:

  1. Set all the constants to zero. Then slowly increase _Kp until the robot starts to oscillate. Make sure that it will always correct itself if leaning to one side, even if it falls down to the other when doing so.
  2. Increase _Kd in regular intervals until you notice the oscillations begin to decrease.
  3. Increase _Ki so that the response is faster when the robot is really out of balance, and slower when it is only a little off its setpoint. This should improve the reaction time that was decreased when you increased _Kd.
  4. Fine tune the constants from this point until the robot can maintain its balance indefinitely.

The gif uploaded to the beginning of this section can also serve as a visual guide as to the effect of each of these constants. We have found it very helpful as a visual tool for tuning.