← Resources
Fundamentals·5 min read·

The first scan bit and what belongs in it

One scan of initialisation, and a reliable way to make a machine start in a known state.

Short answer

The first scan bit is true for exactly one scan after the processor enters RUN, and false thereafter. It exists to give a program somewhere to initialise: clearing stale state, setting default values, and putting sequences back to a known step. Using it well is what makes a restart predictable.

PLC scan cycleRead inputsSolve logicWrite outputsHousekeepingRepeat1-20MILLISECONDS

Every platform gives you one scan where you know the program has just started. What you do with it determines whether a restart is predictable.

The names

Rockwell exposes S:FS. Siemens gives you a startup organisation block that runs once before the cyclic one. CODESYS platforms expose a first-cycle flag.

Different mechanisms, same idea.

What belongs there

  • Clearing state that should not have survived: step numbers, in-progress flags, stale results.
  • Setting defaults where nothing was stored.
  • Putting sequences back to a known step rather than resuming mid-cycle.
  • Clearing any output command that must require a deliberate restart.
The test: after a power cut, does the machine come back in a state somebody would predict? If the answer depends on what it was doing when the power went, the first scan is not doing enough.

What does not belong there

Anything that takes time. The first scan is a scan, and a long initialisation delays the first solve of the actual program. Move slow work into a sequence that runs over several scans.

Common questions

What should go in the first scan of a PLC program?
Clearing anything that should not survive a restart, setting default setpoints where none are stored, resetting sequences to a safe step, and clearing outputs that must not re-energise. Anything whose stale value would be misleading or dangerous belongs here.
Is the first scan bit the same on every platform?
The concept is universal, the name is not. Rockwell exposes S:FS, Siemens provides a startup organisation block that runs once before the cyclic OB, and CODESYS platforms expose a first-cycle flag. The mechanism differs; the intent does not.

Keep reading