Overview of S7-300/S7-400 Startup Organization Blocks
Startup organization blocks (OB100, OB101, OB102) are executed exactly once during the transition of a Siemens SIMATIC S7-300 or S7-400 CPU from STOP to RUN. They are not part of the cyclic scan; they are called once by the operating system immediately before OB1 takes over, and the start information is supplied in the OB's local data (TEMP area). After the startup OB completes, normal cyclic execution begins. Code placed in OB100, OB101, or OB102 therefore represents a one-shot, deterministic initialization phase that runs before any scan of the user program.
Three restart behaviors are defined in the SIMATIC firmware, each with its own organization block:
-
OB100 – Complete restart (warm restart): default restart for S7-300 and S7-400 when the CPU is switched from
STOPtoRUNor after power-off/power-on with a backup battery retaining memory. - OB101 – Hot restart: only supported on S7-400 (and S7-400H). The program resumes at the point of interruption as if nothing happened; all dynamic data is preserved.
- OB102 – Cold restart: only supported on selected S7-400 CPUs. The program starts with the initial values from the load memory; all retentive flags, DB contents, timers, and counters are cleared.
For a complete description in the current documentation set, see the Siemens manual Startup organization blocks (OB 100, OB 101 and OB 102) – TIA Portal V21.
Restart Type Comparison
| Property | OB100 (Complete restart) | OB101 (Hot restart) | OB102 (Cold restart) |
|---|---|---|---|
| Typical use | Default startup after STOP → RUN or power on with battery | Resume a process after a brief power dip without losing position/state | Reset to a known clean state, e.g. after a recipe change or full plant reset |
| Process image outputs | Set to 0 (or default), user program writes in OB100/OB1 | Restored from buffered state, drives and actuators resume | Set to 0; user program must rewrite |
| Retentive flags / DB data | Preserved | Preserved | Cleared (initial values from load memory) |
| Non-retentive flags | Cleared | Preserved in S7-400 buffered RAM | Cleared |
| Timers / counters | Cleared | Preserved if backed up | Cleared |
| Supported on S7-300 | Yes (CPU 312 through CPU 319) | No | No |
| Supported on S7-400 | Yes (all CPUs) | Yes (CPU 41x except entry-level 400H configurations) | Yes (legacy CPU 4x3/4x5/4x7 only; not on newer 410/PN) |
| Maximum OB execution time | CPU-dependent, typically a few seconds; CPU goes to STOP if exceeded | Same | Same |
| Local data (TEMP) | 20 bytes start info | 20 bytes start info | 20 bytes start info |
OB100 — Complete Restart (Warm Restart)
OB100 is the only startup OB that exists on every S7-300 and S7-400 CPU. It runs when the CPU transitions to RUN after any of these events:
- CPU mode selector moved from
STOPtoRUNorRUN-P. - Power off / power on with battery-backed RAM retained (warm restart).
- PG command PLC → Cold Restart / Complete Restart from STEP 7 or TIA Portal.
- Self-initialization after a programming/download operation.
Typical content for OB100:
- Reset non-retentive machine flags.
- Initialize the first-scan bit pattern.
- Pre-load recipe data from a DB.
- Bring drives to a defined reference state.
- Set or clear specific outputs in the process image.
Reading OB100 start information
OB100 receives 20 bytes of local data populated by the operating system. The most-used fields are OB100_EV_CLASS (event class, typically B#16#13), OB100_STRT_INFO (restart cause), and OB100_PRIORITY (priority class 27 on most CPUs). In SCL/ST you can read them as local TEMP variables of type BYTE/WORD.
OB101 — Hot Restart (S7-400 only)
OB101 is only available on S7-400 (and S7-400H) CPUs. It allows the program to resume execution at the exact instruction pointer where the power failure occurred, without losing any dynamic state — provided the backup battery preserved the work memory and the power dip was within the CPU's buffer time. This is the closest behavior to a true "continue where you left off" mode that S7-400 offers.
OB101 must be enabled in the CPU's hardware configuration under Properties → Startup. The setting Hot restart determines whether the firmware attempts a hot restart or falls back to a complete restart (OB100) if conditions are not met.
STOP — that always leads to OB100.OB102 — Cold Restart (S7-400 only)
OB102 is supported on the older S7-400 CPU families (CPU 4x3 / 4x5 / 4x7). It forces the CPU to load all data blocks and flags from their initial values, exactly as if the program had just been downloaded. OB102 is enabled from the mode selector or from STEP 7 / TIA Portal with a Cold restart command. It is rarely used in continuous process plants because it wipes recipe and production data; it is more typical of machine building where every shift starts from a defined clean state.
Newer S7-400 CPUs (CPU 410, CPU 416F, the SIPLUS variants) and every S7-300 do not implement OB102 at all. Calling OB102 on an unsupported CPU raises an OB not loaded fault and the CPU remains in STOP.
CPU Compatibility Matrix
| CPU family | OB100 | OB101 | OB102 | Notes |
|---|---|---|---|---|
| S7-300 CPU 312, 313, 314 | ✓ | ✗ | ✗ | OB100 only |
| S7-300 CPU 315-2 PN/DP, 317, 319 | ✓ | ✗ | ✗ | OB100 only; PN/DP variants add Profinet/PROFIBUS diagnostics during startup |
| S7-400 CPU 412-1, 412-2 | ✓ | ✓ | ✗ | Entry-level; no cold restart |
| S7-400 CPU 414-2, 414-3, 416-2, 416-3 | ✓ | ✓ | ✓ | Full startup OB set |
| S7-400 CPU 417-4 | ✓ | ✓ | ✓ | Highest performance; full startup OB set |
| S7-400H (e.g. CPU 412-3H, 414-4H, 416-3H, 417-4H) | ✓ | ✓ | Partial | OB102 not used in H-systems; hot restart is the preferred resume path |
Programming OB100 in STEP 7 Classic (LAD / FBD / STL)
To create a startup OB in STEP 7 V5.x:
- Open the S7 project in SIMATIC Manager.
- Right-click the Blocks container in the S7 program.
- Choose Insert New Object → Organization Block.
- In the dialog, change the default OB number from 1 to
100,101, or102. - Open the new block, add a network, and write the initialization code.
Minimal STL example in OB100 that sets flag M10.0 on first scan:
// OB100 — Complete Restart
SET
= M10.0 // FirstScan_CompleteRestart
L 0
T MW12 // Clear a scratch word
SET
= M10.1 // Optional: drive ready-to-run latch
BE
Every time the CPU executes a complete restart, M10.0 will go TRUE. Because M10.0 is retentive, the bit survives a power dip and can be checked in OB1 by reading its current value. To get a true one-shot in OB1 on each restart, place a one-shot logic in OB1 that detects the rising edge of M10.0 together with the falling edge of OB1_prev_run.
Programming OB100 in TIA Portal (SCL)
In TIA Portal (V16 and newer, including V21) the procedure is identical for the project tree:
- Expand the PLC device folder → Program blocks.
- Double-click Add new block.
- Choose type Organization block, name it
OB_Startup(or keep default). - Set the OB number to
100manually in the block properties. - Edit the block in LAD, FBD, or SCL.
SCL example for OB100 that initializes recipe parameters and a few machine flags:
// OB_Startup (OB100) — Complete Restart, SCL
IF "FirstScan" THEN // FirstScan is a system-side flag in S7-1500; on S7-300 use a manual bit
RETURN;
END_IF;
// Reset non-retentive state
"Machine".StepNumber := 0;
"Machine".FaultWord := 0;
"Machine".CycleCount := 0;
// Initialize recipe pointer
"Recipe".ActiveID := 0;
// Set outputs in process image to safe default
"DO_ConveyorStart" := FALSE;
"DO_HeaterEnable" := FALSE;
// Latch the one-shot flag
"FirstScan" := TRUE;
For the current Siemens documentation, see Startup organization blocks (OB 100, OB 101 and OB 102).
Reading the Startup Information Bytes
All three startup OBs receive 20 bytes of standardized start information in their TEMP area. The fields of practical interest in S7-300/S7-400 are:
| Local variable | Type | Meaning |
|---|---|---|
OB10x_EV_CLASS |
BYTE | Event class: B#16#11 = OB active, B#16#13 = OB cancel |
OB10x_STRT_INF |
BYTE | Startup cause (1 = manual, 2 = after power on, 3 = restart via PG, …) |
OB10x_PRIORITY |
INT | Priority class (typically 27) |
OB10x_OB_NUMBR |
INT | OB number (100, 101, 102) |
OB10x_RESERVED_1 |
BYTE | Reserved |
OB10x_RESERVED_2 |
BYTE | Reserved |
OB10x_STOP |
WORD | Event that caused the stop (e.g. SF LED fault) |
OB10x_STRTUP |
WORD | Additional startup info (restart type, time-of-day, …) |
OB10x_STOP_TIME |
DATE_AND_TIME | Time stamp of the STOP event |
Use these fields to log or display the precise reason for a startup in your HMI, which is invaluable when a process line trips overnight and the on-shift engineer needs to know whether it was a manual stop, a watchdog, or a power event.
Process Resumption After Power Loss — Picking the Right OB
The recurring field question is: "My line lost power; which OB makes the process continue where it stopped?"
- If the CPU is an S7-300: you only have OB100. The CPU will complete-restart, which means timers/counters/non-retentive flags are reset but the program is intact. You must design the application to either: (a) save its current state to retentive DBs periodically and reload them in OB100, or (b) treat every cold power-on as a manual restart and require an operator to resume the line.
- If the CPU is an S7-400 with hot restart enabled (OB101): the firmware restores all dynamic state and resumes the OB1 instruction pointer automatically. You still need OB100 for a clean manual stop-start, but OB101 handles unplanned power dips below the backup time window.
- OB102 is the wrong choice for resume-after-power-failure; it deliberately throws away state.
A robust "resume where we left off" pattern on S7-300 is to write the critical state (current step, position, recipe index) to a retentive DB every scan, then read that DB back in OB100 and force the matching outputs before OB1 starts. The OB100 + OB1 split guarantees deterministic behavior on every power-up.
Practical Patterns for OB100
1. First-Scan Latch
// OB100
SET
= M 10.0 // FirstScan_OB100
Use FP M10.0 in OB1 if you need a single one-shot edge per restart. Because M10.0 is retentive, it survives across restarts, so a true one-shot must use an edge detector each scan.
2. Default Output Image
// OB100 — write safe defaults to the process image
L 0
T QB 0 // Byte 0 outputs to 0
L 0
T QB 4 // Byte 4 outputs to 0
This is essential for safety: with OB100 absent or empty, the process image outputs are zero on every restart, which can cause unexpected movement if your application relied on outputs being latched from the previous run.
3. Drive Pre-Charge
Many SINAMICS G/S drives expect a control word handshake in the right order at startup. OB100 is the right place to set STW1 to the defined pre-charge pattern (e.g. W#16#047E) before the cyclic OB1 takes over the velocity ramp.
4. Recipe Load
On restart, copy the active recipe from the retentive "shadow" DB to the working DB:
CALL FB 100, DB100 // Copy_Recipe_Shadow_To_Working
Diagnostics: What to Look at When Startup Fails
If the CPU does not reach RUN after a power-on, the most common causes involving OB100/101/102 are:
| Symptom (LEDs / diagnostic buffer) | Probable cause | Remedy |
|---|---|---|
| SF (red) on, CPU in STOP, diagnostic buffer: OB not loaded / OB100-OB102 | Startup OB present in project but not downloaded, or wrong OB number | Recompile and download all blocks including the OBs; verify OB number matches the restart type |
| CPU cycles between RUN and STOP every few seconds | OB100 exceeds the maximum allowed execution time, watchdog trips | Remove long delays, SFB/SFC calls that block, or heavy communication; split initialization across OB100 and a follow-up SFC sequence |
| Hot restart requested but CPU runs OB100 instead | Backup battery discharged, or power-down time exceeded the CPU's reserve, or PG/cable requested a complete restart | Check battery; reduce restart class in CPU properties; verify the S7-400 mode selector is in RUN, not RUN-P with manual switch |
| OB101 called on S7-300 → STOP | OB101 does not exist on S7-300 | Remove OB101 from the project; implement resume logic in OB100 |
| OB102 called on CPU 410/PN → STOP | Cold restart not supported on that CPU | Delete OB102; rely on OB100 |
| Diagnostic buffer shows Priority class 27 → OB not found | OB is referenced indirectly (e.g. SFC call) but missing from the program | Insert the matching OB in Program blocks and re-download |
Commissioning Procedure for Startup OBs
- Open the CPU's Device view in TIA Portal and confirm the configured Startup behavior (e.g. Complete restart).
- Insert OB100 in the project, even if empty, so the CPU does not fault on OB not loaded.
- Add your initialization logic and compile. Watch the Compile log for unused tags and overlapping TEMP variables.
- Download in STOP first to force a complete restart and verify the OB100 path.
- From the online Diagnostics → Diagnostic buffer, confirm that the most recent entry shows Complete restart triggered by … and the start time matches.
- Force a power-off / power-on test. Check the SF / BF / DC5V LEDs, the diagnostic buffer, and the values in your retentive DBs.
- For S7-400 with hot restart enabled, perform a controlled power dip (e.g. < 1 s) and confirm the CPU returns via OB101 with retained state.
- Document the expected output state for the first OB1 scan in your functional specification so that operators know what to expect on every restart.
Common Pitfalls
- Confusing scan order: OB100 runs before OB1, not in parallel. Do not place logic in OB1 that depends on OB100 having set a flag in the same scan — it does, but only on the first cycle. Subsequent cycles start with OB1 alone.
- Heavy work in startup OB: anything that takes more than a few seconds (e.g. FTP transfers, slow I/O) can trigger the OB watchdog and drop the CPU into STOP.
- Forgetting OB100 in a new project: on a S7-300 the CPU still starts even without OB100, but no user initialization is executed. Many plants run with empty OB100 for years until they add a recipe or a drive and discover that outputs are not in the expected state.
- Re-downloading with retentivity set to false: STEP 7 / TIA Portal can reset the Retentivity property of DBs if you change the block interface. This is the most common reason an "OB100 that used to work" suddenly loses the resume-from-state behavior.
- OB100 not present in the offline/online diff: during partial downloads, OB100 can be skipped if its timestamp matches but the rest of the program has changed. Always do a full download before commissioning a startup sequence.
Quick Reference: When to Use Which OB
| Scenario | Recommended OB | CPU family |
|---|---|---|
| Default startup of an S7-300 machine | OB100 | S7-300 |
| Default startup of an S7-400 machine with no special resume needs | OB100 | S7-400 |
| Continuous process plant that must resume after a brief power dip | OB101 (enable hot restart in HW config) | S7-400 (CPU 41x) |
| Recipe-driven machine that should start from a known clean state each shift | OB102 (legacy S7-400) or OB100 + manual reset in OB1 (modern) | S7-400 legacy / any |
| Migration project from S7-300 to S7-1500 | OB100 on S7-300; on S7-1500 use the built-in system Startup blocks (OB100/101/102) per TIA Portal V21 docs | S7-300 / S7-1500 |
FAQ
What is the difference between OB100, OB101, and OB102 on S7-300/S7-400?
OB100 is the complete (warm) restart and runs by default on every S7-300 and S7-400 CPU. OB101 is the hot restart, available only on S7-400 (CPU 41x), which resumes the OB1 instruction pointer with all dynamic data preserved after a short power dip. OB102 is the cold restart, available only on legacy S7-400 CPUs, which resets every flag, timer, counter, and DB to its load-memory initial value. See the Siemens manual entry Startup organization blocks (OB 100, OB 101 and OB 102).
Do I have to create OB100 manually, or is it already in the project?
It is not created automatically. You must insert OB100 in the Blocks folder (STEP 7) or Program blocks (TIA Portal). If OB100 is missing, the CPU still goes to RUN on a complete restart, but the user program receives no initialization phase and the process image outputs start at 0.
How do I make my process continue exactly where it stopped after a power failure?
On S7-400, enable Hot restart in the CPU's startup properties and create OB101. Ensure the backup battery is healthy so RAM is retained during the dip. On S7-300 there is no hot restart; you must save the process state to a retentive DB and reload it in OB100, or require an operator to resume.
Why does the CPU drop to STOP when I add OB101 to my S7-300 project?
OB101 is not supported on any S7-300 CPU. Calling or inserting it raises an OB not loaded event. Delete OB101 from the project and put the same logic in OB100.
How can I tell which startup OB actually ran on the last restart?
Open Online → Diagnostics → Diagnostic buffer in STEP 7 or TIA Portal. The most recent Complete restart / Hot restart / Cold restart event lists the cause (manual, power on, PG command), the time stamp, and which OB was called. You can also read OB10x_STRT_INF and OB10x_STOP_TIME from the local TEMP data if your OB100 writes them to a log DB.