The PID Algorithm

This page was last revised 29 June, 2000

There is no single PID algorithm. Different fields using feedback control have probably used different algorithms ever since math was introduced to feedback control. This Web page (a single file, of four pages, no pictures) is written for people in the process industries, for that is the only field in which I (David W. St. Clair) have experience. Even in that single field, which has been served by companies such as ABB (formerly Taylor), Bailey, Fisher, Foxboro, Honeywell, Moore Products, Yokogawa and others there is no standard algorithm. Perhaps years ago there was (or for most practical purposes was), but today there are many algorithms. Also there is no standard terminology. For the person interested in tuning controllers for the process industries it has become a bit more complicated, because the rules and procedures you would use to tune with one algorithm are not the ones you would use to tune with another. Also, with the added features available with computers, some of the configurations can become quite complex. This page does not begin to address those, but you certainly need to understand what your basic building block is.

The purpose of this Web page is to focus on the fact that there are differences and to describe them (or at let to alert you to look for them). No reference to the algorithm of specific manufacturers is given. If you are tuning controllers you must know the algorithm of the equipment you are using. For that you should read the information provided by the manufacturer. Even the words used to identify an algorithm are ambiguous. You should look at the equation. This is unfortunate because many persons assigned the responsibility of tuning process industry controllers are not comfortable with equations. If you are reading this as preparation for writing a PID algorithm, it will alert you to the fact that there is more to it than you might have thought. Indeed, the feedback I have from knowledgeable people is that even the experts can slip up.

I have asked several friends and acquaintances to review this write-up before (and after) putting it on the Web. This does not necessarily mean they agree with what I have written (some discussions are still taking place), but at least I have sought their advice. I hope it has no mistakes in it. If you feel you have something to contribute in the way of corrections or additions, please write me. I have nothing to sell by providing this page, except better control and hopefully less confusion.

Presently there are three basic forms of the PID algorithm. These will be discussed in turn. After that there is a short discussion of other aspects of any algorithm which must be considered to write the digital program for one. A section on references and links is at the end.

Expressed by their Laplace transforms the three forms are:

First form: Kc(1 + 1/Tis)(1 + Tds)/(1 + Tds/Kd)
Second form: Kc'(1 + 1/Ti's + Td's)
Third form: Kc" + 1/Ti"s+Td"s

where

Kc, Kc' and Kc" relate to the P part of PID
Ti, Ti' and Ti" relate to the I part of PID
Td, Td' and Td" relate to the D part of PID
s is the Laplace notation for derivative with respect to time
Kd is the derivative gain

I have deliberately not assigned a name to any of these forms yet. Also I have not given a name to the variables. Both will come later as each algorithm is discussed. The second and third forms can be made equivalent to the first form (provided derivative is handled appropriately), but the first form cannot duplicate all combinations available in the second and third forms. The second and third forms can be made equal to each other. For most practical purposes one algorithm is not better than another, just different.

THE FIRST FORM OF THE PID ALGORITHM

This first form is called "series" or "interacting" or "analog" or "classical". The variables are:

Kc = controller gain = 100/proportional band
Ti = Integral or reset time = 1/reset rate in repeats/time
Td = derivative time
Kd = derivative gain

Early pneumatic controllers were probably designed more to meet mechanical and patent constraints than by a zeal to achieve a certain algorithm. Later pneumatic controllers tended to have an algorithm close to this first form. Electronic controllers of major vendors tended to use this algorithm. It is what process industry control users were used to at the time. If you are unsure what algorithm is being used for the controller you are tuning, find out what it is before you start to tune.

I did not follow closely the evolution of algorithms as digital controllers were introduced. It is my understanding that most major vendors of digital controllers provide this algorithm as basic, and many provide the second form as well. Also, many provide several variations (I'm told Allen-Bradley has 10, and that other manufacturers are adding variations continually).

The choice of the word interacting is interesting. At least one author says that it is interacting in the time domain and noninteracting in the frequency domain. Another author disagrees with this distinction. This really becomes a discussion of what interacts with what. To be safe, think of the word interacting as one to identify the algorithm, not to describe it.

SECOND FORM OF THE PID ALGORITHM

The second form of the algorithm is called "noninteracting, or "parallel" or "ideal" or "ISA" . I understand one manufacturer refers to this as "interacting", which serves to illustrate that terms by themselves may not tell you what the algorithm is. This form is used in most textbooks, I understand. I think it is unfortunate that textbooks do not at least recognize the different forms. Most if not all books written for industry users rather than students recognize at least the first two forms. The basic difference between the first and second forms is in the way derivative is handled. If the derivative term is set to zero, then the two algorithms are identical. Since derivative is not used very often (and shouldn't be used very often) perhaps it is not important to focus on the difference. But it is important to anyone using derivative, and people who use derivative should know what they are doing. The parameters set in this form can be made equivalent (except for the treatment of gain-limiting on derivative) to those in the first form in this way:

Kc' = ((Ti +Td)/Ti))Kc, "effective" gain.
Ti' = Ti + Td, "effective" integral or reset time
Td' = TiTd/(Ti + Td), "effective" derivative time

These conversions are made by equating the coefficients of s. Conversions in the reverse direction are:

Kc = FKc'
Ti = FTi'
Td = Td'/F

where

F =0.5 + sqrt(0.25 - Td'/Ti')

Typically Ti is set about 4 to 8 times Td, so the conversion factor is not huge, but it is important to not loose sight of the correction. With this algorithm it is possible to have very troublesome combinations of Ti' and Td'. If Ti'<4Td' then the reset and derivative times, as differentiated from settings, become complex numbers, which can confuse tuning. Don't slip into these settings inadvertently! A very knowledgeable tuner may be able to take advantage of that characteristic in very special cases, but it is not for everyone, every day. Some companies advise to use the interacting form if available, simply to avoid that potential pitfall.

This algorithm also has no provision for limiting high frequency gain from derivative action, a virtually essential feature. In the first algorithm Kd is typically fixed at 10, or if adjustable, should typically be set somewhere in the range of 6 to 10. This desirable limiting of the derivative component is sometimes accomplished in this second form by writing it as:

Kc'(1 + 1/Ti's + Td's)/(1 + Td's/Kd)

or

Kc'(1 + 1/Ti's + Td's/(1 + Td's/Kd))

There are likely many variations on the theme.

The variables Kc', Ti' and Td' have been called "effective". In the Bode plot, IF Ti'>4Td', THEN Kc' is the minimum frequency-dependent gain (Kc is a frequency-independent gain). This is at a frequency which is midway between the "corners" defined by Ti and Td, which is also midway between the "effective " corners associated with Ti' and Td'. Ti' is always larger than Ti and Td' is always smaller than Td, which recognizes the slight spreading of the "effective" corners of the Bode plot as they approach each other.

This algorithm is also called the "ISA" algorithm. The ISA has no association with this algorithm. Apparently this attribution got started when someone working on the Fieldbus thought it would become "THE" algorithm. It didn't. Or hasn't. ANSI/ISA-S51.1-1979 (Rev. 1993) is a standard on Process Instrumentation Terminology. While this is a standard on terminology, not algorithms, it uses the first form of the algorithm for examples and in its Bode plot for a PID controller. Another term used to identify this algorithm is "ideal". Think of this word as one to identify the algorithm, not describe it. It is true that it can do everything the first form can do, and more, provided the gain for derivative is handled appropriately. But settings which produce complex roots should be used only by the very knowledgeable.

THIRD FORM OF THE PID ALGORITHM

It is hard to know what to call this third form since it is so close to the second. It has been called "parallel", "ideal parallel", "noninteracting", "independent" and "gain independent". In one sense this third form is the second form rewritten. I understand this is the algorithm taught Electrical Engineers. The second and third forms can be made equal to each other by using the following substitutions:

Kc" = Kc'
Ti" = Ti'/Kc'
Td" = Kc'Td'

They would only differ in what you call the tuning parameters. They are not gain, integral time and derivative time as those words are traditionally used in this field. Also, the option for limiting the gain from derivative action should be handled somehow, perhaps the same way as for form two. One option is as follows:

Kc" + 1/Ti"s + Td"s/(1+Td"s/K"d)

The constraint in the second form that Ti'>4Td' to keep the roots real becomes Kc"Ti">4Td"/Kc", which is a bit more complicated.

PROGRAMMING CONSIDERATIONS

There are many considerations in writing the program for a controller besides the decision on which basic algorithm to use. These include:

  1. The option to have the derivative function act only on the process variable, not on set point changes.
  2. The same option with regard to the proportional action. This option may be tied to the first, in that if you choose to have derivative act only on the process variable you get proportional action only on that also.
  3. Provision for setpoint and process variable tracking, to permit bumpless automatic/manual transfers. You can have bumpless transfers without setpoint tracking. You can also transfer from manual to automatic without any bump due to proportional action. Aren't all these options wonderful!
  4. Provision for reset windup protection.
  5. Provision for a filter besides the one used to limit the derivative gain.
  6. It is no simple matter to get digital derivative action to approach the quality of analog derivative action. No program can match it. This space is not intended to amplify on that problem, but simply to emphasize that it is a problem. It relates to sampling frequency and noise on the signal. Some algorithms use more than one back value of the controlled variable I believe. Also some manufacturers limit how low a derivative time may be set. It is very difficult for the user to know whether the derivative provided is doing a good job of achieving what could be achieved with derivative action.
  7. Integral/reset action with digital controllers is not perfect. There is a phenomenon related to quantizing error, sampling time and long integral/reset times and calculating precision which prevents integrating to zero error. Apparently with more digits in the A/D converter and in the computer's math, this is becoming less and less of a problem.
  8. There is the choice of having the algorithm be "velocity", sometimes called "incremental" (each calculation period a change in the output is calculated), or "position" (each calculation period the actual desired output is calculated). Apparently at one time there was a perception that the velocity algorithm did not have a reset windup problem, but this is not the case. The choice between the incremental and position algorithms seems to be a choice based on many considerations which are beyond the scope of this write-up.
  9. There are options on filtering noise, such as providing a dead zone or a zone of low gain around the setpoint.
  10. There are options to be considered in special cases, such as preventing reset windup in override and cascade situations.
  11. Provision needs to be made for manual bias.
  12. There must be other points to make to caution the novice. Does anyone want to suggest some?

REFERENCES AND LINKS

(NOTE TO READERS. If you want to contribute to this, please write me.)

I am aware of two Web sites that have information on the subject.

  1. One is a copy of John Gerry's 1987 Control Engineering article.
  2. Another is an offering by John Shaw.

Appendix K in Tuning and Control Loop Performance: A Practitioner's Guide, 3rd Edition, Revised, by G. K. McMillan, published by ISA, 1994 not only delineates the problem but gives a table of algorithms used by different manufacturers. I understand this appendix was written by Dave Ender of Techmation. It is reported to have a few errors and is not up to date, especially for Allen-Bradley.

Persons interested in tuning controllers might want to look at a companion web page, which describes a booklet Controller Tuning and Control Loop Performance, a Primer.