Back to tutorials

PLC Programming Comparison Instructions – LIM | Limit Test

Vladimir Romanov
September 24, 2018
Table of Contents


The LIM, also known as the Limit Test, is an instruction which will compare the specified operand to two limits: lower limit and high limit. Should the value be greater than the lower limit and less than the higher limit, the instruction will set the output to TRUE. However, if the opposite is the case, the instruction will evaluate to FALSE. Furthermore, the reversal of the two limits will have the opposite logic effect on the instruction effectively resulting in a NOT of the original instruction.

The LIM instruction is very commonly used in ladder logic programming. It stemmed from the parallel use of the GRT and LES Instructions. It gives the user a simple way to make sure that the specified value falls between two distinct limits and is often used for setpoints, temperature readings, etc.

As briefly mentioned above, the instruction may be inverted by specifying a Low Limit which is higher than the High Limit. This may seem confusing at first, but is the right approach in certain situations. That being said, avoid this practice as much as possible.

Example & Usage of LIM

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

  1. A Micrologix 1100 Allen Bradley PLC is used to control a process.
  2. In rung 0000, a LIM  instruction is used to compare an Integer N7:0 to two constants: 5 and 54.
  3. Since N7:0 is set to 16, it falls between the limits of the LIM instruction.
  4. Rung 0000, therefore, evaluates to TRUE.
  5. In rung 0001, a LIM  instruction is used to compare an Integer N7:2 to two Integers: N7:1 and N7:3.
  6. Since N7:2 is set to 24, N7:1 is set to 123 and N7:3 is set to 7000, N7:2 does not fall between the limits of the LIM instruction.
  7. Rung 0001, therefore, evaluates to FALSE.

Programming example in RSLogix 500:

  1. In rung 0002, a LIM  instruction is used to compare a Float F8:0 to two Floats: F8:1 and F8:2.
  2. Since F8:0 is set to 242.45, F8:1 is set to 123.123 and F8:2 is set to 2352.34, F8:0 falls between the limits of the LIM instruction.
  3. Rung 0002, therefore, evaluates to TRUE.
  4. In rung 0003, a LIM  instruction is used to compare a Float F8:4 to two Floats: F8:3 and F8:5.
  5. Since F8:4 is set to 46.0, F8:3 is set to 500.0 and F8:5 is set to 10.0, F8:4 falls between the limits of the LIM instruction.
  6. Because the Low Limit is greater than the High Limit in this instruction, the instruction evaluates to FALSE.

Programming example in RSLogix 500:

  1. In rung 0004, a LIM  instruction is used to compare a Temperature Setpoint Float F8:6 to two Limit Floats: F8:7 and F8:8.
  2. Since F8:6 is set to 23.0, F8:7 is set to 45.0 and F8:8 is set to 54.0, F8:6 does not fall between the limits of the LIM instruction.
  3. Rung 0004, therefore, evaluates to FALSE.

Programming example in RSLogix 500:



In this example, we have 5 rungs which contain a LIM (Limit Test) Instruction. The examples demonstrate the fact that this instruction will evaluate the operand against two limits: Low and High. If the specified operand falls within this limit, the instruction will evaluate to TRUE. If the operand is outside the limit, it will evaluate the FALSE. However, the preceding logic only applies if the Low Limit is, in fact, lower than the High Limit. If that’s not the case, the opposite logic will apply to the instruction.

The examples also illustrate the fact that the instruction may be used with different operands such as constants, integers, and floats.

Lastly, in the final rung, we see a case which can be commonly found on a PLC in the field. A limit instruction is used to see if the target temperature has been reached. Based on this logic, the programmer may choose to turn on a heater, boiler or otherwise.

Data Types Allowed for LIM

The LIM 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 will be evaluated within the LIM instruction is being scanned. In an instance where the value is changed in other locations for only a brief duration, the LIM 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 LIM 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