Unlike some other PLC platforms that have a dedicated system bit (like Siemens' or Allen-Bradley's
for exactly one cycle when the PLC runtime starts. This is essential for initializing variables, resetting state machines, or performing one-time setup tasks.
VAR fbGetCurTaskIndex : GETCURTASKINDEX; bIsFirstScan : BOOL; END_VAR fbGetCurTaskIndex(); // Updates the current task index bIsFirstScan := _TaskInfo[fbGetCurTaskIndex.index].FirstCycle; IF bIsFirstScan THEN // Code here runs ONLY on the very first execution cycle END_IF Use code with caution. 2. Manual Implementation: Initialized Booleans
If you have a Fast Task (1 ms) and a Slow Task (10 ms), the first scan bit will trigger independently for each task on the first execution of that task. This can cause race conditions.