Comparison Operation
= Operator
= Operator compares if two operands are equal.
Format: Expression1 = Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.
Bit operation truth table
Expression 1 | Expression 2 | Result |
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Example
Example | Description |
IF MX00 = 1 THEN YX2A := 1; END_IF; | If the bit value of M00 is the same as 1, the operation of IF statements are performed. |
<> Operator
<> Operator compares if the two operands are not equal.
Format: Expression1 <> Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.
Bit operation truth table
Expression 1 | Expression 2 | Result |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Example
Example | Description |
IF MX00 <> 1 THEN YX2A := 1; END_IF; | If the bit value of M00 is not 1, the operation of IF statements are performed. |
< Operator
< Operator compares if the operand on the left side is smaller than the right side.
Format: Expression1 < Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.
Bit operation truth table
Expression 1 | Expression 2 | Result |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 0 |
1 | 1 | 0 |
Example: Add the values from 0 to 4
Description |
// While D00’s word value is less than 5, operations in WHILE statement is performed WHILE DW00 < 5 DO DW00 := DW00 + 1; DW10 := DW10 + DW00; END_WHILE; |
> Operator
> Operator compares if the operand on the left is greater than the right one.
Format: Expression1 > Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.
Bit operation truth table
Expression 1 | Expression 2 | Result |
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 1 |
1 | 1 | 0 |
Example: Add the values from 0 to 5
Description |
// While D00’s word value is less than 10, the operation in WHILE statement is performed WHILE DW00 < 10 DO // End WHILE statement when D00’s word value is 6 IF DW00 > 5 THEN EXIT; END_IF; DW10 := DW10 + DW00; DW00 := DW00 + 1; END_WHILE; |
<= Operator
<= Operator compares if the operand on the left is less than or equal to the operand on the right.
Format: Expression1 <= Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.
Bit operation truth table
Expression 1 | Expression 2 | Result |
0 | 0 | 1 |
0 | 1 | 1 |
1 | 0 | 0 |
1 | 1 | 1 |
Example: Add the values from 0 to 5
Description |
// While D00’s device word value is less than 5 or equal to 5, the operation in WHILE statement is performed WHILE DW00 <= 5 DO DW00 := DW00 + 1; DW10 := DW10 + DW00; END_WHILE; |
>= Operator
>= Operator compares if the operand on the left is greater than or equal to the operand on the right.
Format: Expression1 >= Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.
Bit operation truth table
Expression 1 | Expression 2 | Result |
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 1 |
1 | 1 | 1 |
Example: Add the values from 1 to 10
Description |
IF DW00 = 0 THEN DW10 := 10; END_IF; // While D10’s word value is equal to or greater than 1, the operation in WHILE statement is performed WHILE DW10 >= 1 DO DW00 := DW00 + DW10; DW10 := DW10 - 1; END_WHILE; |