PROGRAM MAIN VAR fbFirstScan : TON; bFirstScan : BOOL; END_VAR // Implementation fbFirstScan(IN := NOT fbFirstScan.Q, PT := T#1MS); bFirstScan := NOT fbFirstScan.Q;
But this is still a workaround. The most professional method in Tc3_Standard is to use the StandardLib (from Beckhoff Automation) which includes FB_FirstScan directly. Beckhoff TwinCAT offers built-in program-local initialization flags that many users overlook: INIT and EXIT sections within a program. beckhoff first scan bit
// Main cyclic code myOutput := TRUE; // Normal logic PROGRAM MAIN VAR fbFirstScan : TON; bFirstScan :
PROGRAM MAIN VAR myOutput : BOOL; END_VAR // INIT section runs once when program is loaded/started INIT myOutput := FALSE; // Set safe state // Home axes, clear arrays, etc. // Main cyclic code myOutput := TRUE; //
IF fbFirstScan() AND (nEtherCATState = 8) THEN // 8 = OP EnableOutputs(); END_IF Here is a professional, production-ready template for a Beckhoff PLC main program:
: The official Tc3_Standard provides a clean helper: