PLCcheck

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).

·12 min read
S5S7function blockFBFXmigrationformal operandinstance DBparameterFB250FB251

Diesen Artikel auf Deutsch lesen

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

FeatureS5 FBS7 FB
Parameter declarationFormal operands (NAME, BEZ:)Block interface (Input, Output, InOut, Static)
Parameter typesE/A/D/B/T/Z/DW (address-based)Any data type (BOOL, INT, REAL, STRUCT, etc.)
Instance dataShared DB (explicit A DB before call)Instance DB (automatic, one per call)
Call syntaxSPA FB 10 with parameter listCALL FB10, DB10
NestingLimited by CPU (typically 8–16 levels)Up to 24 levels (S7-1500)
Extended FBsFX (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 FBFunctionS7 Equivalent
FB 250 (SEND)Send data via serial/SINECPUT/GET, TSEND_C, or BSEND
FB 251 (RECEIVE)Receive dataPUT/GET, TRCV_C, or BRCV
FB 241 (PID)PID controllerPID_Compact (S7-1500) or FB 41 CONT_C
FB 12 (AS-i)AS-Interface communicationAS-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

  1. ☐ Identify all FBs and their formal operands
  2. ☐ Map S5 parameter types to S7 interface types (E→BOOL Input, A→BOOL Output, DW→INT/DINT InOut)
  3. ☐ Identify FBs that write to input parameters → change to InOut
  4. ☐ Create instance DBs for each FB call
  5. ☐ Handle shared DB access → redistribute to instance DBs
  6. ☐ Replace standard Siemens FBs (FB250, FB251, FB241) manually
  7. ☐ Renumber FX blocks if number conflicts exist
  8. ☐ Test each FB individually after conversion

How PLCcheck Pro Helps

Upload your S5 code →

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

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.