Comparisons Operations for IEC
See also: IEC 61131 Language Editor Programming
See also: Project Toolbox for IEC
Topic Menu
Less Than 
< LT
Operator - Test if first input is less than second input.
Inputs
IN1 : ANY First input
IN2 : ANY Second input
Outputs
Q : BOOL Boolean- [Data Type BOOL] - A single bit, binary value, or register/variable. Boolean points have only two possible values, 'TRUE' or 'FALSE'. TRUE if IN1 < IN2
Remarks - IN1 & IN2 must have the same data type. In LD language, the EN signal enables the operation, and the ENO is the result of the comparison. In IL language, the LT instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type.
ST Language
Q := IN1 < IN2;
FBD Language
LD Language
(* The comparison is executed only if EN is TRUE *)
IL Language
Return to the Top: Comparisons Operations for IEC
Less Than or Equal to 
<= LE
Operator - Test if first input is less than or equal to second input.
Inputs
IN1 : ANY First input
IN2 : ANY Second input
Outputs
Q : BOOL TRUE if IN1 <= IN2
Remarks - Both inputs must have the same type. In LD language, the EN signal enables the operation, and the ENO is the result of the comparison. In IL language, the LE instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type.
ST Language
Q := IN1 <= IN2;
FBD Language
LD Language
(* The comparison is executed only if EN is TRUE *)
IL Language
Return to the Top: Comparisons Operations for IEC
Not Equal 
<> NE
Operator - Test if first input is not equal to second input.
Inputs
IN1 : ANY First input
IN2 : ANY Second input
Outputs
Q : BOOL TRUE if IN1 is not equal to IN2
Remarks - Both inputs must have the same type. In LD language, the input rung EN signal enables the operation, and the ENO is the result of the comparison. In IL language, the NE instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type. Equality comparisons cannot be used with TIME variables. Because the timer actually has the resolution of the target cycle and test may be unsafe as some values may never be reached
ST Language
Q := IN1 <> IN2;
FBD Language
LD Language
(* The comparison is executed only if EN is TRUE *)
IL Language
Return to the Top: Comparisons Operations for IEC
Equal To 
= EQ
Operator - Test if first input is equal to second input.
Inputs
IN1 : ANY First input
IN2 : ANY Second input
Outputs
Q : BOOL TRUE if IN1 = IN2
Remarks - Both inputs must have the same type. In LD language, the input rung EN signal enables the operation, and the ENO is the result of the comparison. In IL language, the EQ instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type. Equality comparisons cannot be used with TIME variables. Because the timer actually has the resolution of the target cycle and test may be unsafe as some values may never be reached.
ST Language
Q := IN1 = IN2;
FBD Language
LD Language
(* The comparison is executed only if EN is TRUE *)
IL Language
Return to the Top: Comparisons Operations for IEC
Greater Than 
> GT
Operator - Test if first input is greater than second input.
Inputs
IN1 : ANY First input
IN2 : ANY Second input
Outputs
Q : BOOL TRUE if IN1 > IN2
Remarks - Both inputs must have the same type. In LD language, the input rung EN signal enables the operation, and the ENO is the result of the comparison. In IL language, the GT instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type.
ST Language
Q := IN1 > IN2;
FBD Language
LD Language
(* The comparison is executed only if EN is TRUE *)
IL Language
Return to the Top: Comparisons Operations for IEC
Greater Than or Equal To 
>= GE
Operator - Test if first input is greater than or equal to second input.
Inputs
IN1 : ANY First input
IN2 : ANY Second input
Outputs
Q : BOOL TRUE if IN1 >= IN2
Remarks - Both inputs must have the same type. In LD language, the input rung EN signal enables the operation, and the ENO is the result of the comparison. In IL language, the GE instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type.
ST Language
Q := IN1 >= IN2;
FBD Language
LD Language
(* The comparison is executed only if EN is TRUE *)
IL Language
Return to the Top: Comparisons Operations for IEC
Bounds Test
LIM
Operator – This block determines if the input (IN) value is numerically in the range defined by the Low and High.
Inputs
LOW: (TYPE : ANY) - This is the lower range for the Input IN.
IN: (TYPE : ANY) - The Input which is checked to lie between the Low & High ranges specified at the Inputs.
HIGH: (TYPE : ANY) - This is the Higher range for the Input IN.
Outputs
Q : (TYPE: BOOL) - The Output is true when input IN is in between the LOW/HIGH range.
Remarks
If Low <= High:
This function passes power if the input is in between Low and High (inclusive) range.
For example, if Low = 10 and High = 100 when the INPUT is between 10 and 100 the function passes power. If the input is 9 or lower OR 101 or higher this function would not pass power.
If Low > High:
This function passes power if the input is outside the range of Low and High (exclusive). For example, if Low = 100 and High = 10 when the INPUT is between 11 and 99 the function does not pass power. If the input is 10 or lower OR 100 or higher this function will pass power.
ST Language
LIM (LOW, IN, HIGH)
Q := LIM.Q;
FBD Language
LD Language
IL Language
Return to the Top: Comparisons Operations for IEC