lib/edge_detection.txt
author mjsousa
Mon, 11 Aug 2014 07:22:37 +0100
changeset 928 fa7a6800503d
parent 0 fb772792efd1
child 1094 068c28266332
permissions -rwxr-xr-x
Fix calling of functions whose parameters are of an implicitly declared datatype (currently only makes sense for REF_TO datatypes, but may make sense to other datatypes too if the datatype model is changed in the future).
(* 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 RETAIN 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 RETAIN M: BOOL; END_VAR
Q := NOT CLK AND NOT M;
M := NOT CLK;
END_FUNCTION_BLOCK