S7-1200 Multi-Instance FB Monitoring in TIA Portal: Setup Guide

David Krause13 min read
SiemensTIA PortalTutorial / How-to
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: Multi-Instance Function Blocks on S7-1200

Multi-instance function blocks (FBs) allow a single FB type to be reused multiple times under a single instance Data Block (DB). On the S7-1200, the classic pattern places a "driver" FB (e.g., MotorDriver_FB1) inside another FB (e.g., Motor_FB2) as a multi-instance, then calls Motor_FB2 five times from OB1 with five separate instance DBs. The runtime memory belongs to the enclosing FB, but the block logic is identical for every call.

The cost of that reuse is visibility. When you open the FB in "Monitor" mode, the editor only shows one of the five running instances. Selecting which one is the "call environment" problem, and TIA Portal handles it differently across firmware and software versions. On TIA V13 + S7-1200 firmware 4.0 or later, the Call environment pane in the Testing task card lets you explicitly choose the instance DB. On TIA V12 with firmware 2.2 or 3.0, no in-place call-environment switch is available for the S7-1200, and engineers must fall back on call re-ordering or an S7-1500 simulation target.

Engineer field note: The call environment mechanism was originally delivered for S7-300/S7-400 in STEP 7 V5.x and was ported into TIA Portal for S7-300/400 first. The S7-1200 gained it in firmware 4.0 (released for S7-1200 from approx. mid-2015 onward) with TIA Portal V13 SP1. Always confirm your exact CPU order number (6ES7 2xx-1xxx) supports firmware 4.x before relying on the feature.

Prerequisites

Item Minimum Version Recommended
TIA Portal (STEP 7) V13 for S7-1200 call environment V15.1 or later, latest available update
S7-1200 CPU firmware V4.0 (for call-environment switching) V4.4 or V4.5 (latest for that CPU)
Programming language FBD / LAD / STL / SCL SCL for structured multi-instance code
Project type Single project Single project with multi-instance FB hierarchy
Online connection PROFINET or PROFIBUS with PG/PC interface Direct Ethernet to CPU, IP reachable
CPU mode RUN with test functions permitted RUN; test mode enabled via "Test mode" project property

Verify your CPU firmware with Online > Accessible devices, then right-click the CPU and select Online & diagnostics > Diagnostics > General. The firmware version appears under "Identification" as the CPU's firmware build. CPUs of the original S7-1200 product line (6ES7 211/212/213/214/215/216) cap out at firmware 4.x; the S7-1200 G2 generation (6ES7 217/218) uses a different firmware stream starting at V5.x with TIA Portal V20. Cross-check with the S7-1200 Programmable Controller System Manual.

How Multi-Instance FBs Work in TIA Portal

A multi-instance FB is declared inside the static section of a parent FB. The parent FB owns the instance memory and passes the address implicitly when it calls the child. For five motors the source structure looks like:

// Motor_FB2 (parent, called 5 times from OB1 with Motor_DB1..Motor_DB5)
VAR
    Drive : ARRAY[1..5] OF MotorDriver_FB1;  // 5 multi-instances of FB1
    Speed_SP : ARRAY[1..5] OF REAL;
    Running : ARRAY[1..5] OF BOOL;
END_VAR

BEGIN
    FOR i := 1 TO 5 DO
        Drive[i](Start := Start[i], Speed := Speed_SP[i], RunOut => Running[i]);
    END_FOR;
END_FUNCTION_BLOCK

When you place the cursor inside Drive[i] in the parent FB and select Monitor, TIA Portal must resolve which of the five array elements you mean. That resolution is the "call environment." On the S7-300/400, the call stack is multi-level and the call environment is selected from a list of every active call path. On the S7-1200 the CPU only reports the currently executing instance, so the editor must let you switch the displayed instance manually.

Setting the Call Environment on S7-1200 (TIA V13+ / Firmware 4.0+)

The Call Environment feature lets you pin the program-status display to a chosen instance DB while the CPU continues executing all instances. It is the recommended method for live monitoring without re-compiling or stopping the CPU.

  1. Download the project to the S7-1200 and establish an online connection. The CPU must be in RUN with online test mode permitted (project property "Test mode for this CPU" enabled under Protection & Security).
  2. Open the multi-instance FB in the project tree (for example MotorDriver_FB1). The FB editor appears with code, interface, and the Testing task card on the right.
  3. Click Monitoring on/off in the toolbar (glasses icon) to start program status. The currently executing instance is displayed initially.
  4. Open the Testing task card on the right-hand side of the editor (if not visible, enable it under View > Task cards).
  5. In the Call environment pane, click Change. The "Call environment of a block" dialog opens.
  6. Select the desired condition. Available choices typically include:
     • Current call path - the default; monitors wherever the CPU is currently executing.
     • Specific call path - lets you select an instance DB; for the S7-1200 firmware 4.0+ release, a dropdown lists all instance DBs that this FB is currently called with (for the array example, Drive[1] through Drive[5]).
     • Breakpoint call environment - used together with breakpoints; this is described in the breakpoint topic of the TIA Portal help.
  7. Confirm with OK. The editor re-renders program status for the selected instance without interrupting the CPU scan.

Reference the official STEP 7 in TIA Portal - Function Manual for the complete description of "Basics of the call environment" and "Setting the call environment of the block" for S7-300/400 (the same UI workflow was applied to S7-1200 from firmware 4.0).

Monitoring When the Call Environment Is Not Available

If you cannot use call-environment switching, the following methods cover the cases commonly seen in the field. They are organized by CPU family and firmware.

Case A - S7-1200 Firmware 2.2 or 3.0 with TIA Portal V12/V13

The Call Environment pane in the Testing task card does not list switchable instance DBs for these firmware levels. The accepted workaround is to temporarily reorder the FB calls inside the parent FB so the instance you want to inspect executes first.

// Reordered: instance 4 is now first, call environment will show it
FOR i := 4 TO 4 DO        // single iteration for instance 4
    Drive[i](Start := Start[i], Speed := Speed_SP[i], RunOut => Running[i]);
END_FOR;
FOR i := 1 TO 5 DO
    IF i <> 4 THEN
        Drive[i](Start := Start[i], Speed := Speed_SP[i], RunOut => Running[i]);
    END_IF;
END_FOR;

The reorder can be done online on the S7-1200 firmware 2.2 and 3.0 without forcing a STOP transition, which preserves process state. After verifying the targeted instance, restore the original call order and download again.

Case B - TIA V13 Professional with PLC Simulator (S7-1500 target)

The S7-PLCSIM included with TIA V13 Professional only simulates the S7-1500 line. To debug the multi-instance code without an S7-1200 at the bench, transfer the project to an S7-1500 station, run PLCSIM, and place the cursor on the desired FB call inside the parent FB. The context-menu command Open and monitor opens the correct instance DB automatically because PLCSIM supports full call-environment resolution. Validate on the S7-1500, then re-deploy to the S7-1200.

Case C - S7-300/S7-400 (Step 7 V5.x or TIA Portal)

The classic call environment is fully supported on S7-300/400. Open the FB, click Monitor, and use the Testing task card Call environment > Change. The dialog lists the entire call stack (depth up to seven call levels depending on CPU), and any instance DB referenced along the stack can be selected. This is the reference behavior the S7-1200 firmware 4.0+ implementation mirrors.

Case D - Watch Tables as a Fallback

If the call environment is unavailable and the parent FB exposes the child instance data through its OUT interface, drag the relevant tags into a Watch Table. For multi-instance arrays, repeat the watch table once per array index. Watch tables cannot show intermediate locals, but they are always available regardless of firmware.

Call Environment vs. Breakpoints vs. Single-Step

Function Effect on CPU S7-1200 firmware support Use when
Call environment (program status) None - CPU continues at full speed V4.0+ Inspect live I/O, sequence state, and tag values without disturbing scan
Breakpoints CPU halts at breakpoint (RUN to STOP/HOLD transition) V4.0+ for S7-1200 Step through logic at the breakpoint of a single instance
Single-step Step-by-step execution V4.0+ for S7-1200 Trace a single logic path through nested FBs
Watch table None All firmware Continuous tag observation when call environment not available
Trace (S7-1200) None (records in CPU) V4.0+ (depends on CPU order number) Time-correlated analog/digital recording without halting
Safety caution: Breakpoints and single-step transitions place the S7-1200 CPU into HOLD. Outputs are frozen at the last scanned value, process interlocks may be lost, and any monitored field device will not see fresh outputs until the CPU resumes. Use breakpoints only on a bench PLC or when the process can be safely paused.

Differences Between S7-1200 Firmware 2.x, 3.x, and 4.x for Monitoring

Capability Firmware 2.2 Firmware 3.0 Firmware 4.0 / 4.1 / 4.2 / 4.4 / 4.5
Monitor mode (single instance) Yes Yes Yes
Switch instance DB inline (call environment) No No Yes
Online edit FB calls without STOP Yes (limited) Yes Yes (with full call environment)
Breakpoints / single-step No No Yes (firmware 4.0+)
Trace function No No Yes (firmware 4.0+, depending on CPU work memory)
Recipe / data log display in TIA Limited Yes Yes

To upgrade from firmware 2.2 or 3.0 to 4.x, use Online & diagnostics > Firmware update with the matching firmware file from the Siemens Online Support portal. Always confirm your CPU order number (MLFB, e.g., 6ES7 214-1AG31-0XB0) has a compatible 4.x firmware release available; some early S7-1200 CPUs cannot be upgraded past 3.0.

Step-by-Step: Diagnose and Fix "Cannot Switch Instance DB" on S7-1200

  1. Open Online & diagnostics on the CPU and verify the firmware version under General > Identification. If the firmware is below 4.0, plan either a firmware upgrade or use the call-order workaround.
  2. In TIA Portal, check the installed version under Help > About. If it is V12 with S7-1200, call-environment switching is not available; upgrade to V13 or later.
  3. Open the parent FB (the one that contains the multi-instance). Confirm the multi-instance is declared in the Static section, not in Temp. Instances declared in Temp are not retained and cannot be properly monitored across calls.
  4. Compile the project (Project tree > right-click PLC > Compile > Software). Any "instance DB must be unique" warnings indicate duplicate instance naming - fix before downloading.
  5. Download to the CPU in RUN mode if the firmware supports online changes, otherwise STOP and download. The CPU returns to RUN automatically.
  6. Open the FB, click Monitoring on/off, then open the Testing task card and click Change in the Call environment pane. If the dropdown lists all instance DBs, select the one you need. If the dropdown is empty or the button is greyed out, the firmware does not support the feature - apply a workaround.
  7. For workarounds, reorder the calls in the parent FB, save, download online, and re-open monitor. Each call instance you want to inspect becomes the "first call" once and is shown in program status.
  8. When finished, restore the original call order and download again.

Verification

Confirm that the call environment has switched correctly by validating these signals in the monitoring view:

  • The instance DB name displayed in the editor title bar matches the one you selected (for example, Drive[3] instead of Drive[1]).
  • Tag values reflect the targeted motor: change the speed setpoint of motor 3 from the HMI, observe the Speed_SP[3] value updating inside the call-environment display of MotorDriver_FB1.
  • Other motors remain unaffected: motor 1 and motor 2 retain their previous setpoints and run signals while you inspect motor 3.
  • Scan time remains constant: the CPU does not enter HOLD, and the cycle time in the online diagnostics matches the unloaded cycle time within +/- 1 ms.

For TIA V13 + PLCSIM, repeat the same checks against the simulated S7-1500, then redeploy to the physical S7-1200 to confirm parity.

Troubleshooting Matrix

Symptom Likely Cause Resolution
Call environment > Change button greyed out Firmware < 4.0 or test mode not enabled Upgrade firmware to 4.0+ and enable test mode in CPU properties
Dropdown shows only the current instance Instance DBs declared as Temp or optimized block access masking context Move instances to Static; verify the block access is set to "compatible" for legacy CPU
Program status does not refresh after switching Online connection lost Re-establish PG/PC connection; confirm the CPU IP is reachable
Breakpoint does not pause the CPU Test mode disabled at runtime Re-enable test mode in the project, recompile, download
Cannot reorder calls online Online block changes disabled by the protection level Set protection to "Full access incl. fail-safe" for commissioning, or STOP and download
Multi-instance data disappears after power cycle Instance DB is non-retentive Mark the relevant tags as retentive in the instance DB properties
Compile error: "Multi-instance not allowed here" FB was declared in Temp section or wrong nesting Declare the multi-instance FB in the Static section of the parent FB
Online update rejected after reorder Block interface signature changed Ensure no interface parameter was renamed; recompile and download as a consistent unit

Best Practices for Commissioning Multi-Instance FBs

  • Always name multi-instance FB variables descriptively (for example Conveyor_1_Drive instead of Instance_1) so the call-environment dropdown reads naturally.
  • Assign the multi-instance as Static, never Temp; otherwise the instance state is undefined between calls.
  • For arrays of multi-instances, use structured naming so the array index is visible in the call-environment dropdown. The dropdown surfaces the parent FB's static symbol path.
  • Maintain a separate "diagnostic" FB whose only job is to publish the state of each child instance to a structured DB. This gives you a permanent monitoring view without depending on the call-environment feature.
  • On S7-1200 firmware 4.x CPUs that support Trace (most CPUs with sufficient work memory from 6ES7 214-1xx models onward), record the multi-instance signals over time rather than relying on a static monitor view. Reference the S7-1200 System Manual for Trace compatibility.
  • Document the firmware baseline in your project README. Future engineers will know whether call-environment switching is supported.

Related Siemens Documentation

FAQ

Why can I not switch the instance DB on my S7-1200 with TIA Portal V12?

TIA Portal V12 does not expose the call-environment switch for the S7-1200, and the S7-1200 firmware required (V4.0 or later) was not released until after V12. Upgrade both TIA Portal to V13 SP1 (or later) and the CPU firmware to V4.0+ to enable the Call environment > Change button in the Testing task card.

Which S7-1200 firmware is the minimum for switching instance DBs while monitoring?

Firmware V4.0 is the minimum. Firmware V4.4 / V4.5 is recommended because they include bug fixes and Trace support. The S7-1200 G2 generation uses firmware V5.x with TIA Portal V20; the same call-environment workflow applies.

Can I monitor all five motor multi-instances simultaneously without breakpoints?

No - program status only renders one instance at a time. For continuous parallel observation, use a Watch Table with the instance tags or enable the S7-1200 Trace function (firmware V4.0+ depending on CPU) to record the signals over time.

Is it safe to reorder FB calls online on the S7-1200?

On firmware V2.2 and V3.0 you can change the call order of multi-instances online without forcing STOP, but only if the FB interface signature remains unchanged. Always validate that interlocks and outputs behave as expected after the online change. Breakpoints and single-step place the CPU in HOLD and are not safe for live processes.

Can I use PLCSIM to debug S7-1200 multi-instance code without a physical CPU?

TIA V13 PLCSIM simulates the S7-1500 line, not the S7-1200. To debug without hardware, transfer the project to an S7-1500 station in PLCSIM, run the simulation, and use Open and monitor to step into the multi-instance. After validation, redeploy to the physical S7-1200. Newer TIA Portal releases (V16+) include a limited S7-1200 PLCSIM that supports monitor mode.

Back to blog