Page 393 - Programmable Logic Controllers, Fifth Edition - Mobile version
P. 393

Part 5 Math, Comparison,


                                   and Move Instructions



















               Math Instructions                                       Part Objectives

               ControlLogix basic math instructions include addition,   After completing this part, you will be able to:
               subtraction, multiplication, division, and square root.
               Figure 15-77 shows the Compute/Math toolbar for the        •  Utilize ControlLogix math instructions in programs
               ControlLogix controller.                                   •  Utilize ControlLogix comparison instructions in
                  The  ADD  instruction is used to add two numbers.        programs
               This instruction adds these values from Source A and       •  Utilize ControlLogix move instructions in programs
               Source B. The source can be a constant value or a tag.     •  Develop and follow the operation of programs that use
               The result of the ADD instruction is put in the destination   math, comparison, and move instructions
               (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 num-
                    ber from Source A (Value_A) and the value from          Input              Ladder logic program
                    Source B (Value_B).                                                  Add_Sw
                                                                     L1
                 •  The result will be stored in the Dest tag                         <Local:1:I.Data.1>  ADD
                    (Total_Value).                                           Add_Sw                  Add       Value_A
                                                                                                                   25
                 •  In this example, the 25 was added to 50 and the                                  Source A  Value_B
                    result (75) was stored in Total_Value.                                           Source B      50
                                                                                                             Total_Value
                  The SUB instruction is used to subtract two numbers.                               Dest          75
               Figure 15-79 shows an example of a SUB instruction rung
                                                                               Tag Name    Value  Style  Data Type
                                                                                Total_Value   75 Decimal  DINT
                                                                                Value_A      25 Decimal  DINT
                                 CPT  ADD  SUB  MUL  DIV  MODSQR
                                                                                Value_B      50 Decimal  DINT
                                                                                Add_Sw         1 Decimal  BOOL
                       Compare  Compute/Math  Move/Logical  File/Misc.

               Figure 15-77  Compute/Math toolbar for the ControlLogix   Figure 15-78  ADD instruction rung and its Monitor Tags
               controller.                                           window.



               374







          pet73842_ch15_333-394.indd   374                                                                              03/11/15   7:34 PM
   388   389   390   391   392   393   394   395   396   397   398