Your automation controller — Powerful, Tailored, Supported.

## Adjusting PID Gains - Tutorial by Thomas Bullock

The BULL! column in the March 1991 issue of Motion Control explained PID and showed the Bode diagram (open loop gain as a function of frequency) for it. A number of users of PID have indicated that they have difficulty adjusting the gains (KP for the proportional gain, KI for the integral gain, and KD for the differential gain). This reminds me of the golfer on the first tee whose first three swings resulted in nothing but air and whose fourth swing dribbled down the fairway. He turned to his friends and said, "This is a difficult course, isn't it?" It was only difficult because he didn't understand the basics and hadn't practiced them.

This month's column will concentrate on the basics- what happens when you adjust each of the three factors? It will still take some practice to do it well and quickly — and you may never become a 300 yard hitter, but your score will improve dramatically!

Two Bode diagrams from the March issue will be used to help gain a picture of what happens when each of the factors is adjusted. The first Bode plot to be used is of the PID network by itself. Later, a Bode diagram of the total loop gain incorporating the motor (which is also an integrator) will be shown.

The PID network is shown below illustrating the effect of changing only the proportional factor (KP). As can be seen, increasing KP not only increases the midfrequency range proportional factor, but also lowers the frequency at which the integration factor ceases effectiveness and raises the frequency at which the differential factor begins to kick in. The effect of lowering KP is also illustrated.

Changing the integration factor (KI) has the impact shown below. Not only does it affect the low frequency gain, but it changes the frequency at which the proportional factor (KP) becomes effective. It would be most desirable to raise KI as high as possible, but the higher it gets, the more negative a phase shift is introduced in the proportional range where the servo bandwidth normally ends up. This reduces the phase margin of the servo, causing overshoots and ringing as described in an earlier column.

Increasing the differential gain (KD) lowers the frequency at which it has more impact than the proportional factor (KP). This introduces positive phase shift in the proportional range to help offset the negative phase shift from the integration factor KI, thereby improving the phase margin and reducing the ringing. It has the undesirable effect, however, of increasing the high frequency gain, making the servo more noise sensitive and encouraging the undesirable effects of natural resonances.

Now that one can "see" the impact of changing each of the gain factors, it is important to have a procedure to follow when working with them all together.

The Bode diagram below, taken from the March 1991 column on PID, shows the loop gain with the PID plus the integration resulting from the motor. It also shows the effect of increasing each of the three PID gain factors.

The adjustment procedure that seems most logical is first to reduce KI and KD to their minimum values so that KP and thus the servo bandwidth (O DB crossover frequency) can be set with no influence from the integrator or the differentiator. This KP factor should be set about 30% below the adjustment where instability occurs. Next raise KI until the servo is just below instability, then increase KD to improve the phase margin and system stability. This can be done by repeatedly making about a 30% increase in KD, and then adjusting KI to see if it is still on the edge of instability. When KI no longer appears on the edge of stability, round 1 of the procedure is complete. Now, again increase KI to the point just below instability and again increase KD as before while "testing" KI. This time, when satisfactory operation occurs, the adjustment is complete.

The strategy behind this procedure is first to set the bandwidth for a normal, naked loop without compensation. Once this is done, it is desirable to raise KI as high as possible to approach a type 2 system with two integrators. KI is set as high as is dared and then the positive phase margin from the differential factor is introduced to restore stable operation. This technique is repeated to "tighten up" the proportional gain frequency section. It does not pay to continue to try to optimize since it is too easy to lose the "vision" and balance between KI and KD.

It seems that every time I get my golf game in balance, I start trying new things to make it even better and end up hacking instead of golfing. It usually requires going back to the basics to once again achieve that balance.

When you adjust your PID, remember the basics, keep a vision of what is happening, and maintain a balance.