Ladder Logic Masked comparison for Equal Instruction

KronoTech

PLC

Ladder Logic

Basic

Counters

Timer

Arithmetic

Comparison

EQU

NEQ

LES

LEQ

GRT

GEQ

LIM

MEQ

Functions

Trig Functions

RSLogix 5000

Structured Text

HMI

Instruments

MEQ - Masked comparison for Equal

Test portion of two values to see whether they are equal. Compares 16 bit data of a source address to 16 bit data at a reference address through a mask.

Example

Lets say we have four counters. Each counter goes from 0 to 9. Since 0 to 9 can be represented in 4 bits then we can combine the four counters in one word of 16 bits. This is to reduce the amount of memory counters will need.

  • Counter 1 = N7:0 bit 0,1,2,3
  • Counter 2 = N7:0 bit 4,5,6,7
  • Counter 3 = N7:0 bit 8,19,10,11
  • Counter 4 = N7:0 bit 12,13,14,15

Now that we have all four counters in one word we want to compare our result to a certain value. MEQ is the solution for such a problem. MEQ will make a comparison of a value based on the bits specified in the mask section.

Ladder Logic Solution

Comparing N7:0 = -31166 with 2 is energizing B3:0/0 why? Well cause:

  • Source: -31166 = 8642 Hex
  • Compare: 0002 = 0002 hex
MEQ 1 SLC 500 Beginners Training Guide

Comparing N7:0 = -31166 with 64 is energizing B3:0/1 why? Well cause:

  • Source: -31166 = 8642 Hex
  • Compare: 0064 = 0040 Hex
MEQ 2 SLC 500 Beginners Training Guide

Comparing N7:0 = -31166 with 1536 is energizing B3:0/2 why? Well cause:

  • Source: -31166 = 8642 Hex
  • Compare: 0600 = 0002 Hex
MEQ 3 SLC 500 Beginners Training Guide

Comparing N7:0 = -31166 with -32768 is energizing B3:0/3 why? Well cause:

  • Source: -31166 = 8642 Hex
  • Compare: 0002 = 8000 Hex
MEQ 4 SLC 500 Beginners Training Guide

Note

  • When the mask is equal to F = 1111 in Binary. So if you want to mask only the first 3 bits out of 4 then your mask should be 0111, which is equal to 7 in Hex. What this mean is that your binary bit is on then the comparison would be done on that specific bit or bits.

Quick Links

PLC Languages

Ladder Logic
Function Block
Structure Text
SFC
Mnemonic

Ladder Logic

Basic
Counters
Timer
Arithmetic
Comparison
Functions
Trig Functions

Instruments

Switches

HMI

Advantages
Alarms
Trends

Other

Bottle Application