LIMIT block
Short summary
Name |
LIMIT |
→POU type |
|
Category |
|
Conform to →IEC-standard |
currently restricted |
Graphical interface |
|
Available since |
version 1.22.0 (for logi.CAD 3) |
Functionality
The block limits a value to defined limits (minimum and maximum value): MIN(MAX(IN, MN),MX)
You connect a value at input IN. If the value of IN exceeds the maximum value connected at input MX, the block returns the value of MX. If the value of IN is below the minimum value connected at input MN, the block returns the value of MN. If the value of IN is within the defined limits or it is equal to one of the limits, the block returns the value of IN.
Special cases
(see under "Example for usage within ST-editor"
)
: If the minimum value exceeds the maximum value, the block always returns the value of MX.
Inputs, return value
|
Identifier |
Description |
|
Inputs: |
MN |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, DATE_AND_TIME, DATE or TIME_OF_DAY |
minimum value |
IN |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, DATE_AND_TIME, DATE or TIME_OF_DAY |
value |
|
MX |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, DATE_AND_TIME, DATE or TIME_OF_DAY |
maximum value |
|
Return value: |
– |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, DATE_AND_TIME, DATE or TIME_OF_DAY |
|
Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.
Example for usage within ST-editor
PROGRAM Test
VAR
result1, result2, result3, result4 : INT;
END_VAR
result1 := LIMIT(MN :=
5
, IN :=
99
, MX :=
100
); (* The variable
'result1'
evaluates to
'99'
. *)
result2 := LIMIT(MN :=
5
, IN :=
2
, MX :=
100
); (* The variable
'result2'
evaluates to
'5'
. *)
result3 := LIMIT(MN :=
5
, IN :=
105
, MX :=
100
); (* The variable
'result3'
evaluates to
'100'
. *)
result4 := LIMIT(MN :=
100
, IN :=
2
, MX :=
5
); (* The variable
'result3'
evaluates to
'5'
. Reason: value
for
'MN'
> value
for
'MX'
*)
END_PROGRAM
When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.