Handling S5 Special Function Blocks (OB, SB) in S7
How to migrate S5 organization blocks (OB) and step blocks (SB) to S7. Covers OB number mapping, startup OBs, interrupt OBs, and SB conversion strategies.
Handling S5 Special Function Blocks (OB, SB) in S7
S5 organization blocks (OBs) and step blocks (SBs) have different numbers and functions than their S7 counterparts. The OB concept exists in both systems, but the numbering is completely different. SBs have no S7 equivalent at all. This guide maps every S5 OB to its S7 counterpart and explains how to handle SBs.
S5 Organization Blocks → S7 Mapping
Cyclic Processing
| S5 OB | Function | S7 OB | Notes |
|---|---|---|---|
| OB 1 | Cyclic main program | OB 1 | Same concept, same number |
Startup / Restart
| S5 OB | Function | S7 OB | Notes |
|---|---|---|---|
| OB 20 | Warm restart (S5-135U/155U) | OB 100 | S7 startup OB |
| OB 21 | Cold restart (manual) | OB 100 | S7 does not distinguish warm/cold at OB level — use OB 100 startup info |
| OB 22 | Restart after power recovery | OB 100 | Same — all startup through OB 100 |
Key difference: S5 has separate OBs for different startup types (OB 20/21/22). S7 uses a single OB 100 for all startups. The startup type (warm/cold/complete restart) can be determined from OB 100's start information within the block.
Time-Driven / Cyclic Interrupts
| S5 OB | Function | S7 OB | Notes |
|---|---|---|---|
| OB 10–OB 18 | Cyclic interrupts (configurable intervals) | OB 30–OB 38 | S7 cyclic interrupt OBs (default intervals: 5s, 2s, 1s, 500ms, 200ms, 100ms, 50ms, 20ms, 10ms) |
| OB 13 | Time-controlled interrupt (S5-95U/115U) | OB 35 | Typical: OB 35 with 100ms default |
Key difference: In S5, cyclic interrupt intervals are configured in DB1. In S7, they are configured in the hardware configuration (CPU properties) or directly in OB properties.
Process / Hardware Interrupts
| S5 OB | Function | S7 OB | Notes |
|---|---|---|---|
| OB 2 | Process interrupt (hardware interrupt) | OB 40–OB 47 | S7 has 8 hardware interrupt OBs |
| OB 3 | Process interrupt (second channel) | OB 40–OB 47 | Map to appropriate HW interrupt OB |
Error and Diagnostic OBs
| S5 OB | Function | S7 OB | Notes |
|---|---|---|---|
| OB 31 | Scan time monitoring (watchdog retrigger) | SFC 43 "RE_TRIGR" | S7 uses a system function, not an OB |
| OB 34 | Battery failure | OB 81 (power supply fault) | Different number |
| OB 37 | Error handling | OB 85 (program error) or OB 121/122 | S7 has specific error OBs |
Integral (Built-in) OBs
| S5 OB | Function | S7 Equivalent |
|---|---|---|
| OB 251 | PID algorithm | PID_Compact (S7-1500) or FB 41 CONT_C |
OB 251 is not an OB in the S7 sense — it is a built-in function block in S5. In S7, use the PID library functions.
S5 Step Blocks (SB) → S7
Step blocks (Schrittbausteine, SB) are an S5-specific block type for sequential logic. They have no direct S7 equivalent.
What SBs do: SBs are called from the main program (OB1) and contain logic for a specific "step" in a sequence. The S5 operating system does not provide automatic step management — the programmer must implement the step sequence logic manually using markers and conditional jumps.
S7 options for SB migration:
| Option | When to Use | Effort |
|---|---|---|
| Convert SB → FC | Simple SBs with no state management | Low |
| Convert SB → FB | SBs that maintain state (step variables, timers) | Medium |
| Rewrite as GRAPH (S7-GRAPH) | Complex sequential logic with step chains | High (but better result) |
| Convert SB → SCL with CASE | Step sequences using a step counter variable | Medium |
Recommended approach for step sequences:
// SCL implementation of a step sequence (replacing SB logic)
CASE #Step OF
0: // Idle
IF #Start THEN #Step := 1; END_IF;
1: // Step 1: Open valve
#Valve := TRUE;
IF #Level_High THEN #Step := 2; END_IF;
2: // Step 2: Run mixer
#Mixer := TRUE;
#Step_Timer(IN := TRUE, PT := T#30s);
IF #Step_Timer.Q THEN #Step := 3; END_IF;
3: // Step 3: Drain
#Valve := TRUE; #Mixer := FALSE;
IF #Level_Low THEN #Step := 0; END_IF;
END_CASE;
The Converter's Limitations with OBs and SBs
The Siemens S5→S7 converter:
- Converts OB 1 → OB 1 (correct)
- Converts PBs → FCs (correct)
- Converts FBs → FBs (mostly correct)
- Converts SBs → FCs (basic conversion, loses step semantics)
- Does NOT remap OB numbers (OB 21/22 are converted as-is — you must manually place their code into OB 100)
- Does NOT handle OB 31 (watchdog) or OB 251 (PID)
You must manually:
- Move startup code from converted OB 21/OB 22 into S7 OB 100
- Move cyclic interrupt code from converted OB 10–18 into S7 OB 30–38
- Configure interrupt intervals in the S7 hardware configuration (not in DB1)
- Replace OB 251 PID with PID_Compact or CONT_C
- Restructure SB logic if step sequences are critical
Frequently Asked Questions
Are S5 OB numbers the same in S7?
Only OB 1 has the same number and function. All other OBs have different numbers in S7. The converter does not remap them — you must do it manually.
What happens to the code in OB 21 / OB 22 after conversion?
The converter creates blocks with those numbers, but S7 does not use OB 21/22 for startup. You must move the startup logic into S7 OB 100 manually.
Should I use S7-GRAPH for step sequences?
If the original S5 program has clear sequential logic (steps, transitions, parallel branches), S7-GRAPH produces a much cleaner result than converting SBs to FCs. However, GRAPH requires a complete rewrite — it cannot be auto-converted.
Maintained by PLCcheck.ai. Last update: March 2026. Not affiliated with Siemens AG.
Related Articles
S5 Absolute Addressing vs. S7 Symbolic Addressing
Why S5 uses absolute addresses (E 0.0, MW 10, DB10.DW5) and S7 prefers symbolic names (Start_Button, Temperature, Motor.Speed). Migration strategy for converting absolute to symbolic.
8 min read
migration-guideMigrating S5 Counter Programs (Z/ZV/ZR) to S7
How to migrate S5 counter programs to S7. Covers ZV (count up), ZR (count down), BCD format differences, S7 equivalents (S_CU, S_CD, CTU, CTD, CTUD), and common pitfalls.
10 min read
migration-guideUnderstanding S5 Data Blocks (DB0, DB1, DX0) in S7
What are S5 system data blocks DB0, DB1, and DX0? Why they exist, what they contain, and how to handle them during S5 to S7 migration.
10 min read
Analyze your PLC code with AI
PLCcheck Pro explains, documents, optimizes, and migrates PLC code — automatically.
Try PLCcheck Pro →Not affiliated with Siemens AG. S5, S7, STEP 5, STEP 7, and TIA Portal are trademarks of Siemens AG.