In legacy TwinCAT 2 and early TwinCAT 3 projects using the Tc2_Standard library, the standard way to get a first scan bit is:
This ensures a clean, new log file is created each time the controller starts, without overwriting historical data. beckhoff first scan bit
The first scan bit is a versatile tool used in nearly every professional PLC project. In legacy TwinCAT 2 and early TwinCAT 3
IF fbFirstScan.bFirstScan THEN (* Force reset retain values on fresh download *) rMotorPosition := 0.0; // Even if retain, reset on first scan bRecipeLoaded := FALSE; END_IF // Even if retain
The is a system-generated boolean flag that is TRUE for exactly one PLC cycle after: