S5 Function Blocks to S7: FB/FX Migration Guide
How to migrate S5 function blocks (FB, FX) to S7. Covers parameter passing differences, formal operands vs. block interface, instance data blocks, and standard FBs (FB250, FB251).
S5 Function Blocks to S7: FB/FX Migration Guide
S5 function blocks (FB) use a fundamentally different parameter passing mechanism than S7 FBs. In S5, parameters are passed through formal operand declarations at the top of the FB. In S7, parameters are defined in the block interface. The Siemens converter handles the basic conversion, but complex FBs with many parameters, nested calls, or standard Siemens FBs (FB250, FB251) require manual attention.
S5 vs. S7 Function Block Architecture
| Feature | S5 FB | S7 FB |
|---|---|---|
| Parameter declaration | Formal operands (NAME, BEZ:) | Block interface (Input, Output, InOut, Static) |
| Parameter types | E/A/D/B/T/Z/DW (address-based) | Any data type (BOOL, INT, REAL, STRUCT, etc.) |
| Instance data | Shared DB (explicit A DB before call) | Instance DB (automatic, one per call) |
| Call syntax | SPA FB 10 with parameter list | CALL FB10, DB10 |
| Nesting | Limited by CPU (typically 8–16 levels) | Up to 24 levels (S7-1500) |
| Extended FBs | FX (only S5-135U/155U) | No distinction — all FBs are equal |
S5 FB Parameter Declaration
An S5 FB starts with a header declaring its formal operands:
FB 10
NAME: MOTOR_CTRL
BEZ: START E // Input: Start button address
BEZ: STOP E // Input: Stop button address
BEZ: RUNNING A // Output: Motor running signal
BEZ: SPEED DW // Data word: Speed setpoint
When calling the FB, actual operands are assigned:
SPA FB 10
START: E 0.0
STOP: E 0.1
RUNNING: A 4.0
SPEED: DW 5
S7 FB Equivalent
The same FB in S7 uses a typed block interface:
FUNCTION_BLOCK "Motor_Ctrl"
VAR_INPUT
Start : BOOL;
Stop : BOOL;
Speed_Setpoint : INT;
END_VAR
VAR_OUTPUT
Running : BOOL;
END_VAR
VAR
// Static variables (instance data)
Self_Hold : BOOL;
END_VAR
Call in S7 SCL:
"Motor_Ctrl_Instance"(Start := "Start_Button",
Stop := "Stop_Button",
Speed_Setpoint := 1500);
Motor_Running := "Motor_Ctrl_Instance".Running;
Key Migration Issues
1. Instance Data Blocks
In S5, FBs often share a single DB that is opened with A DB n before the FB call. The FB then reads/writes to this DB using DW addresses. Multiple FB calls may use the same DB with different DW offsets.
In S7, each FB call gets its own instance DB (or uses multi-instancing within a parent FB). The instance DB stores the FB's static variables automatically.
Migration approach: The converter creates separate instance DBs for each FB call. If the original S5 program used a shared DB for multiple FB instances, the data must be redistributed to individual instance DBs.
2. Formal Operand Types
S5 formal operands are address-based (E, A, M, DW, T, Z). They pass the address to the FB, not the value. This means the FB accesses the actual I/O or memory directly.
S7 parameters pass values (for Input/Output) or references (for InOut). This is a fundamental architectural difference.
Most common issue: S5 FBs that modify input parameters (writing to an address passed as "E" type). In S7, Input parameters are read-only. These must be changed to InOut parameters.
3. Siemens Standard FBs
S5 includes several standard function blocks in the CPU operating system. The most common:
| S5 Standard FB | Function | S7 Equivalent |
|---|---|---|
| FB 250 (SEND) | Send data via serial/SINEC | PUT/GET, TSEND_C, or BSEND |
| FB 251 (RECEIVE) | Receive data | PUT/GET, TRCV_C, or BRCV |
| FB 241 (PID) | PID controller | PID_Compact (S7-1500) or FB 41 CONT_C |
| FB 12 (AS-i) | AS-Interface communication | AS-i CP configuration in HW config |
These cannot be converted automatically. The S7 replacements have different interfaces and must be reconfigured manually.
4. FX Blocks (S5-135U/155U Only)
FX (extended function blocks) are specific to the S5-135U and S5-155U. They have a larger address space than standard FBs and can access extended memory. In S7, there is no distinction — all FBs have the same capabilities.
Migration: FX blocks are converted to standard S7 FBs. The only issue is avoiding number conflicts (e.g., if both FB 10 and FX 10 exist, one must be renumbered).
Conversion Checklist
- ☐ Identify all FBs and their formal operands
- ☐ Map S5 parameter types to S7 interface types (E→BOOL Input, A→BOOL Output, DW→INT/DINT InOut)
- ☐ Identify FBs that write to input parameters → change to InOut
- ☐ Create instance DBs for each FB call
- ☐ Handle shared DB access → redistribute to instance DBs
- ☐ Replace standard Siemens FBs (FB250, FB251, FB241) manually
- ☐ Renumber FX blocks if number conflicts exist
- ☐ Test each FB individually after conversion
How PLCcheck Pro Helps
- Identifies all FBs with their formal operand declarations
- Flags standard Siemens FBs that need manual replacement
- Maps parameter types to S7 equivalents
- Detects FBs that write to input parameters
Frequently Asked Questions
Can the Siemens converter handle all FB conversions?
Basic FBs with standard parameter types are converted reasonably well. Complex FBs with many parameters, nested calls, shared DB access, or standard Siemens FBs (FB250/251/241) require manual work.
What about S5 step blocks (SB)?
SBs are converted to FBs or FCs in S7. They have no direct equivalent. The converter handles basic SBs, but complex SBs with step logic may need restructuring (consider using S7 GRAPH for sequential logic).
Do I need to keep the same FB numbers in S7?
No. S7 supports FB numbers up to 65535. You can renumber freely. However, keeping original numbers makes cross-referencing between old and new programs easier during testing.
Maintained by PLCcheck.ai. Last update: March 2026. Not affiliated with Siemens AG.
Related Articles
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
migration-guideS5 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
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.