# Ladder Logic Comparison Instructions

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

## Introduction

This chapter give the definition of comparison instructions and the way they are used. In general comparison instruction are used to test a pair of values to energize or de-energize a rung.

## Definition

The following is a list of the comparison instructions in SLC 500:

### EQU - Equal

#### Definition

• Test whether two values are equal or not.
• If source A and Source B are equal, the instruction is logically true. Source A must be an address. Source B can either be a program constant or an address. Negative integers are stored in two's complement.

### NEQ - Not Equal

#### Definition

• Test whether one value is not equal to a second value.
• If Source A and Source B are not equal, the instruction is logically true. If the two values are equal, the instruction is logically false.
• Source A must be an address. Source B can be either a program constant or an address. Negative integers are stored in two's complement.

### LES - Less Than

#### Definition

• Test whether one value is less than a second value.
• If Source A is less than the value at source B the instruction is logically true. If the value at source A is greater than or equal to the value at source B, the instruction is logically false.
• Source A must be an address. Source B can either be a program constant or an address. Negative integers are stored in two's complement.

### LEQ - Less Than or Equal

#### Definition

• Test whether one value is less than or equal to a second value.
• If value at source A is less than or equal to the value at source B, the instruction is logically true.
• If the value at source A is greater than or equal to the value at source B, the instruction is logically false.
• Source A must be an address. Source B can either be a program constant or an address. Negative integers are stored in two's complement.

### GRT - Greater Than

#### Definition

• Test whether one value is greater than the second value.
• If the value at source A is greater than the value at source B, the instruction is logically true.
• If the value at source A is less than or equal to the value at source B, the instruction is logically false.
• Source A must be an address. Source B can either be a program constant or an address. Negative integers are stored in two's complement.

### GEQ - Greater or Equal

#### Definition

• Test whether one value is greater or equal to a second value.
• If the value at source A is greater than or equal the value at source B, the instruction is logically true.
• If the value at source A is less than to the value at source B, the instruction is logically false.
• Source A must be an address. Source B can either be a program constant or an address. Negative integers are stored in two's complement.

### MEQ - Masked Comparison for Equal

#### Definition

• 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
• Use the MEQ instruction to compare data at a source address with data at a compare address. Use of this instruction allows portions of the data to be masked by a separate word.
• Source is the address of the value you want to compare.
• Mask is the address of the mask through which the instruction moves data. The mask can be a hexadecimal value.
• Compare is an integer value or the address of the reference.
• If the 16 bits of data at the source address are equal to the 16 bits of data at the compare address (less masked bits), the instruction is true. The instruction becomes false as soon as it detects a mismatch. Bits in the mask word mask data when reset; they pass data when set.

### LIM - Limit Test

#### Definition

• Test whether one value is within the limit range of two other values
• The Low limit, Test, and High Limit values can be word addresses or constants, restricted to the following combination:
• If the Test parameter is a program constant, both the Low Limit and High Limit parameters must be word addresses.
• If the Test parameter is a word address, the Low Limit and High Limit parameters can be either a program constant or a word address.
 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