Description
You can use the "Compare data type for UNEQUAL with the data type of a tag" instruction to query the data type which a tag does not have to which a VARIANT points. You are comparing the data type of the tag at IN1 parameter, which you declared in the block interface, with the data type of a tag at IN2 parameter for "Not equal".
The tag at the IN1 parameter must have the VARIANT data type. The tag at the IN2 parameter can be an elementary data type or a PLC data type.
If the condition of the comparison is fulfilled, the instruction returns the result of logic operation (RLO) "1". If the comparison condition is not fulfilled, the instruction returns RLO "0".
Comparison of timers, date and time
Not all times can be compared directly with each other, such as S5TIME. In this case they are implicitly converted into another time so that they can be compared, for example to TIME.
If you want to compare dates and times of different data types, the value of the smaller date or time data type is implicitly converted into the larger date or time data type. This means the two date and time data types DATE and DTL, for example, are compared on the basis of DTL.
When the implicit conversions fail, the comparison result is FALSE.
Comparison of structures
For the comparison of structures, you can use the instruction "CMP <>". Anonymous structures cannot generally be compared unless they are part of the same ARRAY.
For additional information on the comparison of structures, please refer to: CMP <>: Not equal
Parameters
The following table shows the parameters of the "Compare data type for UNEQUAL with the data type of a tag" instruction:
|
Parameters |
Declaration |
Data type |
Memory area |
Description |
|
|---|---|---|---|---|---|
|
S7-1200 |
S7-1500 |
||||
|
IN1 |
Input |
VARIANT |
L (The declaration is possible in the "Input", "InOut" and "Temp" sections of the block interface.) |
First operand |
|
|
IN2 |
Input |
Bit sequences, integers, floating-point numbers, timers, date and time, character strings, ARRAY, PLC data types |
I, Q, M, D, L |
I, Q, M, D, L, P |
Second operand |
|
OUT |
Output |
BOOL |
I, Q, M, D, L |
I, Q, M, D, L |
Result of comparison |
Example
The following example shows how the instruction works:
The "TagOut" output is set when the following conditions are fulfilled:
-
The operand "TagIn" has the signal state "1".
-
The condition of the comparison instruction is fulfilled, i.e. the #Tag1 operand is not equal to "Tag2".