A DDITION —B LOCK

A DDITION —B LOCK

An addition (ADD) functional block adds two values stored within the controller and places the sum in a specified register. The operand values can

be fixed constants, values contained in I/O or holding registers, or variable numbers stored in any memory location. Figure 9-62 illustrates a typical addition functional block.

ADD

Enable or DoweOutput

Control

Reg 1000

+ Reg 1001 = Reg 2000

Storage Area

Reg 9 7 3 1000

Contents in BCD ADD

10 To control other logic

Figure 9-62. Addition functional block.

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC Programming C HAPTER 3 Programming

Languages 9

A control line enables the operation of an addition block. When the rung conditions are TRUE, the processor performs the addition function. In the block shown in Figure 9-62, register 1000 and register 1001 can be preset values, storage registers, or I/O registers. Each time an OFF-to-ON transition enables the control line, the instruction adds the values in these two registers and places the result in register 2000. The done, or enable, output coil indicates that the operation has been completed. This output remains ON as long as the control line is TRUE. An overflow of the addition operation energizes the overflow output of the block. If the operation overflows, some PLCs will clamp, or store, the results at the maximum value that the register can hold. Others will store the difference between the maximum count value and the actual overflow value.

Some controllers use double-precision addition when working in block format (see Figure 9-63). This operation is identical to simple ladder addition, but the PLC uses two registers each to hold the operands and two registers to store the result.

+ Reg 1001 = Reg 2000

19,999,998 Figure 9-63. Double-precision addition block.

In Figure 9-64, two ingredients are added to a reactor tank for mixing. Analog input modules, which provide 12-bit information in BCD, send data about the two ingredients’ flows to the PLC. The values are stored in registers 1000 and 1001. Implement instructions to keep track of the total amount of the combined ingredients, so that this information can be displayed on a monitor for the operator.

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC Programming C HAPTER 3 Programming

Flow A

Flow B

Reg 1000

Reg 1001

Figure 9-64 . Flow of two ingredients into a reactor tank.

S OLU T I ON

One register can hold the total of both ingredients after the addition of the two ingredients’ flows. Figure 9-65 shows the use of an ADD instruction to store the BCD result in register 2000. Note that this ADD instruction is always active.

ADD

Reg 1000 + Reg 1001 = Reg 2000

Reg 1000 = Ingredient A Reg 1001 = Ingredient B Reg 2000 = Sum of ingredients A and B

Figure 9-65. Solution to Example 9-8.

S SUB

UBTRACTION —L ADDER

The subtraction (SUB) ladder instruction subtracts the values stored in two registers. As in an addition instruction, if the rung is enabled, the subtraction operation occurs. A GET data transfer instruction usually accesses the two

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC Programming C HAPTER 3 Programming

Languages 9

registers used by a SUB instruction. The subtraction result register will usually have an underflow bit to represent a negative result. Figure 9-66 shows a rung with a SUB instruction.

Storage Area

Contents in Decimal (Binary)

If contact 10 closes, the value in register 1001 is subtracted from the value in register 1000 (Reg 1000 – Reg 1001) and the result is stored in register 2000. If contact 10 does not close, no subtraction is performed.

Figure 9-66. Ladder format subtraction instruction.