Back to tutorials
PLC Instructions

PLC Programming Comparison Instructions – LES | Less Than

Vladimir Romanov
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


PowerFlex 525 Parameter, Input and Output Programming Tutorial in RSLogix Studio 5000

The PowerFlex 525 series of Variable Frequency Drives from Allen Bradley is highly utilized and respected within the automation field. The drives are compact, versatile and easy to use. We’ve written an extensive tutorial on how to get started with these drives in a previous tutorial; it covers how to initialize the drive, connect it to an EtherNet/IP based PLC and how to set the right parameters. In this tutorial, we’re looking to expand on the concepts and demonstrate a way to access and utilize the multiple Input and Output options available on the drive. The reason you may want to utilize the IO is to save money on purchasing external components, integrate instrumentation into your drive and save floor space, wiring and cost. We’ve seen the need to integrate closely related sensors into a PowerFlex 525 application; this would be the right way to do it.

Vladimir Romanov

Publishing MQTT Data Using Opto 22 groov EPIC PAC

MQTT is a communication protocol that has taken off in the IIoT community. It’s a light-weight, efficient protocol that works through a publisher / broker / subscriber model. It creates an easy way for field devices to communicate and retrieve data from a single location. In this article, we’ll go over MQTT and dive into an example of how you can publish data using a groov EPIC PAC and retrieve the data using a MQTT client.

Vladimir Romanov

HMI Design - Best Practices for Effective HMI Screens

HMI Design is the practice of building HMI screens that are intuitive to the end user, pleasing to the eye and are efficient to operate. As control systems within manufacturing are migrated from traditional push button designs to primarily operated from HMI displays, HMI Design has become trivial to any new installation.Although there is a wide range of HMI based systems, the basic principles of good design remain the same. Different industries may dictate different patterns of layout for their systems, but the good practices remain.

Vladimir Romanov