Function Block - Comparison with detailed outputs for integer inputs
IN1 : DINT
First value
IN2 : DINT
Second value
LT : BOOL
TRUE if IN1 <
IN2
EQ :
BOOL TRUE if IN1 =
IN2
GT :
BOOL TRUE if IN1 >
IN2
In LD language, the rung input (EN) validates the operation. The rung output is the result of "LT" (lower than) comparison).
(* MyCmp is declared as an instance of CMP
function block *)
MyCMP (IN1, IN2);
bLT := MyCmp.LT;
bEQ := MyCmp.EQ;
bGT := MyCmp.GT;
(* the comparison is performed
only if EN is TRUE *)
(* MyCmp is declared as an instance of CMP
function block *)
Op1: CAL MyCmp (IN1, IN2)
LD MyCmp.LT
ST bLT
LD MyCmp.EQ
ST bEQ
LD MyCmp.GT
ST bGT