Mask Equal To (MEQ)

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


0 comments :