Skip to main content

Beckhoff First Scan Bit ❲Certified · RELEASE❳

IF bFirstScan THEN bFirstScan := FALSE; // One-time init code END_IF

// -- Main control loop -- RunMachineLogic();

:The most reliable built-in method in TwinCAT 3 is using the FirstCycle boolean found within the PlcTaskSystemInfo structure. beckhoff first scan bit

The FB_FirstScan function block monitors the system’s cycle counter and reliably returns TRUE for exactly one cycle after application start, even if multiple programs call the same FB instance.

Why it matters

: Ensuring certain outputs or states are cleared before the main logic begins. hardware initialization How to Configure the FirstScan Bit in Siemens TIA Portal

PROGRAM MAIN VAR myOutput : BOOL; END_VAR IF bFirstScan THEN bFirstScan := FALSE; // One-time

A first scan bit is a boolean flag that remains TRUE for exactly one execution cycle of the PLC task. After the first logic solve is complete, the bit drops to FALSE and stays there until the PLC is restarted.