2-303
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Selection Instructions
2
LIMIT
The LIMIT instruction limits the value of data to limit In according to the maximum value, MX, and the
minimum value, MN. The value of processing result Out is as shown below.
The following example is for when MN is INT#−10 and MX is INT#20.
• In, MN, MX, and Out may be different data types, but observe the following precautions.
• Set the valid range of Out to include the valid ranges of In, MN, and MX.
• Do not combine signed integers (SINT, INT, DINT, and LINT) together with unsigned integers
(USINT, UINT, UDINT, and ULINT) for In, MN, and MX.
• An error occurs in the following case. ENO will be FALSE, and Out will not change.
• The value of MX is smaller than the value of MN.
Function
Value of In Value of Out
In < MN MN
MN ≤ In ≤ MX In
MX < In MX
Precautions for Correct Use
def:=LIMIT(INT#−10, abc, INT#20);
LD ST
INT#20
INT#−10
abc
def
LIMIT
EN ENO
MN
In
MX
Out=def
In=abc
MX=INT#20
MN=INT#−10