PLCcheck

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.

·12 min read
S5S7OBSBorganization blockstep blockstartupinterruptmigrationOB1OB100

Diesen Artikel auf Deutsch lesen

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 OBFunctionS7 OBNotes
OB 1Cyclic main programOB 1Same concept, same number

Startup / Restart

S5 OBFunctionS7 OBNotes
OB 20Warm restart (S5-135U/155U)OB 100S7 startup OB
OB 21Cold restart (manual)OB 100S7 does not distinguish warm/cold at OB level — use OB 100 startup info
OB 22Restart after power recoveryOB 100Same — 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 OBFunctionS7 OBNotes
OB 10–OB 18Cyclic interrupts (configurable intervals)OB 30–OB 38S7 cyclic interrupt OBs (default intervals: 5s, 2s, 1s, 500ms, 200ms, 100ms, 50ms, 20ms, 10ms)
OB 13Time-controlled interrupt (S5-95U/115U)OB 35Typical: 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 OBFunctionS7 OBNotes
OB 2Process interrupt (hardware interrupt)OB 40–OB 47S7 has 8 hardware interrupt OBs
OB 3Process interrupt (second channel)OB 40–OB 47Map to appropriate HW interrupt OB

Error and Diagnostic OBs

S5 OBFunctionS7 OBNotes
OB 31Scan time monitoring (watchdog retrigger)SFC 43 "RE_TRIGR"S7 uses a system function, not an OB
OB 34Battery failureOB 81 (power supply fault)Different number
OB 37Error handlingOB 85 (program error) or OB 121/122S7 has specific error OBs

Integral (Built-in) OBs

S5 OBFunctionS7 Equivalent
OB 251PID algorithmPID_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:

OptionWhen to UseEffort
Convert SB → FCSimple SBs with no state managementLow
Convert SB → FBSBs that maintain state (step variables, timers)Medium
Rewrite as GRAPH (S7-GRAPH)Complex sequential logic with step chainsHigh (but better result)
Convert SB → SCL with CASEStep sequences using a step counter variableMedium

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:

You must manually:

  1. Move startup code from converted OB 21/OB 22 into S7 OB 100
  2. Move cyclic interrupt code from converted OB 10–18 into S7 OB 30–38
  3. Configure interrupt intervals in the S7 hardware configuration (not in DB1)
  4. Replace OB 251 PID with PID_Compact or CONT_C
  5. 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

Analyze your PLC code with AI

PLCcheck Pro explains, documents, optimizes, and migrates PLC code — automatically.

Try PLCcheck Pro →
← Back to Blog

Not affiliated with Siemens AG. S5, S7, STEP 5, STEP 7, and TIA Portal are trademarks of Siemens AG.