Mask Equal To (MEQ)

0 comments
The MEQ instruction passes the Source and Compare values through a Mask and compares the results.

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
Source
SINT
INT
DINT
immediate
tag
value to test against Compare
Mask
SINT
INT
DINT
immediate
tag
which bits to block or pass
Compare
SINT
INT
DINT
immediate
tag
value to test against Source

-    Function Block
Operand
Type
Format
Description
MEQ tag
FBD_MASK_EQUAL
structure
MEQ structure

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

IF (Source AND Mask) = (Compare AND Mask) THEN
<statement>;
END_IF;

FBD_MASK_EQUAL 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.
Source
DINT
Value to test against Compare.
Valid = any integer
Mask
DINT
Defines which bits to block (i.e., mask).
Valid = any integer
Compare
DINT
Compare value.
Valid = any integer

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 MEQ instruction.

Examples
Example 1
If the masked value_1 is equal to the masked value_2, set light_1. If the masked value_1 is not equal to the masked value_2, clear light_1.

This example shows that the masked values are equal. A 0 in the mask restrains the instruction from comparing that bit (indicated by an x in the example).

-    Ladder Diagram

-    Function Block
-    Structured Text
light_1 := ((value_1 AND mask_1)=(value_2 AND mask_2));


Example 2
If the masked value_1 is equal to the masked value_2, set light_1. If the masked value_1 is not equal to the masked value_2, clear light_1.

This example shows that the masked values are not equal. A 0 in the mask restrains the instruction from comparing that bit (indicated by an x in the example).

-    Ladder Diagram
-    Function Block
-    Structured Text
light_1 := ((value_1 AND mask_1)=(value_2 AND mask_2));


- Download to PDF


Read More »

Limit (LIM)

0 comments
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


Read More »

Less Than (LES)

0 comments
The LES instruction tests whether Source A is less than Source B.

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
Notes
Source A
SINT
INT
DINT
REAL
String type

Immediate
tag
value to test against Source B
If you enter a SINT or INT tag, the value converts to a DINT value by sign-extension.

String types are:
-          default STRING data type
-          any new string type you create

To test the characters of a string, enter a string type for both Source A and Source B.
Source B
SINT
INT
DINT
REAL
String type
Immediate
tag
value to test against Source A

-    Function Block
Operand
Type
Format
Description
LES tag
FBD_COMPARE
structure
LES structure

-    Structured Text
Use the less than sign "<" as an operator within an expression. This expression evaluates whether sourceA is less than sourceB.

IF sourceA < sourceB THEN
 <statements>;

FBD_COMPARE 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.
SourceA
REAL
Value to test against SourceB
Valid = any float
SourceB
REAL
Value to test against SourceA
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 LES instruction.

Example
If value_1 is less than value_2, set light_3. If value_1 is greater than or equal to value_2, clear light_3.

-    Ladder Diagram


-    Function Block

-    Structured Text
light_3 := (value_1 < value_2);


- Download to PDF


Read More »

Less Than or Equal To (LEQ)

0 comments
The LEQ instruction tests whether Source A is less than or equal to Source B.

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
Notes
Source A
SINT
INT
DINT
REAL
String type

Immediate
tag
value to test against Source B
If you enter a SINT or INT tag, the value converts to a DINT value by sign-extension.

String types are:
-          default STRING data type
-          any new string type you create

To test the characters of a string, enter a string type for both Source A and Source B.
Source B
SINT
INT
DINT
REAL
String type
Immediate
tag
value to test against Source A

-    Function Block
Operand
Type
Format
Description
LEQ tag
FBD_COMPARE
structure
LEQ structure

-    Structured Text
Use adjacent less than and equal signs "<=" as an operator within an expression. This expression evaluates whether sourceA is less than or equal to sourceB.

IF sourceA <= sourceB THEN
 <statements>;

FBD_COMPARE 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.
SourceA
REAL
Value to test against SourceB
Valid = any float
SourceB
REAL
Value to test against SourceA
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 LEQ instruction.

Example
If value_1 is less than or equal to value_2, set light_2. If value_1 is greater than value_2, clear light_2.

-    Ladder Diagram


-    Function Block


-    Structured Text
light_2 := (value_1 <= value_2);


- Download to PDF

Read More »