Page 85

Petruzella_ProgrammableLogicControllers__5e

374 Part 5 Math, Comparison, and Move Instructions Part Objectives After completing this part, you will be able to: •• Utilize ControlLogix math instructions in programs •• Utilize ControlLogix comparison instructions in programs •• Utilize ControlLogix move instructions in programs •• Develop and follow the operation of programs that use math, comparison, and move instructions Math Instructions ControlLogix basic math instructions include addition, subtraction, multiplication, division, and square root. Figure 15-77 shows the Compute/Math toolbar for the ControlLogix controller. The ADD instruction is used to add two numbers. This instruction adds these values from Source A and Source B. The source can be a constant value or a tag. The result of the ADD instruction is put in the destination (Dest) tag. Figure 15-78 shows an example of an ADD instruction rung along with its Monitor Tags window. The operation of the rung can be summarized as follows: • When the Add_Sw is closed the rung will be true. • The ADD instruction will execute to add the number from Source A (Value_A) and the value from Source B (Value_B). • The result will be stored in the Dest tag (Total_Value). • In this example, the 25 was added to 50 and the result (75) was stored in Total_Value. The SUB instruction is used to subtract two numbers. Figure 15-79 shows an example of a SUB instruction rung CPT Compare ADD SUB MUL DIV MOD SQR Compute/Math Move/Logical File/Misc. Figure 15-77  Compute/Math toolbar for the ControlLogix controller. Input Ladder logic program L1 ADD Add Source A Source B Dest Value_A 25 Value_B 50 Total_Value 75 Add_Sw <Local:1:I.Data.1> Add_Sw Tag Name Value Style Data Type Total_Value Value_A Value_B Add_Sw 75 25 50 1 Decimal Decimal Decimal Decimal DINT DINT DINT BOOL Figure 15-78  ADD instruction rung and its Monitor Tags window.


Petruzella_ProgrammableLogicControllers__5e
To see the actual publication please follow the link above