# CODESYS LIMIT

Instructions · `LIMIT` · verification: source checked

LIMIT is an IEC selection operator in the CODESYS development system that limits a value to a range. It is written as OUT := LIMIT(Min, IN, Max) and is equivalent to OUT := MIN(MAX(IN, Min), Max), so a value above Max returns Max and a value below Min returns Min. The source gives the example Var1 := LIMIT(30,90,80); which returns 80.

## Specification

| Property | Value |
|---|---|
| Language | structured text |
| Code | LIMIT |
| Group | selection operator |
| Syntax | OUT := LIMIT(Min, IN, Max) |
| Dialect | CODESYS |

### Parameters

| Name | Description | Data type |
|---|---|---|
| Min | Lower limit for the result. |  |
| IN | Value to be limited. | all |
| Max | Upper limit for the result. |  |
| OUT | Result of the limiting operation. | all |

## Study notes

- LIMIT is described as an IEC selection operator and is used for limiting.
- The call form is OUT := LIMIT(Min, IN, Max).
- It is equivalent to OUT := MIN(MAX(IN, Min), Max).
- Max is the upper limit of the result; if IN is above Max, LIMIT yields Max.
- Min is the lower limit of the result; if IN is below Min, the result is Min.
- Permitted data types for IN and OUT: all.
- Example: Var1 := LIMIT(30,90,80); gives the result 80 in Var1.

## Sources

1. [Beckhoff Information System](https://infosys.beckhoff.com/content/1033/tc3_plc_intro/2528972171.html) (accessed 2026-10-26)
2. [CODESYS Group](https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_operator_limit.html) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/iec-limit  
JSON: https://machineschema.com/instruction/iec-limit.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
