Questions about PID (actually PD) tuning

Hello.

  1. Ideally, you should be tuning your PID constants on the actual course you want to run it on, or at least on one that is as representative as possible of the kinds of conditions your robot needs to be able to handle. It is not very hard to follow a straight line, so your PID constants do not need to be particularly well tuned to accomplish the task. The difficulty arises when you have to take a sharp turn at high speed, because poorly tuned constants will cause you lose the line if you don’t react fast enough or overshoot if you react too strongly.

  2. I’m not sure I understand how a delay in your loop would allow for ADC settling. The voltages on the sensors are changing independent of your main loop. The QTR library code does everything necessary to accurately read the sensor voltage, so you can read the sensors repeatedly without any delays.

  3. The integral term is useful for situations where some external force is consistently working against you. For example, you would want to use the I term if you are programming a robotic hand to lift a weight to a specific height. Without I, it’s possible to settle on a steady-state situation where the error, E, is not zero due to the effect of gravity on the weight. Specifically, the system will settle to that value of E where P*E generates the proper motor power to compensate for the gravitational force of the weight. The I term acts to shrink E to zero over time by progressively increasing the motor power while E is not zero.

This is not really the situation you encounter when following a line. You could conceivably have some problems if your two motors are very poorly matched and want to make the robot drive in a tight arc when driven at the same duty cycle, but the net effect of leaving out the integral term is that the robot will follow the line off-center. If your robot looks like it’s centered over the line when following a straight segment, you don’t need to worry about the integral term, and I recommend leaving it off. Tuning three independent parameters is a lot harder than tuning two. In this case, the I term won’t get you much, and it can really hurt you if you pick a bad value for it.

- Ben