333
CHAPTER
9
Programming
Languages
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
SECTION
3
PLC
Programming
The square root instruction is useful in applications like the calculation of
flow rate from a differential pressure (DP) orifice flow meter (see Figure 9-
76). In this application, the flow rate (Q) is equal to a constant (K) times the
square root of the differential pressure (∆P
A
= P
out
– P
in
). The analog input
value from the DP flow meter must have its square root value extracted and
then multiplied by the constant. The resulting value will give the volume per
unit time (ft
3
/min) of the flow. Chapter 13 further discusses differential
pressure transducers and their measurements.
registers. In this case, the destination registers are register 2000, which holds
the integer part of the result, and register 2001, which holds the decimal
fraction part. Depending on the controller, the second result register may hold
the remainder instead of a decimal fraction. Some controllers also allow a
scaling factor to be specified in a division block. This scaling factor permits
fractional results, which would otherwise be lost, to be scaled and stored in
a register.
Depending on the PLC used, a division block can have three possible outputs.
When energized, the top output generally represents a successful division, the
middle output represents an overflow or error (divide by zero), and the lower
output indicates whether or not the result has a remainder.
SQUARE ROOT—BLOCK
Figure 9-75. Square root functional block.
A square root (SQR) block instruction generally has two or three registers—
one that holds the value to be operated on and one or two other registers that
hold the result of the square root operation. One of the result registers may
hold the integer part of the result while the other holds the fractional part. The
processor may also provide scaling. Once the control rung has continuity, the
square root operation takes place. Of the possible block outputs, the first one
represents a successful or valid operation, nd the second one indicates an
overflow condition. Figure 9-75 illustrates a square root block instruction.
Reg 1000
Reg 2000
2001
Reg: 1000 = 120
Square root result = 10.9544
Reg: 2000 = 10 (integer)
Reg: 2001 = 9544 (decimal fraction)
Overflow
Enable
SQR
Control