Back to tutorials

PLC Programming Comparison Instructions – LES | Less Than

Vladimir Romanov
September 12, 2018
Table of Contents


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:



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

Back to tutorials

Related Tutorials


PLC Programming Example Project - Batching Tank Ladder Logic PLC and HMI Tutorial

Generally speaking, there are two types of processes in manufacturing: discrete and analog. A discrete process is a manufacturing methodology that will produce separate widgets. In other words, a production line may output one item, two items, three items, etc. An analog production process is where the plant will create a quantity of product that is quantifiable by weight. Examples include the production of beverages, sauces, raw ingredients, etc. Although it is possible to design a flow that will continuously output the product, such production is often managed in batches. It is important to note that although batches are considered to be analog or continuous flow, most of them end up being packaged for consumption which converts them into a discrete manufacturing process.

September 14, 2020
Vladimir Romanov
PLC Programming Career

PLC Programming Certification - Complete Guide

You may choose to pursue a traditional college degree, learn through online tutorials, or take a course that will issue a plc programming certification upon completion. However, what is the best option, and what are the best PLC programming certifications?

August 6, 2020
Vladimir Romanov

Opto 22 groov RIO Getting Started

The groov RIO module from Opto 22 has been released only a few months ago. The groov RIO is a feature packed piece of hardware that is easy to install, configure and deploy for many different field applications. The module comes pre-loaded with an array of software tools used across the industry and is ready to hit the floor running out of the box. Furthermore, the module is equipped with user configurable input and output nodes that have the capability unlike anything else on the market.

August 2, 2020
Vladimir Romanov