Files
2026-06-29 16:28:48 +02:00

35 lines
660 B
Plaintext

FUNCTION_BLOCK "FB_CycleTime"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR_OUTPUT
CycleTime : DInt;
END_VAR
VAR
TimeOld : DInt;
TimeNew : DInt;
END_VAR
BEGIN
//letzte Zykluszeit ermitteln
IF "FirstScan" THEN
//first Cycle
//no Cycletime
#TimeNew := TIME_TCK();
#CycleTime := 0;
#TimeOld := TIME_TCK();
ELSE
#TimeNew := TIME_TCK();
IF #TimeNew < #TimeOld THEN
//Systemzeit übergelaufen
#CycleTime := 2147483647 - #TimeOld + #TimeNew;
ELSE
#CycleTime := #TimeNew - #TimeOld;
END_IF;
#TimeOld := #TimeNew;
END_IF;
END_FUNCTION_BLOCK