etisserant@0: FUNCTION_BLOCK HYSTERESIS
etisserant@0:     (* Boolean hysteresis on difference *)
etisserant@0:     (* of REAL inputs, XIN1 - XIN2      *)
etisserant@0:   VAR_INPUT XIN1, XIN2, EPS : REAL; END_VAR
etisserant@0:   VAR_OUTPUT Q : BOOL := 0; END_VAR
etisserant@0:   IF Q THEN IF XIN1 < (XIN2 - EPS) THEN Q := 0; END_IF ;
etisserant@0:   ELSIF XIN1 > (XIN2 + EPS) THEN Q := 1 ;
etisserant@0:   END_IF ;
etisserant@0: END_FUNCTION_BLOCK
etisserant@0: