Siemens S7-1200/S7-1500 Modbus TCP Setup Guide (TIA Portal)
Siemens is one of the PLC brands engineers most often need to pair with a Modbus PLC simulator — the S7-1200 and S7-1500 don't speak Modbus natively the way a Schneider Modicon does, so the wiring inside TIA Portal has a few gotchas that trip people up the first time. This guide walks through configuring Modbus TCP on an S7-1200 or S7-1500 with the MB_CLIENT and MB_SERVER instructions, then verifying the whole program against a simulated Modbus device before any field hardware is on site.
MB_CLIENT/MB_SERVER vs Modbus_Master/Modbus_Slave
TIA Portal actually ships two separate instruction families for Modbus, and mixing them up is the single most common source of confusion:
| Connection Type | Instructions Used | Hardware Required | Role |
|---|---|---|---|
| Modbus TCP (Ethernet) | MB_CLIENT / MB_SERVER |
Built-in PROFINET/Ethernet port — no extra module | Client = master (polls devices), Server = slave (exposes data) |
| Modbus RTU (serial) | MB_COMM_LOAD + Modbus_Master / Modbus_Slave |
CM 1241 RS485 or CM 1241 RS422/RS485 module |
Master polls devices, Slave exposes data |
Both TCP instructions live in TIA Portal under Instructions → Communication → Others → MODBUS TCP, are included free in the standard instruction library from TIA Portal V11 onward, and run on both the S7-1200 and S7-1500 CPU families.
Setting Up MB_SERVER (PLC as Modbus TCP Slave)
Use MB_SERVER when your S7-1200/S7-1500 needs to expose its own data — for example, so a SCADA system or a Modbus master can poll the PLC's internal values as if it were a field device.
- Drag
MB_SERVERinto a network in OB1 (it must be called cyclically, every scan, not just on a one-shot condition) - Create the instance data block when prompted
- Set
CONNECTto aTCON_IP_v4connection parameter structure with the local port (typically 502) and, for a server, leave the remote IP blank/zero so it accepts any client - Point
MB_HOLD_REGat the data block holding your Modbus register data - Critical: right-click that data block → Properties → uncheck "Optimized block access." Modbus addressing depends on fixed byte offsets, and an optimized DB will not lay memory out the way
MB_SERVERexpects
Setting Up MB_CLIENT (PLC as Modbus TCP Master)
Use MB_CLIENT when your PLC needs to poll a Modbus TCP device — an energy meter, a VFD, or (during development) a Modbus simulator running on your PC.
- Drag
MB_CLIENTinto OB1, also called every scan - Configure
CONNECTwith the target device's IP address and port 502 - Set
MB_MODEto select read (0) or write (1) andMB_DATA_ADDRfor the Modbus register address you want - Point
MB_DATA_PTRat the local data block where the read/write values will be stored, again with Optimized block access disabled - Monitor
STATUSfor the result — a non-zero value here is almost always the fastest way to identify a configuration problem
A single S7-1200 or S7-1500 can run MB_CLIENT and MB_SERVER at the same time on different connection IDs — polling field devices as a master while simultaneously serving its own data to a SCADA system as a slave.
Testing Against a Simulator Before Field Devices Arrive
Because Siemens PLCs don't have native Modbus support the way Schneider Modicon does, engineers commissioning an S7-1200/S7-1500 project usually can't fully validate the Modbus logic until the real meters, VFDs, or gateways show up on site — unless they simulate the other end. Here's the workflow:
- Run ModbusSimulator in Slave mode, Modbus TCP protocol, port 502, on your development PC
- Set the simulator's IP to the PC's LAN address and point your
MB_CLIENTinstance'sCONNECTparameter at that IP - Load the target device's real register map into the simulator (holding registers for setpoints, input registers for readings) so the values your PLC reads match what the actual meter or VFD will return
- Force test values in the simulator and step through your PLC's scaling/byte-order logic to confirm it decodes them correctly — this is exactly the kind of check covered in our byte order guide
- Stop the simulator mid-poll to confirm your
MB_CLIENTSTATUS logic correctly flags a timeout instead of silently holding stale data
This mirrors the general workflow in our PLC Modbus testing tool guide, but with the specific TIA Portal instruction names and pitfalls that are unique to Siemens.
Common Siemens Modbus TCP Errors
MB_CLIENT/MB_SERVER STATUS shows a connection error
- Confirm the PLC and the remote device (or simulator PC) are on the same subnet, and that a firewall isn't blocking TCP port 502
- Make sure
MB_CLIENTandMB_SERVERaren't sharing the sameCONNECTID if both are active - Check that only one side is initiating the TCP connection — if both are configured as active/client, neither will listen
Data reads back scrambled or as zero
- "Optimized block access" is almost always the culprit — disable it on the data block referenced by
MB_DATA_PTR/MB_HOLD_REG - Double-check
MB_DATA_ADDRuses Modbus's own numbering, not the S7 absolute address of your data block - For 32-bit values, verify byte/word order matches the source device — Siemens defaults to big-endian, but many Modbus devices use word-swapped order
Modbus TCP works, but PROFINET I/O also needs to run
This isn't a conflict — PROFINET and Modbus TCP can run over the same physical Ethernet port at the same time, since PROFINET operates at a different protocol layer than the TCP/502 socket Modbus TCP uses. No special CPU configuration is required beyond making sure both are enabled in your program.
Test Your Siemens Modbus TCP Program Without Field Hardware
ModbusSimulator runs as a Modbus TCP or RTU slave (or master) on your PC, so you can validate your S7-1200/S7-1500 MB_CLIENT and MB_SERVER logic — register maps, byte order, timeouts — before a single meter or VFD is wired up. Free 30-day trial.
Download Free tierRelated Articles
- Allen-Bradley PLC Modbus Setup Guide (ControlLogix, CompactLogix, Micro800)
- Schneider Modicon Modbus TCP Configuration Guide
- Delta PLC Modbus RTU Configuration Guide
- Mitsubishi PLC Modbus Communication Setup
- WinCC SCADA Modbus Integration and Testing Guide
- Ignition SCADA Modbus Driver Testing Guide
- PLC Modbus Testing Tool: Test Communication Without Field Devices
- Modbus TCP/IP Simulator: Test Ethernet Devices Without Hardware
- Modbus Byte Order Explained: Big-Endian vs Little-Endian
- Modbus TCP Port 502 Blocked — How to Open It
- How to Configure Multiple Modbus Slaves in One Tool