1. Overview: What OB100 Does in an S7-1500 CPU
The S7-1500 organization block OB100 (Startup) is a one-shot routine that the operating system of the CPU calls exactly once immediately after a startup event, before the first scan of the main cyclic organization block OB1 begins. It is the Siemens equivalent of the First Scan bit (S:FS) used in RSLogix 5000 / Studio 5000 for Allen-Bradley ControlLogix, but instead of a single boolean flag, the entire OB body is executed top-to-bottom a single time. This makes OB100 the canonical location to bring the PLC's user program into a deterministic, known-good state before any cyclic logic runs.
OB100 belongs to the startup class of organization blocks. Per the official Siemens documentation, the startup OB called by the CPU depends on the type of restart that occurred:
-
OB100 – Complete restart (warm restart): default startup OB for S7-1500 and most S7-300/400 CPUs. The non-retentive portion of
M,DB,IEC timers/counters, and process image is cleared; retentive data is preserved. - OB101 – Hot restart: only available on specific S7-400 CPUs with hot-restart-capable firmware. Execution resumes from the point of interruption. Not used on S7-1500.
- OB102 – Cold restart: all RAM is initialized; even retentive data is cleared. Used on S7-400 / WinAC RTX. On S7-1500, a cold restart is effectively a power-cycle with no project backup retained.
For a modern S7-1500 CPU such as the CPU 1515-2 PN (6ES7515-2AM02-0AB0) or CPU 1516-3 PN/DP (6ES7516-3AN02-0AB0) running firmware V2.9 or later in TIA Portal V17/V18/V19/V20/V21, OB100 is created automatically when a new project is generated, but its body is left empty by default. The programmer is expected to populate it with whatever initialization the application requires.
2. Prerequisites
| Item | Minimum / Recommended | Notes |
|---|---|---|
| CPU | S7-1500 (any), e.g. CPU 1511-1 PN, 1512C, 1515-2 PN, 1516-3 PN/DP, 1517-3 PN/DP, 1518-4 PN/DP | ET 200SP CPUs (1510SP-1 PN, 1512SP-1 PN) also support OB100 |
| Firmware | V1.8 or higher; V2.9 recommended for latest TIA Portal features | Startup OB behavior is consistent across all S7-1500 firmware versions |
| TIA Portal | V15.1 / V16 / V17 / V18 / V19 / V20 / V21 | OB100 creation procedure is identical across versions |
| User knowledge | Familiarity with LAD/FBD/STL or SCL | OB100 body is programmable in LAD, FBD, STL, or SCL |
| Online connection | PROFINET, PROFIBUS, or Ethernet to engineering PG/PC | Required for download and online monitoring of startup execution |
3. OB100 Execution Lifecycle in an S7-1500 CPU
Understanding when OB100 runs is critical to writing correct initialization code. The lifecycle for a complete restart is:
- Power ON, mode selector change from STOP → RUN, or CPU command Complete restart from TIA Portal.
- CPU clears all non-retentive
M,DBinstance data (static), and process image of inputs/outputs. - CPU evaluates retentive flags:
Mbits declared retentive in the PLC tag table,DBvariables marked Retain, and IEC counters/timers flagged retentive are preserved. - CPU clears the non-retentive portion of the process image outputs (PIQ) to zero.
- CPU calls OB100 once.
- CPU writes outputs from the PIQ to the physical outputs.
- CPU enters RUN mode and begins cyclic execution of OB1 (or the cyclic interrupt OB assigned priority 1).
If OB100 is not present in the project, the CPU simply skips step 5 and proceeds to cyclic execution. If OB100 exists but is empty, it still runs as a one-shot no-op. If OB100 raises an unhandled error, the CPU transitions to STOP.
4. Creating OB100 in TIA Portal – Step-by-Step
- Open the S7-1500 station in the project tree.
- Expand Program blocks.
- Double-click Add new block.
- Set the type dropdown to Organization block (OB).
- From the OB family list, select Startup; the dropdown shows OB100 by default.
- Choose a programming language: LAD, FBD, STL, or SCL. SCL is recommended for complex initialization with arrays and loops.
- Click OK. TIA Portal generates the OB100 skeleton with the startup information local variables (
OB100_START_EV_ID,OB100_STRTUP_INF,OB100_PRIORITY,OB100_OB_NUMBR). - Add the initialization code in the OB body.
- Compile the project and download to the target CPU.
5. Startup Information Available in OB100
Every call of OB100 receives a 20-byte OB100_STARTUP_INFO temporary variable visible in the block's interface. Useful fields:
| Temporary Variable | Data Type | Meaning |
|---|---|---|
OB100_EV_CLASS |
BYTE | Event class 0x13 = standard startup event |
OB100_STRTUP_INF |
WORD | Startup reason: 0x0001 = Manual complete restart via mode switch 0x0002 = Automatic complete restart after power on 0x0003 = Restart requested by SFC / HMI 0x0004 = Restart after cold restart (S7-400) |
OB100_PRIORITY |
INT | Priority class (27 by default for OB100) |
OB100_OB_NUMBR |
INT | OB number (100) |
OB100_RESERVED_1 |
WORD | Reserved |
OB100_RESERVED_2 |
WORD | Reserved |
OB100_STOP |
WORD | Stop cause from previous STOP |
OB100_STRT_INFO |
DWORD | Additional startup information |
OB100_DATE_TIME |
DATE_AND_TIME | Date/time the OB was called |
Reading OB100_STRTUP_INF lets the same OB100 react differently to a power-on versus a download-restart versus a manual mode-switch restart — useful for skipping warmup delays after a download.
6. Typical Initialization Tasks for OB100
Engineering teams conventionally use OB100 to perform the following kinds of work. The exact list is process-specific.
| Category | Example Action | Why in OB100 |
|---|---|---|
| DB variable initialization | Zero counters, clear recipe flags, set default setpoint | Brings FB instances to a known state at power-on |
| Module parameter writes |
WRREC writes to analog-output range or IO-Link port configuration |
Configuration is sticky but verifying at startup catches parameterization corruption |
| Latched-bit cleanup |
R latched alarms and warning latches in HMI tag DB |
Resets post-fault latches so the operator sees a clean alarm page |
| Connection status | Force PN_Connection_OK tags to FALSE so cyclic OB re-evaluates them |
Prevents stale TRUE from a previous session |
| Drive handshakes | Pulse Drive_Cmd_Wakeup for 1 cycle to resync state machine |
Drives may have powered up in unknown state |
| Warmup delays | Start an IEC timer that blocks auto-mode for 10 s | Allows VFDs / heaters to ramp before auto-control engages |
| Password / safety state | Set Safety_Lockout = TRUE after E-Stop |
Forces manual reset path after a fault |
| Recipe selection | Load last-recipe-number from retentive DB | Restores recipe after power loss |
7. Sample Code – LAD, FBD, and SCL
7.1 LAD example – Reset and initialize
// OB100 (Startup) – LAD
// Brings process into a deterministic state at complete restart
Network 1: // Reset process-level latched alarms
SET
R "HMI_DB".Alarm_Latch_1 // reset warning latch
R "HMI_DB".Alarm_Latch_2
R "HMI_DB".Alarm_Latch_3
R "HMI_DB".Fault_Latch_Pump
Network 2: // Initialize non-retentive DB counters
L 0
T "Process_DB".Cycle_Counter // INT
T "Process_DB".Reject_Counter // INT
T "Process_DB".Batch_Number // INT
Network 3: // Default values
L 100
T "Recipe_DB".Setpoint_Temp // default setpoint, °C
L 50.0
T "Recipe_DB".Setpoint_Flow // REAL default
Network 4: // Move state machine to safe state
L 0 // 0 = SAFE_INIT
T "State_DB".State_Current
S "State_DB".Safety_Lockout // force manual reset after power-on
Network 5: // Mark first scan in a flag for cyclic OB1 to read
SET
S "Sys_DB".First_Scan_Done // will be reset in OB1 after use
7.2 SCL example – Conditional warmup based on startup reason
// OB100 (Startup) – SCL
IF OB100_STRTUP_INF = 16#0001 THEN // manual restart via mode switch
"Process_DB".Warmup_Seconds := 30; // long warmup – drives are cold
"Process_DB".Auto_Mode_Allow := FALSE;
ELSIF OB100_STRTUP_INF = 16#0002 THEN // automatic restart after power on
"Process_DB".Warmup_Seconds := 60; // longer warmup after power loss
"Process_DB".Auto_Mode_Allow := FALSE;
ELSIF OB100_STRTUP_INF = 16#0003 THEN // restart via HMI / SFC
"Process_DB".Warmup_Seconds := 10; // short warmup – just after download
"Process_DB".Auto_Mode_Allow := FALSE;
END_IF;
7.3 STL example – For legacy ports from S7-300 projects
// OB100 (Startup) – STL
SET
R M 200.0 // reset operator message queue
R M 200.1
R M 200.2
L 0
T DB10.DBW 0 // recipe slot = 0
T DB10.DBW 2 // batch count = 0
SET
S M 250.7 // "Restart_Active" for OB1 to read
8. Alternative: System Memory Byte and First-Scan Bit
Siemens offers a second mechanism that resembles the Allen-Bradley S:FS pattern: System Memory Bytes. Unlike Allen-Bradley's single first-scan bit, the S7-1500 system clock memory byte and first-scan bit are enabled in the CPU properties.
| System Memory Byte | Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
|---|---|---|---|---|---|---|---|---|
| Clock Memory Byte (default MB0) | 2 Hz | 1.6 Hz | 1 Hz | 0.8 Hz | 0.5 Hz | 0.4 Hz | 0.2 Hz | 10 Hz |
| First-Scan Memory Byte (default MB1) | 1st scan (always 1 on transition 0→RUN) | — | — | — | — | — | — | — |
To enable this in TIA Portal:
- Open Device view, select the CPU.
- In the Properties inspector go to System & clock memory.
- Check Enable system memory byte; default address is MB1. The highest bit (M1.7) is the first-scan bit — it is TRUE only on the first cyclic scan of OB1 after a startup.
- Check Enable clock memory byte; default address is MB0.
Use the first-scan bit for one OB1 cycle initialization (e.g. preset a counter value to 0). Use OB100 for one block execution initialization (preset dozens of tags, evaluate startup reason, send WRREC, etc.). Many engineers use both: the heavy lifting in OB100, and a final fine-tune inside the first OB1 cycle gated by M1.7.
9. Retentive vs Non-Retentive Variables – What OB100 Should Reset
Understanding the CPU's retentive behavior avoids redundant writes in OB100.
| Memory Area | Default Behavior on Complete Restart | OB100 Reset Needed? |
|---|---|---|
Non-retentive M (M0..M<retentive_start>-1) |
Cleared to 0 | No – already 0 |
Retentive M (M<retentive_start>..M<range_end>) |
Preserved | Yes if application needs them cleared |
| Process image of inputs (PII) | Refreshed on next OB1 cycle | No |
| Process image of outputs (PIQ) | Cleared to 0 (safety default) | No – outputs safe-by-default |
| DB with all variables Non-retain | Cleared | No |
| DB with some variables Retain | Retain values preserved | Yes if those values need clearing at startup |
| IEC timer / counter with Retain | Preserved | Yes if you need them reset |
| Local stack of OB1 (TEMP variables) | Indeterminate on first call | Yes – always initialize TEMP before read |
Configure retentive ranges in Device view → CPU properties → Retentive memory. For S7-1500 CPUs the default is retentive from MB0 to MB15, and one or two DBs may be flagged retain in the DB properties. Adjust per process requirements.
10. Diagnosing and Verifying OB100 Execution
- Compile and download the project.
- Switch the CPU to STOP, then to RUN.
- Open Online & diagnostics → Diagnostics → Cycle / Time; the diagnostic buffer will list the OB100 call timestamp and a startup reason code matching
OB100_STRTUP_INF. - Open Watch table with the variables OB100 should set. Add the watch table to the Trigger condition: Once at startup or On transition to RUN. This forces TIA Portal to capture the values from the first scan.
- Force the CPU to STOP → MRES → RUN (memory reset) to confirm the same initialization occurs even with retentive data cleared.
- Pull the 24 V supply to simulate a real power loss; confirm warmup timers and latched-alarm resets still fire correctly.
To inspect the startup information in real time, monitor the OB100 temporaries with a Monitor with trigger session. Because the temporaries are valid only inside OB100, set the trigger condition to On start of OB for OB100 to capture the values during the single execution.
11. OB100 vs Cyclic OB1 – Comparison
| Attribute | OB100 (Startup) | OB1 (Main cyclic) |
|---|---|---|
| Trigger | Complete restart event | Free-running cyclic at configured minimum cycle time |
| Execution count | 1 per startup | Continuous (every cycle) |
| Cycle time contribution | Adds to startup time, not OB1 cycle | Adds to cyclic scan |
| Watchdog | 300 ms default for S7-1500 startup OBs (configurable) | 150 ms default (configurable) |
| Priority | 27 (fixed) | 1 (lowest cyclic) |
| Process image read | Inputs refreshed before OB; outputs written after OB returns | Same per cycle |
| Time-of-day interrupts | Suspended during startup | Run normally |
| Suitable for long I/O writes | Yes (still keep < 5 ms) | Yes, but use async pattern |
12. Troubleshooting Matrix
| Symptom | Likely Cause | Resolution |
|---|---|---|
| CPU goes to STOP immediately after RUN | Unhandled error inside OB100 (e.g. divide by zero, range error on WRREC) |
Open diagnostic buffer; fix the error in OB100; recompile |
| Variables still hold old values after power-on | Variables declared Retain; OB100 does not reset them | Add explicit reset assignments in OB100, or uncheck Retain in the DB property |
| First-scan bit does not pulse | System memory byte not enabled, or wrong address used in program | Enable System memory byte in CPU properties; verify address matches |
| Drives do not respond after restart | OB100 reset hand-shake bits that drive state machines rely on, but does not re-trigger the handshake | Add a single-cycle pulse at the end of OB100 to re-init the drive comms |
| Outputs energize at power-on even though program should start safe | OB1 reads from PIQ before WRREC completes in OB100; OB1 not gated by a startup flag |
Set a Startup_Done flag in OB100; gate all output writes in OB1 by Startup_Done
|
| OB100 watchdog trips (Diagnostic event 16#3501) | Loop / heavy computation in OB100 | Limit OB100 to deterministic init; move time-consuming work to a follow-up OB (e.g. OB123 time-of-day interrupt at priority 12) |
| OB100 not called at all | Project downloaded without OB100, or OB100 explicitly deleted | Recreate OB100 in project tree; re-download; confirm in Program blocks view |
13. Best-Pattern Template for a New Project
Use this SCL skeleton in OB100 to give every S7-1500 project a consistent, safe startup:
// OB100 – SCL – Project-wide startup template
// 1. Reset non-retentive process counters
FOR i := 1 TO 16 DO
"Proc_DB".Counters[i] := 0;
END_FOR;
// 2. Apply safe defaults
"Proc_DB".Auto_Mode_Allow := FALSE;
"Proc_DB".Safety_Lockout := TRUE; // require manual reset
"Proc_DB".Warmup_Seconds := 30;
// 3. Re-arm communication status
"Comm_DB".PN_C1_Healthy := FALSE;
"Comm_DB".PN_C2_Healthy := FALSE;
// 4. Write module parameters (per requirement)
// WRREC variant example:
// ret := WRREC(REQ := TRUE, IOID := 0, LADDR := 288, RECORD := "IO_DB".Cfg_Rec);
// 5. Single-cycle re-init pulse for cyclic OB to read
"Sys_DB".First_Scan_Done := TRUE;
Pair this with a one-line consumption in OB1:
// OB1 – Network 1
IF "Sys_DB".First_Scan_Done THEN
// 1-shot init that requires PIQ to be available
"Proc_DB".Drive_Handshake := TRUE;
"Sys_DB".First_Scan_Done := FALSE;
END_IF;
14. Cross-Platform Notes (Allen-Bradley and Beckhoff Equivalent)
| Platform | Equivalent of OB100 | Notes |
|---|---|---|
| Allen-Bradley ControlLogix / CompactLogix | Task with S:FS (first scan) bit; or PLC task configured as Startup (rare) | Single S:FS boolean inside an SFC or ladder routine |
| Allen-Bradley SLC 500 / MicroLogix |
S2:1/15 first pass bit in S2 status file |
One-shot per mode change |
| Beckhoff TwinCAT 3 |
PlcTaskDef.PlcTaskFlags.STARTUP; _TaskInfo.FirstCall
|
Init method or FB_Init
|
| CODESYS V3 | Prg with Init property = true; or __INIT method |
Run once after download/restart |
| Siemens S7-1200 | Same OB100 mechanism; identical syntax | Use the same template |
15. Standards, Manuals, and Official References
The following Siemens official documentation is the authoritative source for OB100 behavior, startup information, and configuration:
Additional official references (TIA Portal help portal, Function Manual "S7-1500 Automation System", and the Program Lifecycle / Organization Blocks chapter) describe the OB100 temporary interface and the startup event class codes shown in section 5. Always cross-check the local Siemens Industry Online Support portal for the firmware version of your specific CPU before relying on any timing value.
What is OB100 in an S7-1500 CPU?
OB100 is the startup organization block, executed once by the CPU immediately after a complete restart, before OB1 starts cycling. Use it for one-shot initialization such as resetting DB counters, clearing latched alarms, writing module parameters, and forcing the process into a known safe state.
How is OB100 different from the S7-1500 system memory first-scan bit?
The system memory byte (default MB1) exposes a first-scan flag in bit 7 that is true for one OB1 cycle. OB100 runs once before the cyclic OB1, evaluates the startup reason, and can perform heavier work like WRREC. Many programs use both: OB100 for bulk init, and M1.7 inside OB1 for the very first cycle's fine-tune.
Why does my OB100 not reset certain variables after a power cycle?
Variables you declared Retain in the DB properties, or M bits inside the configured retentive range, are intentionally preserved across restarts. Either remove the Retain attribute or add explicit reset assignments inside OB100 for those tags.
Can OB100 contain blocking calls like SFB / SFC communication?
Yes, but limit them. The OB100 watchdog is 300 ms by default on S7-1500. Long PUT/GET or WRREC calls can exceed this and force the CPU to STOP with diagnostic event 16#3501. For heavy work, gate the call in OB1 or use a high-priority time-of-day interrupt that runs once shortly after startup.
What startup reason does OB100_STRTUP_INF return after a TIA Portal download?
Per the Siemens documentation the values are 0x0001 (manual complete restart), 0x0002 (automatic complete restart after power on), and 0x0003 (restart requested by SFC / HMI / online download). Read OB100_STRTUP_INF in the first network of OB100 if you need to branch the initialization on the reason.