Limit (LIM)

The LIM instruction tests whether the Test value is within the range of Low Limit to the High Limit.

Available Languages
-    Ladder Diagram


-    Function Block


-    Structured Text
 This instruction is not available in structured text. *

* There is no equivalent structured text instruction. Use other structured text programming to achieve the same result.

Operands
-    Ladder Diagram
Operand
Type
Format
Description
Low limit
SINT
INT
DINT
REAL
immediate
tag
value of lower limit
Test
SINT
INT
DINT
REAL
immediate
tag
value to test
High limit
SINT
INT
DINT
REAL
immediate
tag
value of upper limit

-    Function Block
Operand
Type
Format
Description
LIM tag
FBD_LIMIT
structure
LIM structure

-    Structured Text
Structured text does not have a LIM instruction, but you can achieve the same results using structured text.

IF LowLimit <= HighLimit AND
 (Test >= LowLimit AND Test <= HighLimit)) OR
 (LowLimit >= HighLimit AND
 (Test <= LowLimit OR Test >= HighLimit)) THEN
<statements>;
END_IF;

FBD_LIMIT Structure
Input Parameter
Data Type
Description
EnableIn
BOOL
Enable input. If cleared, the instruction does not execute and outputs are not updated.
Default is set.
LowLimit
REAL
Value of lower limit.
Valid = any float
Test
REAL
Value to test against limits.
Valid = any float
HighLimit
REAL
Value of upper limit.
Valid = any float

Output Parameter
Data Type
Description
EnableOut
BOOL
Enable output.
Dest
BOOL
Result of the instruction. This is equivalent to rung-condition-out of the ladder diagram LIM instruction.

Examples
Example 1: Low Limit <= High Limit
When 0 <= value >= 100, set light_1. If value < 0 or value > 100, clear light_1.

-    Ladder Diagram

-    Function Block


-    Structured Text
IF (value <= 100 AND (value >= 0 AND value <= 100)) OR
 (value >= 100 AND value <= 0 OR value >= 100)) THEN
  light_1 := 1;
ELSE
  light_1 := 0;
END_IF;


Example 2: Low Limit >= High Limit
When value >= 0 or value <= -100, set light_1. If value < 0 or value > -100, clear light_1.

-    Ladder Diagram


-    Function Block


-    Structured Text
IF (0 <= -100 AND value >= 0 AND value <= -100)) OR
 (0 >= -100 AND (value <= 0 OR value >= -100)) THEN
  light_1 := 1;
ELSE
  light_1 := 0;
END_IF;


- Download to PDF


0 comments :