For one of my programs I need a normally closed, timed-closing (NCTC) relay in Ladder Diagram.
I do not know of a standard method to implement such, so I'm trying to construct one myself. My current approach needs a falling-edge detection. The code of such a detector I've found in the back of a book: "IEC 61131-3: Programming Industrial Systems" (2nd edition, page 327). Looks like this:
FUNCTION_BLOCK F_TRIG (* falling edge *)
VAR_INPUT
CLK : BOOL;
END_VAR
VAR_OUTPUT
Q : BOOL;
END_VAR
VAR RETAIN
MEM : BOOL := 1; (* initialise edge flag *)
END_VAR
Q := NOT CLK AND NOT MEM; (* recognise falling edge *)
MEM := NOT CLK; (* reset edge flag *)
END_FUNCTION_BLOCK
Which gives me exactly 5 errors (ignoring the build failing because of those):
ERROR 4250: F_TRIG (1): Another 'ST' statement or end of POU expected
ERROR 4250: F_TRIG (4): Another 'ST' statement or end of POU expected
ERROR 4250: F_TRIG (7): Another 'ST' statement or end of POU expected
ERROR 4250: F_TRIG (10): Another 'ST' statement or end of POU expected
ERROR 4250: F_TRIG (13): Another 'ST' statement or end of POU expected
I properly configured the type of POU to be a function block and the language of the POU to be ST. I suspect my syntax is rusty, but I'm open for suggestions. Especially if I'm tackling this problem in an all wrong approach.
It looks okay to me. What's going wrong?
Running Codesys 2.3.