• No results found

Although we have referred to computer or microprocessor-based control, our examples of PID control have so far used equations and block diagrams to illustrate only continuous form (Equation 5-1 and Figure 4-13, for example). Let us now consider how the form represented by Equation 5-1 would be implemented in discrete form for a digital computing control system (Ref. 5-2). The formulation for a digital device is called a control algorithm.

First, let us assume the following:

• That the algorithm is processed on a repetitive basis, say, every ∆Τ seconds. (∆Τ can be as short as 50 ms in some distributed control systems or as long as several minutes in some host computer-based systems. We assume that for a particular control loop in a particular system ∆T is constant.) We can speak of processing the algorithm at the nth processing instant and designate values computed at that instant with a subscript

“n”.

• That the process variable is sensed and converted either into engineering units or into a normalized value by a combination of hardware and software. On each processing cycle of the control algorithm the most recent value of the process variable, designated xn, is available to us.

That, likewise, the set point is available to us; this is designated SPn.

• That other variables, computed on previous processing cycles, have been saved in memory and are available to us. These are designated with subscripts “n-l”, “n-2”, etc.

In the automatic mode, a processing cycle begins by determining the error between set point and measurement:

en = SPn - xn if the controller is reverse-acting, or en = xn - SPn if the controller is direct-acting.

The next step is to approximate the integration operation of the continuous algorithm. Since integration computes the area under the curve, the integration operation can be approximated by a technique called box car integration, in which each discrete value of error is multiplied by

∆Τ, thus computing the area of a rectangle. The area of all rectangles are summed. Alterna-tively, as a new value of error is determined, a new sum of rectangular areas can be computed by adding the new rectangular area to the previous sum:

Sn = Sn-1 + ∆T en . (5-26)

The term Sn is equivalent to the integral of the error up until time n.

While this series of steps is conceptually sound, it is equally valid and more convenient to sim-ply sum up all past errors, then multisim-ply the resulting sum by ∆Τ in a later operation:

Sn = Sn-1 + en . (5-27)

The differentiation operation can be approximated by a discrete differencing, for example:

It is equally valid and more convenient, however, to compute merely the difference between the present and previous error, then divide by ∆Τ in a later operation.

We are now ready to compute the controller output value at time n:

(5-28)

Equation 5-25 is the discrete counterpart of the standard PID equation written in continuous form in Equation 5-1. Because this equation computes the position of the final control element, it is usually called the position form.

It is sometimes desirable to calculate the increment by which the controller output should change rather than the actual output itself. The increment of change is given by:

∆mn=mn – mn–1

This expression is not a valid way to calculate ∆mn, however, since we know neither mn nor mn–1. We need an equation for calculating ∆mn directly. We first write an expression for mn–1, similar to Equation 5-25, except all the subscripts are decreased by 1:

(5-29)

Now make a term-by-term subtraction of Equation 5-29 from Equation 5-28, using Equation 5-27 to compute Sn – Sn-1:

(5-30)

This equation is also a discrete counterpart to the continuous form of the standard PID, Equa-tion 5-1. It calculates the incremental change in controller output over a time period ∆Τ, and is often called the incremental or velocity mode form.

All the modifications to the standard form of the PID mentioned earlier in this chapter are also applicable to both the position and the incremental forms of the discrete PID. For example, the incremental form of the PID, which has modifications that place both the proportional and derivative on measurement rather than error, is as follows:

(5-31)

The incremental form calculates the required change in controller output or valve position. It depends upon some other hardware or software provision to “remember” the last actual posi-tion of the controller output or valve posiposi-tion. In the following paragraphs, we will describe a very common way of achieving this.

For many microprocessor-based systems, a control strategy is configured by a series of soft-ware function blocks. Many times, these function blocks are the counterpart of hardsoft-ware mod-ules in an analog control system. Just as a set of hardware modmod-ules require interconnections (through wiring or pneumatic piping) to form a complete control system, so a set of software function blocks also requires interconnection. This is often called “softwiring.”

Figure 5-14 shows a simple feedback loop in which the microprocessor-based control portion consists of three function blocks:

An analog input (AI) function block that causes an analog-to-digital (A/D) converter (hard-ware device) to convert the incoming sensor signal (say, 4–20 mA) into an analogous value that may be in engineering units or a normalized signal (say, 0 to 100% of transmitter range).

This value is deposited in a memory register that can be considered as a part of the AI function block.

A control function block (PID) that obtains the measurement value from the AI block, com-pares this with the set point, then executes a discrete form of PID algorithm (Equation 28, 5-30, or a form containing any of the modifications), and calculates either the required controller output or change in controller output.

An analog output (AO) function block that obtains from a memory register the required posi-tion of the valve or other final control element. This value (0 to 100%) is converted by a digital to-analog (D/A) converter (hardware device) into a signal (say, 4–20 mA) to the valve.

Figure 5-14. Typical Control Loop Hardware/Software Structure 7,B

$,

39 63

3,' 7&B

$2 79B

77



$6 326

$1$/2*,1387 )81&7,21%/2&.

3,'&21752/

)81&7,21%/2&.

$1$/2*,1387 )81&7,21%/2&.

0(025</2&$7,216 86(')25 ,17(5%/2&.

'$7$75$16)(5

)81&7,21%/2&.7$*6 6+2:1)25(;$03/(21/<

writes the old value in the memory register referenced by the AO block. If the PID algorithm is an incremental type, it calculates the required change in valve position and adds this change to the current value in the memory register. In either case, the AO block has a new value at which to reposition the valve or other final control element (see Figure 5-15). In normal operation, both the position and incremental algorithm forms produce essentially identical behavior in the control loop. Hence there is no technical advantage to the user of one form over the other.

However, from the viewpoint of the software implementer, it is easier to deal with certain situ-ations such as manual/automatic switching and tuning parameter changes using the incremen-tal form. Hence, many microprocessor-based control system vendors use this form.

Dealing with abnormal situations involves additional communication between function blocks.

Figure 5-15. Position and Incremental (Velocity) Mode Algorithms

other function blocks recognize and act upon. The exact features and details of implementation are specific to each vendor, but the following features are fairly common:

When the PID block is switched from automatic to manual, it simply stops calculating its incremental change. The position of the final control element remains at its last value. Thus, bumpless transfer from automatic to manual is inherently achieved.

The lower-level block (the AO block in the preceding example) will probably have limits beyond which the upper-level block cannot change the value of the required valve position.

This is analogous to setting output limits of 4 mA (0%) and 20 mA (100%) on an analog con-troller output. These limits are user adjustable.

Because there is no memory register within the incremental algorithm that is acting like an integrator, there is no windup within the algorithm itself. However, if an external influence interrupts the control loop (say, a sticking valve), then the memory register that communicates with the AO block can wind up to its limiting value.

The PID block may impose a limit on the absolute value of the incremental change. Thus, the user may set with certainty the maximum rate of change of the final control element. (If the loop is well behaved, this limit will only be exercised infrequently. This limit should not be used to determine normal loop behavior in lieu of adequate tuning of the PID itself, as the author witnessed at one installation.)

Possibly the original reason the incremental form of the PID was developed was for control functions that resided in a central computer that directly determined valve positions. (This is known as direct digital control, or DDC.) To prevent the loss of many (perhaps several hun-dred) control loops during computer failure, the “memory” of the last valve position was con-tained in an external device, such as an electrical stepping motor. The PID controller in the computer calculated an incremental change in required output. This incremental change was transmitted to change the position of the external stepping motor; the stepping motor position was then converted into a signal that positioned the final control element. In the event of com-puter failure, there were no further changes to the stepping motor, hence the loop was said to fail to a “hold-as-is” condition.

™ INCORPORATING ENGINEERING UNITS IN CONTROLLER