Configuring SIMATIC S7 Parameter Programs in TIA Portal

David Krause11 min read
SiemensTechnical ReferenceTIA Portal
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

Parameter programming is the cornerstone of reusable, modular PLC code in the Siemens SIMATIC environment. A parameter program is any function (FC) or function block (FB) whose behavior is shaped at runtime by arguments supplied at the call site, rather than by hard-coded addresses inside the block body. Parameters decouple algorithm logic from I/O mapping, which is what enables a single motor-start block, PID controller, or valve sequencer to serve many actuators without duplicating source code.

In TIA Portal (V15 and newer, including V16, V17, V18, and V19), parameters are declared on the block interface of an FC or FB and bound to actual operands when the block instance is called from an OB, another FC/FB, or a program-cycle task. This reference explains how parameter programs are structured, how formal and actual parameters relate, and how to commission them in a real S7-1200 or S7-1500 project.

Conceptual Foundation: Formal vs. Actual Parameters

Two terms must remain distinct throughout parameter design:

  • Formal parameter (also called formal argument or interface declaration): the symbolic name and data type declared in the block interface under Input, Output, InOut, Static, or Temp.
  • Actual parameter (also called actual argument): the operand or expression written at the call site that supplies a value to the formal parameter when the call is executed.

This division mirrors the universal concept described in the Wikipedia entry on parameters in computer programming: a formal parameter is a placeholder inside a routine, while the actual parameter is the value handed to that placeholder when the routine is invoked. In SIMATIC, the binding is established visually through the call interface, and TIA Portal performs type checking at compile time.

Why this matters on S7 hardware

Without parameter programming, every FC would have to read and write directly from process-image I/O (e.g., %IW0, %QW4). The same algorithm could not be reused for a second valve without copy-paste edits, and any scaling or address change would require editing every copy. Parameter programs collapse that duplication: the block holds pure logic, the project engineer maps operands at the call.

Parameter Categories in SIMATIC Blocks

TIA Portal exposes five declaration sections on every FC and FB interface. Each carries a specific lifetime and transfer semantic:

Section Purpose Read/Write at call site Lifetime
Input Values consumed by the block Read (can be unbound / left open) One call
Output Values produced for the caller Read after the call One call
InOut Two-way pointer to caller memory Read-modify-write Caller-scope lifetime
Static Persistent block-internal memory (FB only) Cannot be wired; access via instance Instance DB lifetime
Temp Scratch memory used during the call Cannot be wired One call
Important: Multi-instance FBs nest FBs as if they were local blocks. The parent FB then exposes the child's inputs/outputs through its own interface, which is the canonical pattern for building machine modules.

Elemental Data Types for Parameter Declarations

Formal parameters must carry a defined type so the compiler can enforce interface compatibility. SIMATIC distinguishes elementary (bit, integer, floating-point, time, character), complex (DATE_AND_TIME, STRING, ARRAY, STRUCT), and PLC user-defined (UDT) types.

Group Common types Typical use in parameter programs
Bit BOOL, BYTE, WORD, DWORD, LWORD Digital I/O, flags, packed status words
Integer (S7-1200/1500) SINT, USINT, INT, UINT, DINT, UDINT, LINT, ULINT Counters, setpoints, diagnostic counters
Floating-point REAL, LREAL PID setpoint, scaled analog values
Time/date TIME, LTIME, DATE, TOD, LTOD, DTL Watchdogs, schedules, timestamps
String STRING[n], WSTRING[n] HMI tag strings, recipe names
Aggregation ARRAY[..] of T, STRUCT, UDT Recipe tables, axis records, asset data
Variant pointer VARIANT (S7-1500) Generic FB usable with any element type
Type strictness: On S7-1200 (firmware V4.x), default integer width is 16-bit (INT). On S7-1500 and S7-1200 with firmware V4.2+, 32-bit (DINT) is the default when Optimized block access is enabled for new projects. Verify the active target before committing a parameter set.

Creating a Parameterized FC in TIA Portal

The following procedure creates a two-input FC that returns the maximum of two REAL setpoints. It assumes TIA Portal V17 or V18 is in use, with the S7-1200/S7-1500 CPU configured as the target.

Prerequisites

  • TIA Portal V17, V18, V19, or V20 installed with the matching CPU Support Package.
  • Project with the target PLC configured, including IP address and slot assignment.
  • PLC firmware V4.2+ on S7-1200 or firmware V2.0+ on S7-1500 for full data-type coverage.

Step-by-step

  1. In the project tree, expand Program blocks and double-click Add new block. Choose Function (FC), assign a name (for example FC_MaxOfTwo), and select SCL as the language.
  2. Open the FC interface (top half of the editor). Declare three parameters:
    FUNCTION FC_MaxOfTwo : REAL
    VAR_INPUT
      iValueA : REAL; // First setpoint
      iValueB : REAL; // Second setpoint
    END_VAR
    BEGIN
      IF iValueA >= iValueB THEN
        FC_MaxOfTwo := iValueA;
      ELSE
        FC_MaxOfTwo := iValueB;
      END_IF;
    END_FUNCTION
  3. Compile the FC. Fix any errors. A green checkmark in the message bar confirms success.
  4. Open the calling OB (for example OB1 "Main") and place the FC call. Wire the two setpoints to iValueA and iValueB, and route the return value to an LD or tag that the HMI can read.
  5. Download only blocks (not full project) to the controller. Monitor the block by opening it in online mode; right-click inputs and outputs to add a watch table.
Optimization: For S7-1500 with Optimized block access, the FC's Output return value is the implicit RET_VAL, which is automatically exposed. On S7-1200 classic projects the same field exists but is hidden by default; show it via the gear icon on the block interface.

Parameterized FB and Instance Data Blocks

Function blocks retain their internal state across calls through a paired instance data block (DB). This is what makes a parameter program suitable for cyclic control loops, where state such as integrator windup must persist between scan cycles.

Creating an FB with parameters and static memory

  1. Add a new Function block (FB), name it FB_PID_Simple, and select SCL.
  2. Declare the interface. The Static section holds integrator memory; Input, Output, and InOut carry process values:
    FUNCTION_BLOCK FB_PID_Simple
    VAR_INPUT
      iSetpoint   : REAL;
      iProcessVar : REAL;
      iKp         : REAL;
      iTi         : REAL; // [s]
      iCycle      : REAL; // [s]
    END_VAR
    VAR_OUTPUT
      qManipulated : REAL;
    END_VAR
    VAR
      rIntegral    : REAL;  // Internal integrator (static)
      rLastError   : REAL;
    END_VAR
    BEGIN
      // Error and proportional
      #rLastError := #iSetpoint - #iProcessVar;
      // Integral term with anti-windup clamp at +/-100%
      #rIntegral := LIMIT(-100.0, #rIntegral + #rLastError * #iCycle / #iTi, 100.0);
      #qManipulated := LIMIT(-100.0, #iKp * #rLastError + #rIntegral, 100.0);
    END_FUNCTION_BLOCK
  3. Compile. TIA Portal offers to create the instance DB; accept, naming it DB_PID_Heater_1. Each call site re-instantiates the block by creating an additional instance DB.
  4. When the project is recompiled with a new interface, TIA Portal's Block consistency check highlights break-points. Use Update interface (right-click the FB) to push the change into all instance DBs at once.

Each instance DB occupies memory from the load memory of the PLC. Inspect the size under Program blocks > System blocks > Program resources when designing architectures that scale to hundreds of FBs.

Parameter Wiring at the Call Site

The binding between formal and actual operands happens inside the call box. TIA Portal shows unwired inputs in red; resolving all red bindings is a prerequisite for download.

Pin Symbolic operand Absolute (when symbolic disabled) Allowed source
iSetpoint "DB_Heater".sp %DB5.DBD0 Tag, literal, expression
iProcessVar "AI_H1_Temp".PV %IW64 Process image input
iKp "Recipie".Kp - Tag or literal
qManipulated "AO_H1_Power".MV %QW16 Process image output

Any pin may be left unwired (label --) when the FB provides a default value or when the variable is genuinely optional. Inputs without defaults on S7-1200 firmware V4.0 may force the CPU into STOP if no actual operand is supplied at runtime, so always bind critical paths.

Parameter Transfer Semantics

The semantic difference between Input, Output, and InOut is not cosmetic.

  • Input: a copy of the actual operand's value is placed on the block's stack / instance. Writes inside the block do not propagate to the caller. Useful when the block should not have side effects on process memory.
  • Output: the caller provides the address; on block exit the block writes its return through the address. Until then the output reads as the initial value of the typed variable.
  • InOut: a pointer (or descriptor for optimized blocks) into the caller's memory. Reads and writes both route to the same address. Use this when the block must modify an existing tag without making a copy (saves memory in large arrays).
Performance note for large data: Passing an ARRAY[0..1000] of REAL as InOut is significantly faster than passing it as Input on S7-1200/1500 with optimized block access, because TIA Portal can pass a pointer rather than copy 4 KB every cycle.

Multi-Instance and Reuse Across Blocks

When several FB instances appear as components of a larger machine module, declare them as multi-instances of the parent FB. This avoids creating one DB per child FB and groups machine state under a single instance.

FUNCTION_BLOCK FB_MachineModule
VAR
  Heater1 : FB_PID_Simple; // Multi-instance, no separate DB needed
  Heater2 : FB_PID_Simple;
  Valve   : FB_ValveControl;
END_VAR
BEGIN
  Heater1(iSetpoint := 80.0, iProcessVar := "AI_T1".PV, qManipulated => "AO_H1".MV);
  Heater2(iSetpoint := 65.0, iProcessVar := "AI_T2".PV, qManipulated => "AO_H2".MV);
  Valve(iCmd := "HMI".ValveOpen, qState => "HMI".ValveFB);
END_FUNCTION_BLOCK

Siemens Industrial Online Support Resources

For deeper reference material on parameter programs, refer to the S7-1200 and S7-1500 programming manuals in the Siemens Industrial Online Support portal:

Audit pointers: SIOS entries above are meant as starting points for navigation. Verify the printed edition identifier and firmware version listed in the document footer against your installed TIA Portal version before reusing sample code in a running system.

Verification Checklist

Before commissioning any parameter program on the controller, walk through this checklist:

  1. All formal parameters show a data type that matches the desired operand type. REAL setpoints must not be wired to an INT pin, etc.
  2. Every InOut pin in the calling OB is initialized; uninitialized InOut tags can cause firmware V4.2+ to log Area length error diagnostics.
  3. Instance DBs show green checkmarks after recompiling; run Block consistency check (right-click the Program blocks folder, choose Compile).
  4. PLC is placed online and the block is monitored for at least one full scan cycle. Inputs that should change must actually change in the online view.
  5. The HMI tag list references only symbolic names; no absolute % addresses are hard-coded for the FB's input/output.

Common Error Sources and Field Diagnostics

Symptom Likely cause Field action
Block goes red after download with FB interface changed Formal parameters added without Update interface Right-click the FB, choose Update interface, recompile, download all instance DBs
Online value reads zero despite correct wiring Pin left unwired or wired to -- Open the call site, ensure all input pins carry a tag
PLC goes STOP on first run Unwired InOut referencing an uninitialized DB field Pre-assign tag in OB initialization area or default value on interface
Compile warning "IO supervisor access error" Optimized block access settings differ between blocks Unify Optimized block access attribute across caller and callee

What is the difference between an FC and an FB in a Siemens parameter program?

An FC (Function) has no memory and cannot store state; all values must be supplied via Input, Output, or InOut. An FB (Function Block) holds state in a paired instance data block, exposing Static tags for runtime persistence. Use FBs whenever the algorithm needs cyclic memory (e.g., integrator, edge detector) and FCs for pure transforms (e.g., math, scaling).

How do I pass a parameter by reference without copying large arrays?

Declare the formal parameter as InOut rather than Input. On S7-1500 with optimized block access, TIA Portal implements the transfer as a pointer to the caller's memory, so an ARRAY[0..999] of REAL is not duplicated every cycle. Reserve Input for small scalars where accidental mutation by the called block would be undesirable.

Which TIA Portal version is required for type-safe FC/FB parameter programming on S7-1200?

For the full data-type set (including LREAL, LWORD, and POINTER/UPOINTER with type-safe syntax) plus optimized block access on S7-1200, target firmware V4.2 or later. Pair it with TIA Portal V15.1 or newer; current Service Pack releases (V17, V18, V19, V20) provide the longest maintenance window. Older V4.0/V4.1 firmware still works but cannot use LREAL as a formal parameter.

Can I leave an input parameter unwired at the call site?

Yes, TIA Portal permits unwired Input pins; the CPU substitutes the initial value declared on the block interface (default zero for elementary types). Inputs that are declared without a default and that are read by the block before being written internally can cause an Initial value not yet assigned notice and, on rare S7-1200 firmware, a STOP. Bind every input that the block reads, or assign a sensible default during interface editing.

Where do I find official Siemens documentation on FC/FB parameter lists?

Use Siemens Industrial Online Support at support.industry.siemens.com. Search for the S7-1500 or S7-1200 function manual; it walks through the block interface editor, parameter types, and updating instance DBs after interface changes. The entry point for the S7-1500 manual collection is typically found under Automation Technology > SIMATIC > PLC > S7-1500 > Documentation.

Back to blog