Contents
Beginner

PLC Programming Comparison Instructions – LES | Less Than

By
Vladimir Romanov
|
September 12, 2018
Table of Contents

Introduction

The LES, also known as the Less Than, is an instruction used to compare two values against each other. The instruction takes two integers, floats or constants and will return TRUE if the value specified in “Source A” is less than the one in “Source B”. The “Source B” operand must be strictly less than the one specified in “Source A”. In other words, the instruction will return FALSE if they are equal.

This instruction can be used to test for an upper limit for an analog sensor and reliably notify the programmer should the value be exceeded.

In RSLogix 500, you may not compare two constants; this restriction is not present in RSLogix 5000 as well as Studio 5000. This is also the case for all comparison instructions.

Example & Usage of LES

Here’s a real-world scenario of a LES instruction:

  1. A Micrologix 1100 Allen Bradley PLC is used to control a process.
  2. A LES instruction is used to compare a Float F7:10 to a Float F7:11.
  3. The Float F7:10 is currently set to “345.464” and the Float F7:11 is set to “2.15915”.
  4. This LES instruction evaluates to FALSE since the value of F7:10 is NOT Less Than the value in F7:11.
  5. Note: The logic displays the boolean B3:1/0 as energized due to the fact that it’s used elsewhere in the logic. It is not being energized by this rung.
  6. A LES instruction is used to compare an Integer N7:0 to the Integer N7:1.
  7. The Integer N7:0 is currently set to “564” while the Integer N7:1 is set to “6”.
  8. This LES instruction evaluates to FALSE since N7:0 is NOT Less Than N7:1.
  9. A TON instruction is used to run a continuous timer T4:2 loop 2 seconds (200 x 0.01 = 2000 msec.)
  10. A LES instruction is used to compare the value of the accumulated (.ACC) value of Timer T4:2 to the integer N7:3.
  11. The LES instruction will evaluate to TRUE during the first half of the timer because N7:3 is set to 100 (100 x 0.01 = 1000 = 1/2 of the timer).
  12. The LES instruction will evaluate to FALSE during the second half of the timer because N7:3 is set to 100 (100 x 0.01 = 1000 = 1/2 of the timer).

Programming example in RSLogix 500:

LESInstructionRSLogix500Example

Outcome:

The first two examples of the LES instruction are straightforward. We’re comparing two operands to each other and return TRUE if the one specified in “Source A” is less than the one in “Source B”. The first instruction is evaluating two distinct float registers. Since the one specified in “Source A” is NOT less than the one in “Source B”, the instruction returns a FALSE. The same is true for the second LES instruction, but it’s used on a set of integers.

The last example which uses the LES instruction in ladder logic is slightly less obvious. A timer is running in a continuous loop due to the XIO Instruction used on its .DN bit. The setting on the timer causes the loop to repeat every two seconds. The LES instruction below the timer is comparing the accumulated value in the timer to the integer N7:3. Since the integer is set to 100, it causes the instruction to evaluate to TRUE during the first half of the timer.

Data Types Allowed for LES

The LES can be used to compare two values of identical types. These value can be INTs, DINTs, or FLOATs.

  • Integer – You may specify each operand to be of “Integer” type.
  • Float – You may specify each operand to be of “Float” or “Real” type.

Important Notes

  • Note 1 – Both operands need to be exactly the same while the rung containing the LES instruction is being scanned. Otherwise, the instruction will evaluate to TRUE. In an instance where the value is changed in other locations for only a brief duration, the LES comparison may result in unforeseen outcomes.
  • Note 2 – When working with constants, RSLogix 500 will not allow the user to use the constant in the “Operand A” field. The constant must be specified within “Operand B”. This limitation is not present in all software packages.
  • Note 3 – The user may not specify a comparison of two constants within RSLogix 500. In other words, you may not use the LES instruction with “Operand A” set to 7 and “Operand B” set to 20. This case will always evaluate to FALSE which should not be used.

Video Tutorial

Got a question or comment?

Related Tutorials

Beginner

How to Build an Allen Bradley PLC Trainer Kit for PLC Training at Home

The best way to learn PLC programming is to get hands-on experience. However, as many are trying to learn how to program these devices before landing a job, it becomes crucial to invest in your own hardware in order to accelerate the learning process. That being said, a PLC programmer will face three challenges when it comes to building an effective PLC trainer.

April 10, 2020
|
By
Vladimir Romanov
Beginner

Photo Eye Sensor | How to Wire a Photoelectric Sensor into a CompactLogix Allen Bradley PLC

Learn how to work with photoelectric sensors, understand the basics, how to wire them, how to tie them into various PLCs and field devices and lastly how to troubleshoot them.

April 24, 2020
|
By
Vladimir Romanov
Beginner

PLC Programming | How to Read Ladder Logic

Learn the basics of Ladder Logic, one of the top 5 most popular types of PLC programming languages used in manufacturing environments.

April 7, 2020
|
By
Vladimir Romanov