WinCC flexible ChangeConnection for MP377 on S7-300/400H

David Krause12 min read
HMI / SCADASiemensTutorial / 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

A SIMATIC MP377 operator panel tied to a redundant S7 system — whether an S7-300 software-redundant pair or an S7-400H pair — must read process values from the active controller. WinCC flexible project tags are statically bound to a single configured connection, so a tag points to one MPI/PROFINET partner address. When the redundant system switches from CPU-A to CPU-B, the original tag still queries CPU-A, which is now standby. Without a mechanism to re-point the tag, the panel reads frozen, stale, or invalid values from the secondary CPU.

WinCC flexible ships the ChangeConnection system function. Triggered by a runtime event (PLC bit, scheduled task, or button press), it re-binds a tag (or a group of tags) to a different pre-configured connection. Combined with an H-system status bit read from the PLC, the MP377 detects which controller is active and switches its tag set to the correct connection in milliseconds — well within operator response time.

ChangeConnection requires WinCC flexible 2008 SP2 or later. The MP377 image must be ≥ V1.3.2 (verify under Start → Settings → Control Panel → System → Image Version). Older runtime images silently ignore the function call and the HMI log shows "Function not supported".

Prerequisites

Component Specification
HMI software SIMATIC WinCC flexible 2008 SP2 / SP3 / SP4 / SP5 (or WinCC Comfort V11+ for TIA Portal migration)
Operator panel MP 377 12" / 15" / 19" Touch or Key (6AV6 644-...) with Windows CE 6.0
Runtime image MP 377 image ≥ V1.3.2
PLC pair Two S7-300 CPUs running software redundancy (CPU 315-2 PN/DP, 317-2 PN/DP, 319-3 PN/DP) or two S7-400H CPUs in a redundant pair (CPU 412-3H, 414-3H, 416-3H, 417-4H) with redundant sync modules
CP for H communication CP 343-1 H (S7-300 H-link) or CP 443-1 / CP 443-1 Advanced (S7-400H)
S7-400H firmware ≥ V4.5 (V5.3 or later recommended for full H-diagnostic access)
Network medium MPI cable, PROFIBUS DP, or PROFINET (single-port for S7-300, redundant ring for S7-1500R/H)
Engineering tool (PLC) STEP 7 V5.4 SP5 or V5.5 for S7-300/400H

Redundant S7 Topology Fundamentals

Three physical topologies are commonly seen with MP377 installations. Knowing which one applies determines how the active CPU is detected.

Scenario A — S7-300 Software Redundancy

Two standard S7-300 CPUs (no H hardware) linked through the SIMATIC S7-300 Software Redundancy library. One CPU runs as Master (FB 101 "SW_RED_M"), the other as Slave (FB 102 "SW_RED_S"). Both nodes are reachable on the MPI / PROFIBUS network at distinct MPI addresses. Switchover is software-driven and takes 100–500 ms. A status word stored in a shared DB reports the current role and can be read by the MP377.

Scenario B — S7-400H Hot Standby

Two S7-400H CPUs connected via fibre-optic sync modules (up to 10 km apart). Both are addressable on the plant bus. SFC 90 "H_CTRL" or the system status list (SSL, SZL-ID W#16#0171) reports the active role. Switchover is sub-100 ms. The CP 443-1 handles the H communication protocol and presents both CPUs under a single redundant IP pair to the operator panel when PROFINET is used.

Scenario C — S7-1500R/H

The newer S7-1500R/H family uses PROFINET redundancy. The MP377 does not directly support S7-1500R/H; a SIMATIC Comfort Panel (TP 1500 / TP 1900 / TP 2200) or an IPC with WinCC Runtime Professional under TIA Portal is required. Refer to the official Siemens documentation for the S7-1500R/H connection setup: Communication with the redundant system S7-1500R/H.

The WinCC flexible ChangeConnection System Function

ChangeConnection is a WinCC flexible system function that reassigns a tag to a different pre-existing connection at runtime. Its signature:

ChangeConnection ( Tag , NewConnectionName )
Parameter Type Description
Tag Tag reference The HMI tag whose connection should be re-pointed
NewConnectionName String The name of a previously configured connection in the project

The function only accepts connection names that already exist in the WinCC flexible project. Calling it with an unknown name generates a runtime warning in the HMI diagnostic log ("Connection not found").

ChangeConnection is not exposed in the WinCC flexible 2004 or 2005 system function catalog. Projects that must run on these versions must use a tag-multiplex pattern (two full sets of tags, one per CPU, switched by a status bit) or migrate to WinCC flexible 2008.

Configuring Two Connections in WinCC flexible

  1. Open the WinCC flexible project.
  2. Open Project tree → Communication → Connections.
  3. Insert two connections, naming them exactly as referenced later in ChangeConnection:
    • Conn_CpuA → points to MPI address 2 (or PROFINET IP of CPU-A)
    • Conn_CpuB → points to MPI address 4 (or PROFINET IP of CPU-B)
  4. Set the connection driver to SIMATIC S7 300/400 for both entries. For S7-400H with PROFINET redundancy, the driver must be SIMATIC S7 400H on the appropriate CPU slot.
  5. For PROFINET, enter the CP 443-1 / CP 443-1 Advanced IP addresses; for MPI / PROFIBUS, enter the bus addresses (2 and 4).
  6. Save and compile. Each connection must pass compilation without warnings.

Each connection consumes a connection resource on the MP377. The MP377 12"/15"/19" supports 6 concurrent S7 connections — two for the H pair leaves 4 free for other PLCs or HMI-PLC coordination area.

Step-by-Step: Automatic Connection Switching

The recommended architecture uses one Boolean HMI tag (the trigger) whose value indicates which CPU is active. The PLC writes the trigger from an H-system status flag. ChangeConnection is then called in the HMI scheduler on change of the trigger, re-pointing every process tag to the correct CPU.

Step 1 — Define the HMI Tags

Create a single set of process tags, but bind them initially to Conn_CpuA. They will be re-pointed at runtime.

Tag name      : TankLevel_PV
PLC tag       : DB100.DBD0   (REAL)
Initial conn  : Conn_CpuA

Tag name      : MotorSpeed_PV
PLC tag       : DB100.DBD4   (REAL)
Initial conn  : Conn_CpuA

Create the trigger tag:

Tag name      : ActivePlc_Trigger
PLC tag       : DB200.DBX0.0 (BOOL)   // 0 = CPU-A active, 1 = CPU-B active
Initial conn  : Conn_CpuA

Step 2 — Read the H-System Status into the Trigger

On an S7-400H, the active CPU bit is obtained by reading the SSL partial list "H system status" (SZL-ID W#16#0171) or by calling SFC 90 "H_CTRL". A typical pattern on the PLC side:

// ST (SCL) on CPU-A — write 0 to DB200.DBX0.0 when A is active
// Call in OB1 or OB35
IF "H_status".active_cpu_id = 0 THEN
    "DB_HMI".active_plc_bit := FALSE;   // 0 = CPU-A active
ELSE
    "DB_HMI".active_plc_bit := TRUE;    // 1 = CPU-B active
END_IF;

For S7-300 software redundancy, the slave CPU mirrors the active flag from the master via FB 102 "SW_RED_S" output SLAVE_STATE. The flag is broadcast by the master and stored in a shared DB read by both CPUs. The HMI consumes the same bit on whichever CPU is responding.

Step 3 — Create a Scheduled Task in WinCC flexible

  1. Open Project tree → Scheduler.
  2. Insert a new task, trigger type On tag change, select ActivePlc_Trigger.
  3. Add a VB script as the action. WinCC flexible's scheduler does not natively support IF…THEN in function lists, so use a VB script that reads the trigger and calls ChangeConnection for each tag.
' VB script in WinCC flexible 2008 SP3+
Dim conn As String

If SmartTags("ActivePlc_Trigger") = False Then
    conn = "Conn_CpuA"
Else
    conn = "Conn_CpuB"
End If

' Apply to every process tag in the set
ChangeConnection SmartTags("TankLevel_PV"), conn
ChangeConnection SmartTags("MotorSpeed_PV"), conn
ChangeConnection SmartTags("ValvePos_PV"),   conn
' add one line per HMI tag
WinCC flexible 2008 limits scheduled tasks to one script call each. If the project has more than 30 tags, segment them into groups (each group has its own change-trigger script) or migrate to TIA Portal where the function-list editor supports conditionals and loops natively.

Step 4 — Tag Multiplex (Tag-Centric Alternative)

For projects with hundreds of tags, calling ChangeConnection on every one is expensive and slows the scheduler. Use WinCC flexible's multiplex tag (indirect addressing) instead:

  1. Create two full sets of tags, one set bound to Conn_CpuA, one bound to Conn_CpuB.
  2. Define a multiplex tag (e.g., TagMux_Index) that holds an index 0 or 1.
  3. For each I/O field on the panel, use indirect addressing that reads either the A-tag or the B-tag based on the index.
  4. The I/O field references the multiplexed tag; the multiplex swaps the pointer in a single update.

This eliminates the need for ChangeConnection, at the cost of doubling the tag count and configuration effort. It is the preferred pattern on large MP377 installations with 100+ tags.

PLC-Side Status Logic for H System Detection

The status bit the MP377 consumes must be deterministic. The following source flags are reliable on the listed systems:

System Source of "active" bit Reliability Update latency
S7-400H (V4.x) SSL W#16#0171 byte 0, read with SFC 51 High ≤ 100 ms
S7-400H (V5.x) SFC 90 "H_CTRL" output, called in OB1/OB35/OB82 High ≤ 100 ms
S7-300 SW Redundancy V2.x FB 102 output SLAVE_STATE in shared DB Medium 100–500 ms
S7-1500R/H (TIA) System tag "H-System".H_RACK_STATE High ≤ 50 ms
Do not use the diagnostic buffer (OB82) as the active-CPU indicator: the buffer is event-driven and may not reflect a transition for several hundred milliseconds after switchover, causing the panel to display values from the wrong CPU for that interval.

Alternative: Using the WinCC flexible Connection Status Tags

WinCC flexible exposes built-in connection status tags. With a coordination area enabled, the tag @ConnectionState_<conn_name> reports 1 = OK, 0 = broken. This can be used in a poll-based loop to detect a switchover event and re-issue ChangeConnection.

' Polling loop in WinCC flexible scheduler, period = 500 ms
If SmartTags("@ConnectionState_Conn_CpuA") = 0 Then
    ' CPU-A went down or standby, force CPU-B
    ChangeConnection SmartTags("TankLevel_PV"), "Conn_CpuB"
    ChangeConnection SmartTags("MotorSpeed_PV"), "Conn_CpuB"
    ChangeConnection SmartTags("ValvePos_PV"),   "Conn_CpuB"
End If

This pattern is slower (500 ms latency) but works without any PLC-side status logic. It is the simplest implementation when modifying the PLC code is not feasible — for example, on a brownfield installation where the MP377 is added to a commissioned redundant system.

Connection Resource Limits and Planning

The MP377 has a hard cap on the number of active S7 connections. Exceeding the cap silently drops new connection requests, with the panel reporting Connection error 0x02 in the diagnostic log.

Panel Max S7 connections Notes
MP 377 12" Touch / 12" Key 6 Firmware ≥ V1.3.2
MP 377 15" Touch 6 —
MP 377 19" Touch 6 —

For an H-system, two connections (one per CPU) are the minimum. Add 1–2 spare for third-party PLCs or HMI-PLC coordination areas. If the design exceeds 6 connections, migrate the HMI to a Comfort Panel (TP 1500 / TP 1900 / TP 2200) under TIA Portal, which lifts the connection cap to 16.

Verification and Runtime Diagnostics

  1. Compile and download the WinCC flexible project to the MP377 via ProSave or Ethernet.
  2. Start Runtime. Open the panel's diagnostic page: Start → Settings → Control Panel → System → Info → Version. Confirm the image version is ≥ V1.3.2.
  3. Open the diagnostic log: Start → Settings → System → Logging. Confirm no "Function not supported" warnings on ChangeConnection calls.
  4. Force a switchover on the H system (STEP 7 → H-System → "Switch Master/Standby").
  5. Observe the ActivePlc_Trigger tag on the MP377 (place it on a diagnostic screen for visibility).
  6. Verify that process values update within one screen refresh cycle (≤ 1 s on MP377 with 250 ms acquisition cycle).
  7. Disconnect the active CPU's MPI / PROFINET cable. The standby CPU should take over within 1 s, the trigger should flip, and the panel should continue reading correct values.
  8. Reconnect the cable and force a switch back. Confirm bidirectional operation.

Troubleshooting Matrix

Symptom Probable Cause Remedy
Tags never update after switchover; trigger bit flips but process values freeze ChangeConnection script not called on tag change Confirm the scheduler trigger type is "On tag change" (not "On scheduled tick"); verify the trigger tag is itself a real, single-value tag, not a multiplexed pointer
"Function not supported" warning in HMI log Runtime image too old Update the MP377 image to ≥ V1.3.2 via ProSave
Tags show value 0 or 16#FFFF after switchover DB layout differs between CPU-A and CPU-B, or H sync has not propagated Verify identical DB structure on both CPUs; software redundancy requires manual DB mirroring — check that FB 102 sync covers the affected DBs
Connection error 0x02 in HMI log immediately on start Connection resource limit exceeded ( > 6 on MP377) Reduce the number of configured connections; verify against the panel's cap of 6
Trigger bit not updated by PLC SSL read or SFC 90 called in wrong OB SFC 90 "H_CTRL" must be called in OB1, OB35, or OB82; SSL must be read with SFC 51 in a cyclic OB (OB1 or OB35)
Panel freezes for 2–3 s on switchover ChangeConnection called synchronously in a screen-update event or inside a button event with heavy load Move ChangeConnection to a non-blocking scheduled task (period 100 ms); do not call it inside a button event
MPI address conflict Two CPUs share the same MPI address Assign distinct addresses (e.g., 2 and 4); if a CP is used for the H-bus (CP 343-1 H), assign it a third distinct address
Only one connection ever used, second one fails to establish PROFINET name / IP misconfigured on the standby CPU Verify both CP 443-1 IP addresses are reachable from the MP377 via ping; check PROFINET device name assignment in STEP 7 HW Config
VB script error "Object variable not set" Tag referenced in ChangeConnection not configured in the project Recompile the project; ensure every SmartTags reference resolves to a real tag in the tag list

FAQ

Which WinCC flexible version first supports the ChangeConnection function?

ChangeConnection is available from WinCC flexible 2008 SP2 onward. WinCC flexible 2004 / 2005 do not expose the system function; for these versions, use a tag-multiplex pattern with two full sets of tags and a status-driven switch.

Does the MP377 connect directly to an S7-1500R/H system?

No. The MP377 communicates with the S7-300/400 family natively. For S7-1500R/H, use a SIMATIC Comfort Panel (TP 1500 / TP 1900 / TP 2200) or an IPC with WinCC Runtime Professional under TIA Portal. See the official Siemens documentation for the S7-1500R/H connection setup.

How many MPI addresses does a redundant S7-300 pair need?

Two. Each CPU requires a unique MPI / PROFIBUS address (e.g., 2 and 4). If the system uses a CP for the H-bus (CP 343-1 H), the CP takes a third address; configure the MP377 connections to point at the CPUs' addresses, not the CP's.

Can the ChangeConnection call be triggered from a button event?

Yes, but for automatic redundancy, use a scheduled task triggered by a status tag. A button event blocks the HMI thread and triggers a panel freeze under heavy tag load, especially if ChangeConnection must be called for many tags in sequence.

What is the maximum number of S7 connections an MP377 15" Touch can hold?

6 concurrent S7 connections on all MP377 variants (12" / 15" / 19"). The connection limit is enforced by the runtime and triggers error 0x02 when exceeded. For higher limits, migrate to a Comfort Panel running WinCC TIA Portal.

Back to blog