Back to tutorials
PLC Instructions

PLC Programming Comparison Instructions – LIM | Limit Test

By
Vladimir Romanov
Table of Contents

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.

Video Tutorial

Back to tutorials

Related Tutorials

Advanced

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.

By
Vladimir Romanov
Advanced

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.

By
Vladimir Romanov
Intermediate

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.

By
Vladimir Romanov