Ho provato il tuo programma, effettivamente non è un problema tuo ma è un bug del blocco funzione eTOF, ho provveduto a correggerlo, allego il programma con la nuova FB corretta per il download. Allego anche sorgente blocco funzione eTOF così hai una idea di come funziona.
FUNCTION_BLOCK eTOF
VAR_INPUT
IN : BOOL; { DE:”Timer input” }
PT : UDINT; { DE:”Preset time value (mS)” }
END_VAR
VAR_OUTPUT
Q : BOOL; { DE:”Delayed output” }
ET : UDINT; { DE:”Executing time (mS)” }
END_VAR
VAR_EXTERNAL
SysTime : UDINT; { DE:”System time (mS)” }
END_VAR
VAR
TimeBf : UDINT; { DE:”Time buffer” }
END_VAR
{ CODE:ST }
IF (IN) THEN
ET:=0; (* Executing time (mS) *)
Q:=TRUE; (* Delayed output *)
TimeBf:=SysTime; (* Time buffer *)
RETURN;
END_IF;
IF NOT(Q) THEN RETURN; END_IF;
ET:=SysTime-TimeBf; (* Executing time (mS) *)
IF (ET >= PT) THEN
ET:=PT; (* Executing time (mS) *)
Q:=FALSE; (* Delayed output *)
END_IF;
END_FUNCTION_BLOCK