Data Acquisition (DAQ) and Control from Microstar Laboratories

Knowledge Base: Control

  • See the list of other topics for category Control

Q10070 Tuning PID loops

Tags: Help, DAPL, PID, PID1, processing, tuning, control loop

Applies to: All DAPL versions and DAP models supporting analog outputs

There are lots of competing ideas out there about how to tune PID control loops. Is there a way to do it that is best for the PID commands in the DAPL system?

The many ideas about how to best tune PID loops arise much more from unknown characteristics of the controlled system than from the PID implementation. All of the competing views are correct, in the right context. A good strategy that works for one system will be a bad strategy for another. It is worth experimenting to find out what works best for you and your system, then follow this scheme consistently. If you don't know where to start, here are some ideas.

PID control gains are sometimes implemented in a "parallel form" with the P, I, and D gains applied independently, sometimes in a "normalized form" that expresses the parameters as a feedback gain, integral time constant, and derivative time constant. You can think of these two parameter sets as being equivalent, so they are both referred to as "PID gains" here. Just be careful about the initial value you use for the I-gain term. If your PID command has parallel form parameters, the I-gain term is a multiplier, and the larger the multiplier the larger the effect. But in the integral time constant form, a very long response time corresponds to a low gain, so you should start with a large parameter value. This can seem backwards at first.

First, pick the update time interval of your discrete-time controller such that it takes 25 to 50 samples to span the upward transition for a typical step response. You might not have an accurate idea of what this timing is — then take your best guess, and adjust it as soon as you have new information that the transient response is significantly slower or faster. If the update time intervals are too fast, the derivative processing see lots of noise but not enough local change to produce a helpful response. But if the update time is too slow, the response delay becomes a problem, degrading stability, and the output levels become choppy.

Start with the I-gain and D-gain terms at zero, and P-gain at a low level, for example 1.0. Start increasing the P term carefully, looking for the level at which the loop starts to respond with a sustained oscillation — the stability limit. Do not be concerned at this point about the level at which the system output stabilizes. Using the classic "Ziegler-Nichols" tuning rules as a guide, set the P-gain to about 35% to 65% of the limiting P-gain you found. Use a lower value if it is more important to avoid overshooting, a higher value if it is more important to correct faster while allowing some overshoot.

If the limiting gain is high (20, 40, 100, ?) your system has high natural damping, and loop tuning should be easy. If the limiting gain is moderate (6, 10,...?) you have secondary high-order behaviors to avoid. If this gain is low (0.25, 0.5, 2.0, ?) your system acts a lot like an integrator or an undamped oscillator, dissipating excess energy very slowly, and even with very low feedback gains you might never get fully satisfactory results.

The next thing to do is to start increasing the I-gain term, seeking to reach the target output level in an acceptable time. The integral will oppose the natural damping of the system. When you get to the point that there is about 20% overshoot, make a note of this setting. Observe how long it takes to settle within a few percent of the desired level after a disturbance.

Now start increasing the D-gain term. For naturally well-damped systems, it might not make any significant difference, then leave it at zero. Otherwise, one of two other things could eventually happen:

  • If the D-gain completely cancels out all tendency to oscillate, and more, you will see a sluggish response that delays the settling time, so drop the D-gain back an appropriate amount.
  • If you start to see poorly damped oscillations or high sensitivity to fast low-level noise disturbances, drop the D-gain back to about 1/2 of its current level.

Now the optimization begins. Starting from these settings, follow the same general sequence as before, but taking smaller adjustment steps. First, adjust the P-gain term, perhaps 5% up or down. Then adjust the I-gain term slightly looking for better settling time given the new selection of P-gain. Finally, adjust the D-gain. If you can find a D-gain setting that gives you acceptable damping and overshoot, use this tuning. If you can't find consistent settings this way, back away from the attempted optimization changes.

Keep in mind that some systems "change characteristics" over time. For example, systems might have higher friction losses when "running cold" rather than "warmed up," or they might be subject to loading variations that change the natural frequencies and their interaction with the control loop. You might need to reduce gains to a safer but somewhat slower setting to get acceptable performance through the entire range of variation — robustness. "System variability" can be hard to predict, which is one of the things making PID loop monitoring and tuning a challenge.

L16706

For more information about PID and feedback controls in DAP systems, check the feature articles in the Controls Page.