Find proportional, integral and derivative

How to use Ziegler-Nichols principles to tune PID loop controls.

By John A. Shaw

Process control refers to measuring a process variable, comparing it to some setpoint and manipulating the process in a way that keeps the process variable at its setpoint when either the setpoint changes or a disturbance changes the process. An example is shown in Figure 1. The temperature of the water leaving the heat exchanger is to be held at its setpoint by manipulating the flow of steam to the exchanger using the steam flow valve. In this example, the temperature is the measured or controlled process variable and the steam flow (or the position of the steam valve) is the manipulated variable.
Figure 1. A temperature-indicating controller maintains water temperature by converting a thermocouple reading into a steam valve position.
Figure 1. A temperature-indicating controller maintains water temperature by converting a thermocouple reading into a steam valve position.


Many algorithms can be used to control the process. The most common is the simplest: an on/off switch. Most appliances use a thermostat to turn on the heat when the temperature falls below the setpoint and then turn it off when the temperature reaches the setpoint. This results in the temperature cycling above and below the desired temperature, but it’s sufficient for most common home appliances and some industrial equipment.

Using mathematical algorithms that compute a change in the output based on the controlled variable achieves better control. Of these, by far the most common is known as the proportional, integral and derivative (PID) algorithm. Control loops contain:

  • A sensor to measure temperature, liquid level, pressure, flow rate or other variable, and convert the reading into a signal (typically 4 ma to 20 ma).
  • A control algorithm that calculates the output signal to be transmitted to the final control element.
  • A final control element that could be a valve, damper, motor speed controller or other device. It receives a signal from the controller and manipulates the process, for example by changing the flow rate of some material (Figure 2).
Figure 2. Interconnection of the control loop elements.
Figure 2. Interconnection of the control loop elements.

 Most control systems allow the operator to place individual loops into either manual or automatic mode. In manual mode, the operator adjusts the output manually to bring the measured variable to the desired value. In automatic mode, the control loop manipulates the output to hold the process measurements at the desired value.

Most plants start a process with all the loops in manual mode and then transfer them to automatic mode individually. Sometimes during normal process operation individual loops might be transferred to manual temporarily.

The PID algorithm

The most common algorithm (almost the only algorithm used in industrial process control) is the time-proven PID algorithm.

The PID control algorithm doesn’t “know” the correct output that brings the process variable to the setpoint value. The PID algorithm changes the output in the direction that moves the process variable toward the setpoint. The algorithm needs feedback (process measurement) to perform. If the path between the output and input is broken or limited, the algorithm has no way to “know” what the output should be. Under these (open loop) conditions, the output is meaningless.

The PID control algorithm doesn’t “know” the correct output that brings the process variable to the setpoint value.

– John A. Shaw

The PID algorithm must be tuned for the particular process loop if it’s to function in a stable manner. To tune a PID loop, one needs to understand each of the terms of the PID equation. The tuning is based on the process dynamics.

A controller’s action determines the direction of the output change that results from a change in the input. If a controller is direct acting, an increase in its input results in an increase in its output. With reverse action, an input increase results in decreased output. The controller action is always the opposite of the process action.

The first control mechanism, is called “proportional” or gain. In its pure form, controller output is equal to the error (difference between the measurement and the setpoint) times the gain added to a constant known as “manual reset.” This variable, subject to operator adjustment, is the output value when the measurement equals the setpoint.

O = e x g + k

Where:
O = output signal to the control element
e = error
g = gain
k = manual reset

{pb}
Figure 3. The positive feedback through the “lag” block causes the integral or “automatic reset” action. With the addition of automatic reset to a proportional controller, the positive feedback loop causes the output to ramp whenever the error is not zero. There’s an output limit block to keep the output within a specified range, typically 0 to 100%.
Figure 3. The positive feedback through the “lag” block causes the integral or “automatic reset” action. With the addition of automatic reset to a proportional controller, the positive feedback loop causes the output to ramp whenever the error is not zero. There’s an output limit block to keep the output within a specified range, typically 0 to 100%.

A change in the process measurement, the setpoint or the manual reset changes the output. If the process measurement, setpoint and manual reset are held constant, the output is constant. The manual reset can be replaced by automatic reset, a function that will continue to move the output as long any error persists (Figure 3).

The feedback loop is called reset, or integral action, a function that adds error integration. As long as the error is zero, controller output is constant. However, if the error is non-zero, the output continues to change until it reaches its limit. The rate of change is determined by the time constant of the lag, the amount of the error and gain.

The reset contribution is the gain times the reset rate times the error. If the error is zero, the output doesn’t change. If the error is positive, the output increases; if negative, it decreases.

Calculation of repeat time

Most controllers use both proportional action (gain) and reset action (integral) together. The equation for the controller is:

O = g x (e + Kr  ∫ e dt )

Where:
O = output signal to the control element
g = gain
Kr = reset setting (repeats per minute)
e = error

Figure 4. Reset action makes the controller output continue to increase while error remains constant.
Figure 4. Reset action makes the controller output continue to increase while error remains constant.

Consider the open-loop trend of a PI controller after forcing the error from zero to some other value and then holding it constant (Figure 4.)

There are two distinct effects of a change in the error. When the error changed, the output changed. This is called gain effect and is equal to the product of the gain and the change in the error. The second effect — the reset effect — accounts for the ramp of the output the error causes. If we measure the interval between when the error is changed and when the reset effect is equal to the gain effect, we’ll have a variable called the repeat time. Some control equipment measures reset as repeat time (or reset time or integral time) denominated in minutes or seconds. Others use repeats per minute, the inverse of minutes per repeat.

Derivative: the final variable

Derivative, the third and final element of PID control, responds to the rate of change of the process (or error). Derivative is normally applied to the process only. The derivative contribution can be expressed mathematically:

O = g x Kd x de/dt

Where:
O = output
g = gain
Kd = derivative setting in minutes
e = error

Figure 5. Output vs. error showing the effect of derivative over time. The derivative advances the output by an amount proportional to the derivative time.
Figure 5. Output vs. error showing the effect of derivative over time. The derivative advances the output by an amount proportional to the derivative time.

The open-loop response of a controller with proportional and derivative is shown graphically in Figure 5.

This diagram compares the controller output with gain only (dashed line) to the controller output with gain and derivative (solid line). The solid line is higher than the dashed line for the time that the process is increasing because the addition of the rate of change to the gain effect. We also can look at the solid line as “leading” the dashed line by some amount of time (td).

The length of time the derivative action advances the output is known as the derivative time and is measured in minutes. Major vendors measure derivative in minutes or in seconds. If we combine the three terms (proportional gain, integral and derivative), we obtain the complete PID equation.

Out = g(e + R + D)

Where:
g = Gain
e = error
R = Reset (repeats per minute)
D = Derivative (minutes)

This is a general form of the PID algorithm and is close to, but not identical to, the forms that industrial controllers implement. Figure 6 shows the generalized block diagram for PID control.

Figure 6. A process and instrumentation diagram (P&ID) might use this simplified version of the PID controller block diagram, which shows all three elements: gain, reset, and derivative.
Figure 6. A process and instrumentation diagram (P&ID) might use this simplified version of the PID controller block diagram, which shows all three elements: gain, reset and derivative.
{pb}

Loop tuning

Once a loop is configured and started, the PID control algorithm needs the correct gain, reset and derivative values for it to work correctly. But, how does one know when it’s tuned?

Loop performance falls between two extremes. The loop must respond to a change in setpoint and to process disturbances. Any error, or difference between the process variable and the setpoint, must eventually result in manipulating the output to eliminate the error. If the gain, reset and derivative are too low, response will be insufficient. The other extreme is instability, when a setpoint change causes the loop to start oscillating, and the oscillations persist. At worst, the oscillations grow (or diverge) and spiral out of control. Proper tuning allows the loop to respond to setpoint changes and disturbances without causing instability.

Ziegler-Nichols tuning methods

In 1942, J.G. Ziegler and N.B. Nichols, both of Rochester, N.Y., published a paper describing two control tuning methods that allowed the user to test the process to determine process dynamics. Because they are simple and provide adequate tuning, the methods of Ziegler and Nichols are still widely used.

The Ziegler-Nichols open-loop tuning method identifies the proper values for the assumed process model (gain, pseudo dead time and lag). For these loop tuning methods to work, the process must be lined out, that is, operating in a stable manner.

To use the open loop method, we must first determine the process dynamics. We can test the process by placing the controller into manual and making a small change in the process, with the process measurement recorded. The first parameter is Kp, or the process gain. That is the ratio of the change in the process measurement, in percent, to the change made in the output, in percent. The process time constant is the rate of change of the process, in percent per minute. The process dead time, Td, is the time between the change in the output and the first observable change in the process measurement, in minutes (Figure 7).

Figure 7. The process dead time is apparent from the lag between the step change in output and the process responding.
Figure 7. The process dead time is apparent from the lag between the step change in output and the process responding.

 

The gain, reset and derivative are calculated using the relationships in Table 1:

Algorithm Gain Reset Derivative
P  t/Td Kp    
PI 0.9 (t/Td Kp) .3/Td  
PID 1.2 (t/Td Kp) .5/Td .5Td
Table 1. Open-loop calculation of gain, reset and derivative.

Ziegler-Nichols closed-loop tuning

The closed-loop tuning method determines the gain that causes the loop to oscillate at constant amplitude. Most loops oscillate when the gain is increased sufficiently. The following steps are used:

  1. Place the controller in automatic mode with low gain and no reset or derivative.
  2. Gradually increase the gain, making small changes in the setpoint until oscillations start.
  3. Adjust the gain until the oscillations continue with constant amplitude.
  4. Note the gain (ultimate gain, Gu,) and period (ultimate period, Pu) as shown in Figure 7.

The ultimate gain produces the constant-amplitude oscillation, while the ultimate period is the oscillation period.

Figure 7. At the ultimate gain (Gu), oscillation amplitude will be constant at the ultimate period (Pu).
Figure 7. At the ultimate gain (Gu), oscillation amplitude will be constant at the ultimate period (Pu).


The gain, reset and derivative are calculated using the relationships in Table 2.

Algorithm Gain Reset Derivative
P 0.5 GU    
PI 0.45 GU
1.2/PU  
PID 0.6 GU 2/PU
PU/8
Table 2: Closed-loop calculation of gain, reset and derivative

           
John A. Shaw is resident of Process Control Solutions in Cary, N.C. More information about the PID algorithm, its implementation and its tuning can be found at www.jashaw.com. Contact the author at john@jashaw.com and (919) 882-8766.