How-to
Connect an S7-1500 to Modbus TCP in TIA Portal
Short answer
Modbus TCPIP is Modbus TCP: Modbus frames carried over TCP on Ethernet, listening on port 502. On an S7-1500 you connect by calling MB_CLIENT over the integrated PROFINET port in TIA Portal. Choose client or server by which side initiates the request; most connections to an older system need the PLC as client.
On this page
- Is Modbus TCPIP the same as Modbus TCP?
- Should the S7-1500 be the client or the server?
- What must you collect from the remote system first?
- How do you configure MB_CLIENT in TIA Portal?
- What do REQ, DONE, ERROR and STATUS tell you?
- How do you verify the connection with a real request?
- Why do values read wrong or requests stop?
- Questions asked
Yes, "Modbus TCPIP" means Modbus TCP: the Modbus application frames carried over TCP on Ethernet, with the server listening on TCP port 502. On an S7-1500 you make the connection by calling MB_CLIENT from the program in TIA Portal over the integrated PROFINET interface, and the only real decision up front is whether your PLC initiates the requests or answers them. This article walks through that decision, the connection setup, and the checks that prove the link works.
Is Modbus TCPIP the same as Modbus TCP? #
Yes. Modbus TCPIP on an older system is Modbus TCP: the same Modbus function codes and register addresses that serial systems use, wrapped in TCP segments on Ethernet instead of an RTU serial frame. You do not need a converter or a serial module unless the remote device itself only has a serial port.
Two practical consequences follow. First, the protocol needs no dedicated hardware on the S7-1500: MB_CLIENT communicates through the CPU's PROFINET connection, so the work is configuration and program, not wiring. Second, the register model carries over unchanged, including the one-based register numbering in most device manuals against the zero-based offset the protocol actually sends. If every value later reads one register off, that convention mismatch is the first thing to check.
Should the S7-1500 be the client or the server? #
Decide by which side initiates the request, because Modbus is strictly a request/response protocol. The client sends the requests and the server holds the data and answers them; nothing happens on a quiet link. When the older system expects to be polled by your PLC, the S7-1500 is the client and you use MB_CLIENT.
| What the older system does | Your S7-1500 role | What you build |
|---|---|---|
| Exposes registers and waits to be polled | Client | MB_CLIENT with the partner's IP address |
| Polls your PLC for data | Server | A passive Modbus TCP server instance in the PLC |
| Only ever acts as a client itself | No direct fit | A gateway or a device that can serve registers |
If both sides are clients, no direct PLC-to-PLC Modbus TCP link exists; insert a gateway or a device willing to sit in the server role. For the common case, the older system is the server, and the S7-1500 establishes the connection actively toward it. The PLC-side server configuration, when you need that role instead, is covered in the article on what you must configure on the PLC side for Modbus TCP.
What must you collect from the remote system first? #
Four facts, all from the old system's documentation or its configuration screen. Without them you cannot write a correct request, and guessing any of them produces connection errors or wrong data rather than a clear message.
- The IP address of the remote device, for example 192.168.0.50.
- The TCP port it listens on; servers listen on port 502 unless the documentation states otherwise.
- The unit ID it expects, which matters most through a gateway fronting serial devices.
- The register map: start addresses, quantity, read or write access, and the word order used for 32-bit values.
Also give the S7-1500's PROFINET interface an IP address in the same subnet as the remote device, or a routed path to it, and download the hardware configuration before any program work.
How do you configure MB_CLIENT in TIA Portal? #
The whole client setup is one instruction call plus its connection data. Place it, fill the connection structure, then wire the request inputs from the remote register map.
- In the Instructions task card, open the Communication section, find the Modbus TCP group, and insert MB_CLIENT into a cyclic block such as OB1. Accept the single instance DB the system offers.
- Fill the connection structure the block references with the partner IP address and the partner port, actively established from the PLC.
- Set the request inputs from the register map: the input that selects read or write, the start address in Modbus convention, the quantity of registers, and the data pointer aimed at a global data block of Word values sized to the transfer.
- Drive REQ from a timer-generated pulse or a trigger bit, not from a condition that skips the call. Call the block every scan; a skipped call leaves the transaction hanging mid-state.
- For a second request, sequence it: wait for DONE or ERROR from the first call before changing the parameters and re-triggering REQ, because one instance handles one request at a time. The request-sequencing pattern for this block is described in the guide on configuring S7-1500 MB_CLIENT request sequencing for Modbus TCP.
Note that the exact mapping from address range to function code (coils, discrete inputs, input registers, holding registers) is stated in the instruction help for your installed TIA Portal version. Read that table before filling the address input rather than assuming it from another device's manual.
What do REQ, DONE, ERROR and STATUS tell you? #
Each transaction is one request/response exchange, and the block reports it through four outputs you should wire on every call. REQ starts it, BUSY runs while the exchange is in flight, DONE is true for one scan on success, and ERROR is true for one scan when the execution terminated with a fault.
STATUS carries the error code value, and it is valid only for the scan in which ERROR is true, so capture it into a memory word if you want to log or display it. Look the code up in the instruction help for your version rather than treating codes as universal across libraries. If your application needs several client connections, note that duplicate connection identity produces connection errors; the two-instance failure mode on an MB_CLIENT setup is a separate article on this site.
How do you verify the connection with a real request? #
Work one small read end to end before touching control-relevant registers. As a worked example, suppose the remote server is at IP address 192.168.0.50 on port 502, and its manual lists holding registers 40001 through 40010.
- Address: 40001 in one-based manual convention is offset 0 in the protocol, so the start-address input gets 0.
- Quantity: 10 registers, so the data block needs an array of 10 Word values.
- Trigger: pulse REQ once. Expect BUSY true, then DONE true for exactly one scan with ERROR false.
- Content: watch the receive data block online. The values must match what the remote system displays for those same registers, with any engineering scaling applied on top.
- Write test: write one documented, harmless register and confirm the change appears on the remote system's side before you connect anything that controls equipment.
If the request fails at the packet level, capture on a mirrored port: a normal exchange shows a TCP handshake to port 502, a request with the correct unit ID and function code, and a response. A Modbus exception response instead means the server rejected the address, quantity or function code, which points at the register map rather than the network.
Why do values read wrong or requests stop? #
Three faults account for most of it. Off-by-one addressing: manuals list 40001 while the protocol sends a zero-based offset, so a consistent one-register shift means the conventions differ. Wrong unit ID: a direct Ethernet device may ignore it, but a gateway routes by it, and a mismatch returns an exception or silence. Word order on 32-bit values: floats that read as nonsense while the individual registers look right mean the two words are swapped between manufacturers, so swap them in the PLC.
Two more are self-inflicted. Re-triggering REQ every scan floods older servers; poll at an interval the device sustains, often hundreds of milliseconds. And a server that accepts few simultaneous TCP connections can be blocked by a leftover SCADA link, so count every client on the wire before blaming the PLC. Unplug the cable once deliberately: expect ERROR with a non-zero STATUS, then automatic recovery when the link returns, with a defined stale-data fallback written into your own logic.
Questions asked
Do I need a separate communication module for Modbus TCP on an S7-1500?
No. MB_CLIENT runs over the PROFINET interface built into the CPU, so any S7-1500 with that interface and an IP address in a reachable subnet talks Modbus TCP directly. A module is only needed if you must add a second physical network segment or reach serial Modbus RTU devices, which takes a gateway instead.
What is the unit ID for on a Modbus TCP request?
It is the old serial slave address, carried in the TCP frame as the unit identifier. A direct Ethernet device usually answers with one fixed ID, but a gateway fronting several serial devices routes each request by that ID, so a mismatch makes the gateway answer with an exception or nothing at all. Take the value from the remote system's manual.
Can two programs poll the same S7-1500 Modbus TCP server at once?
Only up to the connection limit the server actually accepts. Older servers accept very few simultaneous TCP connections, and a forgotten SCADA link can consume one. If two instances of the same client block are involved, the two-instance behavior that breaks Modbus TCP reads from one server is covered in a separate troubleshooting article.
Why does my 32-bit float read as a nonsense value?
Modbus registers are 16-bit words and a 32-bit float spans two of them, but the order of the two words differs between manufacturers. If the individual registers read correctly but the combined value is garbage, swap the two words in the PLC before interpreting the data. Word order is a per-device setting, not a protocol rule.