A Self-Testing PID Loop
This note offers a new kind of solution for the ongoing problem of online monitoring and tuning of PID loops.
There are reasons why some of the control techniques discussed in other pages on this site are not always appropriate. Sometimes, PID controls are a devil known while other techniques are a devil unknown. That is, whatever the appeal of finding something better, the costs of changing and being wrong are too high. In many other cases, PID controls have already proven themselves to be perfectly adequate, and, given that they are perfectly adequate, nothing more complicated is justified.
For whichever reason, when PID controls are the strategy of choice, it is still true that conditions can change. Staying "well tuned" is very important. Poorly tuned loops can have a significant economic impact.
A Disturbance in the Force
One of the most basic strategies for evaluating loop tuning involves measuring loop gain and phase shift as a function of frequency. Unfortunately, it is not possible to measure frequency response if frequencies are not present to measure. If natural disturbances are not present, artificial disturbances must be introduced.
Considerations when performing a loop response test:
While the PID control itself might be simple, the amount of effort to support response testing can be very high. The goal of the self-testing PID control is to make this much easier, by integrating important parts of the testing and data pre-processing into the controller itself. For a DAP-based control:
Excitation Signals for Test
To measure frequency response, it is necessary to compare the output at a given frequency to the excitation input at that same frequency. Conventional practice does a generally bad job of exciting all of the frequencies in the relevant band. To explain this statement, it is first necessary to consider what "the relevant band" is, with respect to a PID control loop. Nyquist's criterion says that a signal cannot be reconstructed unless there are at least two samples per cycle for the highest frequency present in the signal band. But most digital implementations of PID controllers do not use the elaborate interpolation filters necessary to reconstruct a signal from sparse sample sequences. What is done in practice?
Using a simple first-order hold, it is highly desirable to have 10 or more samples along each quadrant of the waveform.
We also do not want abrupt jerking responses from the system. We expect the controlled plant to have a lowpass characteristic so that any small step-edges are smoothed out. (For one thing, if the plant does not have a lowpass characteristic, the ordinary tuning rules do not apply.) This means that frequencies much more than 10% of the Nyquist limit also are not desirable in the system output signals. If the loop response exhibits high levels of signal energy in at higher frequencies, the sampling rate is probably too low.
Given this information, consider the "industry standard" with regard to PID loop tests. In describing the advanced version of their loop-test software, the ExperTune Web site  shows the following list of choices for tuning excitation signals.
This is a quite good coverage of the test signals actually employed in practice. Let's assess the relative strengths and weaknesses.
Step response tests have some serious drawbacks. A step edge introduces broadband excitation, but the edge that excites high frequencies is very short duration. A short time duration means poor frequency resolution. A step test results in a long term level disturbance in the process, which can be a problem when testing online.
Pulse response tests first apply and then remove a large command displacement. Because the disturbance is not sustained for very long, the magnitude of the disturbance can be larger, reducing the long-term displacement of the operating state. In higher frequency bands, there is a rough doubling of the excitation energy because of two transitions rather than just one. However, the short-term excitation must be large to see much response at lower frequencies. A large disturbance can sometimes have unacceptable side effects.
Doublet response tests, in effect, are pulse tests split into two parts, a hard knock in one direction, followed by a hard knock in the other. The offsetting knocks will not upset the process level as much, so they can be larger, while providing more broadband disturbance energy. This is an improvement for online testing because of less net displacement in the operating state of the running process, but it has the same problem of high-energy disturbance like the other impulse test methods.
Random excitation tests provide an alternative that excites the system response over a wide band. White noise distributes energy equally at all frequencies — at least in the limit it does. As we have just seen, this means that the great majority of the disturbance energy is in the wrong bands and not helpful. But worse, the results of random noise tests are — well, very random. While the band coverage is pretty good, the variances in the results can be quite awful.
Rather than exciting everything, the Microstar Laboratories self-testing PID controller provides a built-in disturbance signal generator that excites only the frequencies that you need, in a manner almost free of random noise. Because it is non-random, and has an exactly known energy at every frequency, it produces repeatable results.
The test signal has some highly desirable properties:
Because the injection signal is predetermined, computing the magnitude/phase response is extremely simple. The system is operated at a steady command level. A signal is injected at an appropriate location in the loop, added to the signal already present in that path. A block of response data is collected, and an FFT analysis is applied. The system is in quasi-steady state, hence frequencies other than zero are the result of the test excitation, plus whatever small amounts of noise are present. For the relevant frequency band, the ratio of response amplitude to (constant) excitation amplitude determines gain. The difference between the output phase angle and the (predetermined) excitation phase angle determines phase response.
It might first appear that injecting a disturbance signal into the plant control input and monitoring the plant output would yield the open loop response of the plant, riding on top of a constant level. This is not true, however, because it does not take into account signal propagation around the closed loop. Consider the following diagram with PID controller C and plant P.
Tracing the signals around the loop, we will find that the two transfer functions of interest are:
Skipping a lot of mathematical details, we can derive from the two injection experiments the command transfer function, the output rejection function, and the plant open loop transfer function. The latter characteristic is of special interest, because it indicates the critical frequency for stability in closed loop operation. These response curves are the delivered results.
"Okay, I have transfer characteristics. Now what?"
Unfortunately, the rest of the story is not pretty. Nyquist's stability criterion says that the system is at the margin of stability if the loop gain is 1.0 at a phase shift of 180 degrees. That's all very fine, but you don't want to operate at the ragged edge of instability. First, you must reduce the gain to provide a suitable stability margin. Then, you can apply integral correction to reduce tracking errors and improve rejection response, and derivative correction to improve the phase margin. Qualitatively, this all makes sense. But quantitatively...
That's where the tuning rules come in. If you employ the usual fixed rules, they are based on assumptions that the system is well approximated by a first-order lag (to approximate the lowpass roll-off characteristic) and a pure time lag (to approximate phase shifts due to higher-order effects). If these assumptions don't apply, the rules won't help you much. So assume that the rules work well enough. The tuning rule that you apply will prescribe how to set the PID gains as a compromise between stability, responsiveness and noise rejection.
For example, determine from the plant phase curve the frequency
at which the phase shift is 180 degrees. The inverse of that
critical frequency is defined as critical time
K = 0.6*Ku Ti = 0.5*Tu Td = 0.125*Tu
This rule was devised with continuous controllers in mind. In discrete controllers, it tends to excite high frequencies too much. It also tends to produce a nasty overshoot in response to setpoint changes. The "some overshoot rule" will track changes to the setpoint somewhat better, while not rejecting disturbances as well:
K = 0.33*Ku Ti = 0.5*Tu Td = 0.33*Tu
See the paper cited below  for a survey
of candidate tuning rules. Do these rules work well? No, not really.
But what else are you going to do? That, it seems, must be a topic
for another day. If you know from experience how to use the curves
to find good gain setting for your particular system, apply your
experience. You might also find that the zero-shaping parameter of
The self-testing features have been integrated with the
The self-testing process requires three additional command parameters for configuration.
You might have wondered: with all of the DSP analysis and data transport activity going on, wouldn't that extra computation interfere with updates of the PID loop, making the controller response erratic, possibly even resulting in loss of loop control? If this didn't trouble you, it should have. It is not a problem, however. Blazing speed is what DAPs are all about. The FFT computations are completed in a fraction of a millisecond. That means, as long as the update intervals are one millisecond or longer, control updates are never missed, and never late, not even during the most intense parts of the data analysis. Your system will never lose synchronization, and never lose data.
With the above understanding, it might still be true that the results are better than anything previously available. If you would like to obtain a copy for test and evaluation, go to the download page on this site.
Observations and Conclusions
The payoff for using Data Acquisition Processor (DAP) boards in control applications comes when you can take advantage of the extensive additional capabilities that the DAP has to offer. DAP boards were originally intended for data capture and real-time data analysis, with control applications secondary. This can also go the other way. DAP boards can also be used effectively for reliable and flexible control applications, with the data capture and real-time analysis as secondary features.
The DAP itself is a measurement instrument and a sophisticated
signal generator. In effect, a control loop driven by a DAP is
already fully instrumented and ready to test at any time, on
We have been referring to sampling rates on the order of 1000 updates per second, but there are many systems for which PLC update rates of 60 times per second are considered screaming fast. Whether processing is for one loop updated 1000 times per second or 16 loops updated 60 times per second makes no difference to the DAPL system.
Finally, we can note that independent DAP-based controllers for multiple loops would reside in an industrial PC host, such as the Microstar Laboratories DAPserver. The host can then act as a communication hub. Study of the response data, decisions about changing loop gains, data logging, and observation of process change over time – these can all be done from a remote location, without taking systems offline.
Footnotes and References: