Cookies are important for this site to function properly, to guarantee your safety, and to provide you with the best experience. By clicking OK, you accept all cookies. For more information, please access our Privacy Policy.
Table of Contents
Tutorials / 
PLC Programming Comparison Instructions – LIM | Limit Test
Beginner

PLC Programming Comparison Instructions – LIM | Limit Test

PLC Programming
Allen Bradley
RSLogix 500
RSLogix 5000
Studio 5000
Ladder Logic

Introduction

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:

LIMLimitTestInstruction1
  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:

LIMLimitTestInstruction2
  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:

LIMLimitTestInstruction3

Outcome:

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.