LogixPro Index

LogixPro
Introduction To
Word Compare Instructions



The RSLogix basic Comparison Instructions

  • From the LogixPro Simulations Menu, select the I/O Simulation.
  • Clear out any existing program by selecting the "New" entry in the File menu, and then select the "Clear Data Table" entry in the Simulations menu.
  • Now enter the following program being careful to enter the addresses and values exactly as shown.

  • Once you have completed entering your program, download your program to the PLC.
  • Ensure that SW0 and SW! are configured as Normally Open pushbuttons then place the PLC into the Run mode.
  • Toggle the state of switch SW0 (I:1/0) continuously while observing the truth of each of rungs as indicated by the lamps.
  • Once the count exceeds nine or ten, reset the counter and repeat the above sequence. Keep doing this until you are convinced that the instructions are operating as described in the RSLogix documentation.
  • Finally, indicate the observed state of the lamps, by circling the appropriate numbers below:

    Lamp 0 is On during counts:   1...2...3...4...5...6...7...8...9...10

    Lamp 1 is On during counts:   1...2...3...4...5...6...7...8...9...10

    Lamp 2 is On during counts:   1...2...3...4...5...6...7...8...9...10

    Lamp 3 is On during counts:   1...2...3...4...5...6...7...8...9...10

 

Conclusions:

The basic Comparison instructions compare the values stored in two memory locations. These two values can be the data stored in two different word locations, or one can be the data stored in a word and the other can be a constant value.   The basic comparison instructions are:

  • EQU .... The Equal instruction goes true if the source A and B values are Equal to each other
  • NEQ .... The Not Equal instruction goes true if the source A and B values are Not Equal to each other
  • LES .... The Less Than instruction goes true if the value in source A is Less Than the value in source B
  • GRT .... The Greater Than instruction goes true if the value in source A is Greater Than the value in source B
  • LEQ .... The Less Than OR Equal instruction goes true if the value in source A is Less Than or Equal to the value in source B
  • GEQ .... The Greater Than OR Equal instruction goes true if the value in source A is Greater Than or Equal to the value in source B

Since any PLC word including Timer and Counter accumulators and presets can be used as the source value in any of the basic comparison instructions, these instructions prove extremely versatile and are widely used in RSLogix programs.

 


The LIM Instruction .... Limit Comparison

  • Modify or rewrite your existing program so that the first 3 rungs appear as shown below.
  • Ensure that addresses and values are exactly as shown.

  • Once you have completed modifying your program, download your program and place the PLC into the Run mode.
  • Toggle the state of switch SW0 (I:1/0) continuously while observing the truth of Lamp 4.
  • Once the count exceeds ten, reset the counter and repeat the above sequence. Keep doing this until you are convinced that the LIM instruction is operating as described in the RSLogix documentation.
  • Finally, indicate the observed state of Lamp 4, by circling the appropriate numbers below:

    Lamp 4 is On during counts:   1...2...3...4...5...6...7...8...9...10

 

Conclusions:

The LIM (Limit Comparison) instruction compares the Test value to the value of the Low Limit and the value of the High Limit. The instruction goes true if .. Test is Equal to or Greater than the Low Limit .. And .. Test is Less Than or Equal to the High Limit. A logical equivalent to rung 2 is shown below:

The LIM instruction provides in a single package the same functionality that would normally necessitate the utilization of 2 basic comparison instructions.

 


The MEQ Instruction .... Masked, Equal Comparison

The MEQ instruction is sometimes considered an advanced level instruction which many might deem inappropriate for inclusion in a basic level exercise. The MEQ is however listed with the other comparison instructions, so a quick peek at it's functionality should not cause major harm. The subject of "Masking" relates to the act of controlling which bits within a binary value or word are passed through to a destination.

The following program is a very simple demonstration of how extraneous information can be selectively ignored with the judicious use of masking. There are several other instructions in the RSLogix instruction set that employ masking and work similarly, but only the MEQ instruction will be reviewed here.

  • Clear your existing program by selecting the "New" entry in the File menu.
  • Now enter the following program being careful to enter the addresses and values exactly as shown.
  • Note: address I:5 is the address of the I/O simulator's input card which has the thumbwheel switches connected to it.

The MEQ and EQU instructions are almost identical in operation. The only difference is that with the MEQ instruction, selected bits within the Source value can be "masked out" or deleted prior to doing the comparison for Equality. In the above MEQ example we are going to mask out all bits other than the 4 which contain the data from the first thumbwheel switch.

  • Once you have completed your program, download your program and place the PLC into the Run mode.
  • Starting with the right hand (units) thumbwheel only, increment the displayed value up and down and note how both lamps energize when the value is set to 4.
  • Now set the first thumbwheel to 4 and start incrementing the second (tens) thumbwheel. If your program is operating correctly only lamp 6 should remain lighted.
  • Finally, set the thumbwheel values to match those listed below, and circle the appropriate number if the corresponding lamp is On.

    Lamp 5 is On when the thumbwheel value is:   1...4...14...34...54...94...104

    Lamp 6 is On when the thumbwheel value is:   1...4...14...34...54...94...104

 

Conclusions:

The MEQ instruction has the same functionality of an EQU instruction, but it allows you to first mask out any extraneous information or bits prior to doing the actual test for equality.

Advanced level? Not really, but it does require a reasonably good understanding of numbering systems and in particular binary.

 

......

 

 

 

 Learning Support for Trades and Technology