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

•  Both counters can also be reset manually at any
                                Ladder logic program
                                                                          time by actuation of the Manual_Conveyor_Reset
                     Calculate                                            button.
                                   DIV
                                   Divide
                                   Source A            5
                                   Source B            3             Comparison Instructions
                                   Dest        Answer_Real           Compare instructions are used to compare two values.
                                                 1.6666666           They can be used to see if two values are equal, if one
                                                                     value is greater or less than the other, and so on. In
                        Tag Name      Value  Style  Data Type        ControlLogix controllers, compare instructions are input
                     Calculate            1 Decimal  BOOL            instructions that do comparisons by either using an ex-
                     Answer_Real   1.6666666 Float  REAL             pression or doing the comparison indicated by the specific
                                                                     instruction. Figure 15-83 shows the Compare toolbar for
               Figure 15-81  DIV instruction rung and its Monitor Tags   the ControlLogix controller.
               window.
                                                                        The equal (EQU) instruction is used to test if two
                                                                     values are equal. Values compared can be actual values
                  The DIV instruction is used to divide two numbers.   or tags that contain values. Figure 15-84 shows an exam-
               Figure 15-81 shows an example of a DIV instruction rung   ple of an EQU instruction rung along with its Monitor
               along with its Monitor Tags window. The operation of the   Tags window. The operation of the rung can be summa-
               rung can be summarized as follows:                    rized as follows:

                 •  A constant (5) is used for Source A and a con-     •  The value stored at Source A is compared to the
                    stant (3) for Source B. Note that tags could have     value stored at Source B.
                    been used for Source A or Source B.                •  If the values are equal, the instruction is
                 •  When the Calculate tag is true the DIV instruction    logically true.
                    is executed.                                       •  If the values are unequal, the instruction is
                 •  Source A (5) is divided by Source B (3) and the       logically false.
                    result (1.6666666) is stored in the Dest tag Answer_  •  In this example Source A (25) is equal to Source B
                    Real. Note that in this example a Real-type tag has   (25) so the instruction is true and output Equal_PL
                    been used for its destination.                        is on.
                                                                       •  Source A and Source B may be SINT, INT, DINT,
                  The program of Figure 15-82 is used as part of a parts
               tracking system with three conveyors. The number of        or REAL data types.
               parts in conveyor 1 and the number of parts in conveyor   The not equal (NEQ) instruction is used to test two
               2 are added to get the number of parts on conveyor 3.   values for inequality. Figure 15-85 shows an example of
               The operation of the program can be summarized as     an NEQ instruction rung. When Source A is not equal to
               follows:                                              Source B, the instruction is logically true; otherwise, it
                                                                     is logically false. In this example the two values are not
                 •  Each time Conveyor_1_Sensor is actuated
                    the accumulated value of Counter_1_Parts is      equal so the Not_Equal_PL is energized.
                                                                        The less than (LES) instruction is used to check if a
                    incremented by 1.                                value from one source is less than the value from a sec-
                 •  Each time Conveyor_2_Sensor is actuated          ond source. Figure 15-86 shows an example of an LES
                    the accumulated value of Counter_2_Parts is      instruction rung. When Source A is less than Source B,
                    incremented by 1.                                the instruction is logically true; otherwise, it is logically
                 •  The addition in the ADD instruction places the sum   false. In this example Value_1 (100) is less than Value_2
                    of the accumulated values of the two counters in the   (300) so the Less_Than_PL is energized.
                    Conveyor_3_Parts tag.                               The greater than (GRT) instruction is used to check
                 •  When the accumulated value for either counter is   if a value from one source is greater than the value from
                    equal to 150 the reset (RES) instructions for both   a second source. Figure 15-87 shows an example of a
                    counters are enabled to automatically reset both   GRT instruction rung. When Source A is greater than
                    counter ACC values to zero.                      Source B, the instruction is logically true; otherwise,



               376        Part 5  Math, Comparison, and Move Instructions







          pet73842_ch15_333-394.indd   376                                                                              03/11/15   7:34 PM
   390   391   392   393   394   395   396   397   398   399   400