lib/edge_detection.txt
author Edouard Tisserant
Mon, 04 Oct 2021 11:29:13 +0200
changeset 1094 068c28266332
parent 0 fb772792efd1
permissions -rwxr-xr-x
Remove RETAIN qualifier for F_TRIG and R_TRIG 'M' variable. This is not following standard, and implicitely consumes a lot of RETAIN memory. User can explicitely qualify R_TRIG of F_TRIG instance as RETAIN if needed.
(* Following taken directly from the IEC 61131.3 draft standard *)

(*
 * An IEC 61131-3 IL and ST compiler.
 *
 * Based on the
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
 *
 *)


(*
 * This is part of the library conatining the functions
 * and function blocks defined in the standard.
 *
 * Edge detection function blocks
 * ------------------------------
 *)

FUNCTION_BLOCK R_TRIG
     VAR_INPUT  CLK: BOOL; END_VAR
     VAR_OUTPUT  Q: BOOL; END_VAR
     VAR M: BOOL; END_VAR
Q := CLK AND NOT M;
M := CLK;
END_FUNCTION_BLOCK

FUNCTION_BLOCK F_TRIG
     VAR_INPUT  CLK: BOOL; END_VAR
     VAR_OUTPUT   Q: BOOL; END_VAR
     VAR M: BOOL; END_VAR
Q := NOT CLK AND NOT M;
M := NOT CLK;
END_FUNCTION_BLOCK