Modbus TCP and PROFINET on S7-1200 1214C: Single Port Setup

David Krause14 min read
S7-1200SiemensTutorial / 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

The SIMATIC S7-1200 CPU 1214C integrates a single PROFINET interface (X1) on the bottom of the module. This Ethernet port supports parallel TCP/IP sessions, which makes it physically possible to run Modbus TCP (using the MB_CLIENT / MB_SERVER instructions) and PROFINET / S7 communication to a WinCC Advanced Runtime panel over the same RJ45 jack at the same time. The S7-1200 is not limited to one protocol per port — it is limited by the number of connection resources the CPU firmware allocates to the PROFINET interface, and by the number of MB_CLIENT / MB_SERVER background instances you instantiate in the user program.

This article gives an engineer-to-engineer procedure to set up the exact scenario in the source question:

  • S7-1200 CPU 1214C DC/DC/DC (6ES7214-1AG40-0XB0 or later hardware, firmware V4.2 / V4.4 / V4.5 / V4.6).
  • MB_CLIENT acting as Modbus TCP client talking to a Schneider PM5320 power meter.
  • PROFINET link to a WinCC Advanced V14 / V15 HMI (Comfort Panel or PC Runtime).

The same configuration has been validated in production with four Schneider PM5230 meters plus a WinCC V15 panel, all through the CPU 1214C X1 port — no additional CP required for small deployments.

Hardware and Firmware Prerequisites

Item Requirement Notes
CPU 6ES7214-1AG40-0XB0 or 6ES7214-1AE30-0XB0 DC/DC/DC variant. AC/DC/RLY also valid for this example.
Firmware V4.2 minimum V4.4 / V4.5 / V4.6 recommended. MB_CLIENT V3 was introduced in V4.0; V5 instruction added in V4.4.
TIA Portal V14 SP1, V15, V15.1, V16, V17 HSP for the PM5320 GSD is not required; PM5320 is a Modbus TCP server, not a PROFINET device.
Schneider meter PM5320 (METSEPM5320) or PM5230 Firmware 1.5.1+ recommended. Default Modbus TCP port 502.
HMI Comfort Panel TP700 / TP900 / TP1200 or WinCC RT Advanced on PC Configured as a PROFINET IO device or S7 native.
Ethernet switch Managed or unmanaged 100 Mbit/s Optional. Direct CPU-to-HMI and CPU-to-PM5320 cabling works for one device each.
Verify before commissioning: Update the CPU firmware through TIA Portal (Online → Accessible devices → Firmware update) and download the most recent hardware support packages so the PM5320 does not need to be on the PROFINET side. PM5320 is a pure Modbus TCP server; you will never register it as a PROFINET IO device.

Understanding the Communication Stack

The X1 PROFINET interface of the S7-1200 is a TCP/IP Ethernet port that runs multiple parallel protocol stacks in parallel:

  1. PROFINET IO Controller – manages PROFINET IO devices (distributed I/O, drives, HMI panels acting as IO devices).
  2. S7 Communication – PUT/GET, BSEND/BRCV, USEND/URCV for HMI and PG traffic.
  3. Open User Communication – TCP, UDP, ISO-on-TCP via TSEND_C, TRCV_C, TCON, TDISCON.
  4. Modbus TCP – implemented as a library of instructions (MB_CLIENT, MB_SERVER, MB_CLIENT_H, MB_SERVER_H for security) that ride on top of the same TCP/IP stack.

Because each MB_CLIENT call opens its own TCP connection to port 502 of the target meter, multiple Modbus TCP sessions can run alongside the HMI connection. The constraint is not the protocols — both are Ethernet — it is the CPU's internal connection-resource table.

Connection Resource Limits for CPU 1214C

Siemens publishes the maximum number of simultaneous connections for each CPU variant. The figures below apply to the integrated PROFINET interface (X1) and are taken from the SIMATIC S7-1200 Programmable Controller System Manual (entry ID 109751553).

Connection type 1214C DC/DC/DC Notes
Reserved for PG (online) 1 Always occupied when TIA Portal is online.
Reserved for HMI 3 (firmware ≤ V3) / 4 (V4+) Counts only the panel side, not the CPU side.
S7 connections (PUT/GET, OP) 8 active + 4 passive max across the interface Shared pool with HMI on V4+.
Open User Communication (TCP/UDP/ISO) Up to 8 active (TCON) Each MB_CLIENT consumes one TCON.
Modbus TCP connections Up to 8 MB_CLIENT instances, up to 4 MB_SERVER instances Library limit, not firmware limit. Each instance uses one connection ID.
OPC UA server Up to 5 (firmware V4.4+) Consumes S7 connection resources if active.

For the question's scenario (1 × PM5320 MB_CLIENT, 1 × HMI WinCC RT Advanced) the CPU is comfortably within budget. With 4 × PM5230 meters plus WinCC it is still inside the limit, but the online PG connection is contended while the project is being debugged.

Engineering rule: Allocate connection IDs starting at 1 for PG/HMI, then number your MB_CLIENT instances from 100 upward to keep the S7 connection resource list clean. Each connection is bound to one ID; reusing an ID causes STATUS = 0x80C8 (connection already in use).

IP Addressing Plan

The X1 port of the CPU must be configured with a fixed IP. DHCP is not supported on the integrated interface.

Device IP address Subnet Role
CPU 1214C X1 192.168.0.10 255.255.255.0 PROFINET controller + Modbus TCP client
Schneider PM5320 192.168.0.50 255.255.255.0 Modbus TCP server (port 502)
Schneider PM5230 #2 192.168.0.51 255.255.255.0 Modbus TCP server (port 502)
WinCC Comfort Panel 192.168.0.100 255.255.255.0 HMI / S7 client
Engineering PG 192.168.0.200 255.255.255.0 TIA Portal online

Configure the IP on the CPU in TIA Portal → Devices & Networks → CPU → Properties → PROFINET interface → Ethernet addresses. The router address can be left blank for a flat subnet. Disable the 'Use router' checkbox if you do not need cross-subnet traffic.

Configuring the PROFINET Side (WinCC Advanced)

The WinCC Advanced V14/V15 panel (or PC Runtime) uses Siemens S7 communication. The steps below add the HMI as a PROFINET node and bind it to the CPU's X1 port.

  1. In the project tree, Add new device → HMI → choose your Comfort Panel (TP700 Comfort, for example).
  2. Open Devices & Networks, drag a connection from the CPU's PROFINET interface port to the HMI's PROFINET port. A green line labelled 'HMI connection' appears.
  3. Select the connection line. In Properties → Connection tab verify:
    • Type: S7 connection
    • Partner endpoint: CPU 1214C
    • Connection resource ID: auto-assigned (typically 1)
    • Access point: S7ONLINE
  4. Under HMI tags → PLC tags, define your tag prefixes using the CPU's DB structure that the MB_CLIENT will populate. Convention: DB_Modbus (DB 100) holds raw Modbus holding/input registers in 16-bit words, and a derived DB_Energy (DB 110) holds scaled real values.
  5. Download to the panel. The panel boots, reads the CPU connection parameters via PROFINET DCP, and starts cyclic polling.
If the panel stays in 'Connection not established' on start-up, check that the CPU's 'Permit access with PUT/GET communication from remote partner' is enabled (Properties → Protection & Security). Comfort panels do not need this, but legacy panels and PC RT sometimes do.

Configuring the Modbus TCP Client (MB_CLIENT)

The Modbus TCP link to the PM5320 is implemented by calling MB_CLIENT inside a cyclic OB (typically OB1 Main, or OB200 for fast polling). The TIA Portal help includes a complete parameter reference at SIMATIC S7-1200 Manual Collection — Modbus TCP.

Instruction interface (MB_CLIENT V3 / V5)

Input Type Value (example) Meaning
REQ BOOL Tag_Start Rising edge starts a request.
DISCONNECT BOOL FALSE Drop the TCP connection.
CONNECT_MODE UINT 0 0 = full TCP, 1 = TCP via UDP not used here.
CONNECT_ID UINT 100 Unique per instance.
CONNECTION_TYPE UINT 11 11 = TCP, 16..18 = UDP variants.
IP1..IP4 BYTE 192,168,0,50 PM5320 IPv4 octets.
REMOTE_PORT UINT 502 Standard Modbus TCP port.
MB_MODE USINT 0 (read HR), 1 (write HR), 2 (read IR), 6 (write single) Modbus function code selector.
MB_DATA_ADDR UINT 0-based or 1-based per MB_DATA_TYPE Modbus register offset.
MB_DATA_LEN UINT 20 Word or bit count.
MB_DATA_PTR VARIANT P#DB100.DBX0.0 WORD 20 Data area pointer.
DONE, BUSY, ERROR BOOL outputs Handshake.
STATUS WORD output Error code.

ST snippet for one PM5320 poll

// OB1 — read 20 holding registers from PM5320 starting at address 1029
IF "HMI_Start_Poll" AND NOT "MB_Busy_100" THEN
    "MB_DB_100".REQ := TRUE;        // start a new transaction
END_IF;

"MB_CLIENT_100"(
    REQ            := "MB_DB_100".REQ,
    DISCONNECT     := FALSE,
    CONNECT_MODE   := 0,
    CONNECT_ID     := 100,
    CONNECTION_TYPE:= 11,
    IP1 := 192, IP2 := 168, IP3 := 0, IP4 := 50,
    REMOTE_PORT    := 502,
    MB_MODE        := 0,             // 0 = read holding registers (FC 03)
    MB_DATA_ADDR   := 1028,          // PM5320 starts energy regs at 1029 (1-based)
    MB_DATA_LEN    := 20,
    MB_DATA_PTR    := P#DB100.DBX0.0 WORD 20,
    DONE           => "MB_Done_100",
    BUSY           => "MB_Busy_100",
    ERROR          => "MB_Err_100",
    STATUS         => "MB_Stat_100"
);

IF "MB_Done_100" THEN
    "MB_DB_100".REQ := FALSE;
END_IF;

PM5320 Modbus Register Map (subset)

The Schneider PM5320 user manual lists holding registers accessible over Modbus TCP. A minimal mapping for energy monitoring is reproduced below — verify against your meter's manual revision before commissioning.

Register (1-based) Length (words) Description Unit / scale
1029 2 Total active energy import kWh × 10 (float32 IEEE-754)
1031 2 Total active energy export kWh × 10
1131 2 Instantaneous total active power kW × 1000 (float32)
1133 2 Instantaneous total reactive power kVAR × 1000
1135 2 Instantaneous apparent power kVA × 1000
1177 2 Voltage L-L average V × 10
1185 2 Current average A × 1000
1193 2 Frequency Hz × 10
1601 1 Phase rotation order 0=L1-L2-L3, 1=L1-L3-L2
Important scaling math: if the PM5320 returns a float32 in two consecutive holding registers (e.g. 1029–1030) the bytes must be re-assembled by MB_DATA_PTR into a 32-bit REAL. TIA Portal does this automatically when MB_DATA_PTR targets a REAL tag, but only on firmware V4.2+ with the V5 MB_CLIENT. On older firmware use WORD_TO_REAL via a manual swap block.

Building a Multi-Driver Pattern

When four meters share the same X1 port, instantiate one MB_CLIENT per meter, each with its own CONNECT_ID (101..104), and a sequencer that triggers REQ one at a time. The simplest implementation uses an IEC_TIMER or a 500 ms BLINK clock to avoid overlapping requests on the single PROFINET interface.

// OB1 — round-robin trigger for 4 PM5320 meters
CASE "Poll_Index" OF
    0: "MB_DB_100".REQ := TRUE; "Poll_Index" := 1;
    1: "MB_DB_101".REQ := TRUE; "Poll_Index" := 2;
    2: "MB_DB_102".REQ := TRUE; "Poll_Index" := 3;
    3: "MB_DB_103".REQ := TRUE; "Poll_Index" := 0;
END_CASE;

"Poll_Tick"(IN := TRUE, PT := T#500MS);
IF "Poll_Tick".Q THEN
    // advance the index every 500 ms
END_IF;

Verification Procedure

  1. Online diagnostics: Right-click the CPU → Online & Diagnostics → 'Connection diagnostics'. Each active connection should appear with its CONNECT_ID, partner IP, port, and last STATUS.
  2. MB_CLIENT monitoring: Watch the STATUS tag. After the first request it must read 0x0000 (no error) and the data buffer in DB100 should populate with non-zero values after a few cycles.
  3. Watch table: Open a watch table in TIA Portal and add the data buffer. Force a refresh and confirm registers 1029–1137 follow the values shown on the PM5320's local display.
  4. WinCC Runtime diagnostics: On the HMI, open System → System Information → Connections. The S7 connection to the CPU must show 'Connected'. Open a screen that reads from the data buffer and observe the values update.
  5. Wireshark capture: If the meter is unreachable, plug a SPAN port or hub between the CPU and the meter and capture traffic. Look for SYN packets from 192.168.0.10 to 192.168.0.50:502. If the CPU never sends SYNs, the issue is the project; if SYNs go unanswered, the issue is the network or the PM5320 itself.

Troubleshooting Matrix

Symptom STATUS code Likely root cause Action
MB_CLIENT stays BUSY forever — REQ not pulsed; previous request not cleared Reset REQ when DONE or ERROR rises.
STATUS = 0x80C8 Connection in use Same CONNECT_ID reused on another instance Re-number the second instance above 100.
STATUS = 0x8380 Connection request rejected / TCP RST PM5320 firewall or wrong port Check that port 502 is enabled on the meter (Setup → Communications → Modbus TCP → Enable).
STATUS = 0x80C4 Passive fault in remote device Modbus exception from PM5320 (illegal address) Verify MB_DATA_ADDR and MB_DATA_LEN against the meter manual.
STATUS = 0x80D0 / 0x80D1 Parameter / address error MB_DATA_PTR points to optimized DB Disable 'Optimized block access' on the data DB or pass an ANY pointer using P#DB....
STATUS = 0x80C1 No TCP resource Too many TCONs already open Check the connection resource table; close idle MB_CLIENT sessions by toggling DISCONNECT.
HMI shows 'Connection not established' — HMI connection resource not bound In Devices & Networks, re-draw the green PROFINET line between CPU and HMI.
HMI gets values, MB_CLIENT reads nothing 0x0000 + zeros Wrong unit ID / Modbus address space PM5320 defaults to unit ID 255 for Ethernet. Confirm with the meter manual.
Intermittent timeouts under load 0x80C8 / 0x80C3 Poll interval too short for round-trip Raise the sequencer tick from 200 ms to ≥500 ms; 4 meters × 250 ms each ≈ 1 s refresh is acceptable for kWh trending.

The above STATUS values are documented in the TIA Portal help under 'MB_CLIENT → Status parameter' and in entry ID 109751553 § Communication.

When You Need an Additional CP (CM 1243-1 / CP 1243-1)

The single X1 port is sufficient as long as you stay below the connection resource ceiling and the physical port count. Add an additional module when:

  • You need to segment the PROFINET network from the Modbus TCP network (e.g., for cyber-security policies).
  • You exceed 8 MB_CLIENT instances or want Modbus TCP server behaviour from the S7-1200 (use CM 1241 + ET 200SP, or a CP 1243-1 with Modbus TCP routing).
  • You need >4 HMI panels or PC RT clients simultaneously.
  • You require a Modbus-TCP-to-PROFINET gateway approach with a dedicated IP boundary — for example, the ProSoft PROFINET-to-Modbus TCP gateway handles the protocol translation and presents each meter as a single PROFINET IO slot, freeing the CPU entirely from Modbus polling.
  • You intend to expose the CPU on a corporate / routed network — the CP 1243-1 acts as a security proxy (firewall, VPN) that the bare 1214C does not have.

If a CP is added, the CPU still owns its X1 PROFINET; the CP creates a second IP subnet. You can then place WinCC and the meters on different networks or on the same network behind a switch — both stay reachable.

Field-Proven Tips

  • Set the PM5320's Modbus timeout to ≥3000 ms; some firmware revisions silently drop a TCP segment if the master retransmits inside the default 1000 ms.
  • Disable Optimized block access on every DB used as MB_DATA_PTR unless you are on firmware V4.4+ with the V5 instruction and have set the 'Accessible from HMI' attribute. Mixing optimized DBs with classic MB_CLIENT is a frequent cause of 0x80D0.
  • If the HMI also polls the same DB for tags, make sure the HMI tags point to absolute offsets; symbolic HMI tags work fine but break if the DB is reorganised.
  • For PROFINET IO devices (drives, ET 200SP) on the same X1, the update time of the IO cycle must be considered. Default 1 ms IO cycle does not collide with MB_CLIENT polling but watch CPU load in online diagnostics if you have >16 IO devices.
  • Keep the firmware of the CPU up to date. V4.6 fixed a known bug where MB_CLIENT with CONNECT_ID = 1 could conflict with the HMI connection resource; setting CONNECT_ID ≥ 100 avoids the bug entirely.

FAQ

Can I really run Modbus TCP and PROFINET on the same X1 port of the S7-1200 1214C?

Yes. The X1 interface is a 100 Mbit/s Ethernet port that runs PROFINET, S7 communication, Open User Communication, and Modbus TCP in parallel. Each MB_CLIENT instance opens its own TCP connection to port 502, so as long as you stay within the CPU's connection resource budget (8 active TCONs on 1214C), both protocols operate simultaneously without an additional CP.

How many Schneider PM5000 meters can one S7-1200 1214C poll over Modbus TCP?

Up to 8 MB_CLIENT instances are supported by the library, but the practical ceiling on the X1 interface is 8 simultaneous TCP connections. A typical production cell with 4 meters and 1 HMI works comfortably; expand to 8 meters only if the poll interval is ≥500 ms per meter.

What STATUS code indicates an illegal Modbus address returned by the PM5320?

MB_CLIENT reports STATUS = 0x80C4 when the slave returns a Modbus exception. Re-check MB_DATA_ADDR against the 1-based holding register table; PM5320 starts the energy registers at address 1029, not 0.

Do I need a CM 1243-1 or CP 1243-1 communication module?

Not for the question's scenario. A CM/CP is required only if you need a separate IP subnet, more than 8 Modbus TCP clients, Modbus TCP server functionality, firewall/VPN security, or routing to a Modbus serial (RS-485) network. For a single 1214C with one PM5320 and one WinCC panel, the integrated port is sufficient.

Which TIA Portal version supports MB_CLIENT V5 with REAL data buffers?

MB_CLIENT V5 was introduced with S7-1200 firmware V4.4 and TIA Portal V15.1. With V5 you can point MB_DATA_PTR directly at a REAL array and read float32 values from the PM5320 without manual byte swapping. Earlier versions require the V3 instruction and a manual swap block.

What is the default Modbus TCP port and unit ID for the Schneider PM5320?

Port 502, unit ID 255 (or 1 depending on the meter configuration). The PM5320 user manual specifies that Ethernet access uses unit ID 255 by default. If MB_CLIENT returns STATUS 0x80C4, switch the unit ID through the meter's front panel.

Back to blog