First Scan Bit: Beckhoff
| Brand | First Scan Mechanism | Beckhoff Equivalent |
|--------|----------------------|----------------------|
| Siemens | OB100 | INIT section or FB_FirstScan |
| Rockwell | S:FS (First Scan) bit | bInit variable manually set |
| Codesys | bInit in PLC_PRG | Same (TwinCAT is based on Codesys) |
| Beckhoff Native | INIT, FB_Init, or F_TRIG | Choose based on scope |
Key difference: Beckhoff's system does not have a mandatory, automatic FirstScan system bit. You must explicitly create it. This gives you more control but requires discipline.
Beckhoff provides additional system flags for finer control: beckhoff first scan bit
Use these in combination:
IF FirstScan THEN
IF bInit_Cold THEN
// Full factory reset
ELSIF bInit_Warm THEN
// Restore retain variables, but reinit comms
END_IF
END_IF
During the first scan, you typically want to: | Brand | First Scan Mechanism | Beckhoff
Without a proper first scan routine, your machine might start with actuators in unpredictable positions or unfinished states from a previous run.
PROGRAM MAIN VAR bFirstScan : BOOL := TRUE; // Initialize as TRUE bFirstScanDone: BOOL := FALSE; END_VAR// First scan detection IF bFirstScan AND NOT bFirstScanDone THEN bFirstScanDone := TRUE; // First scan logic here END_IF Beckhoff provides additional system flags for finer control:
// Reset the flag after first cycle IF bFirstScanDone THEN bFirstScan := FALSE; END_IF
⚠️ Caveat: This method can fail if the PLC is stopped/started without power cycle. Always prefer the system library method.