How-to
What an S7-1500 needs as Modbus TCP server for a PC master
Short answer
When the central PC is the Modbus TCP master, the S7-1500 runs as server with one MB_SERVER call per connection; MB_CLIENT instances belong to the side that initiates requests. Map the holding registers with an absolute pointer into a standard-access DB, sized in words to the register range the PC will touch, and give any additional server connection its own instance DB, connection ID and port.

On this page
You have the roles backwards, and the correction saves you two blocks. The central PC is the Modbus TCP master, so the S7-1500 must be the server, and a server needs MB_SERVER — one call for the PC's connection and no MB_CLIENT instances at all. MB_CLIENT makes the PLC the active side that dials somebody else's server; a pair of them, one for reads and one for writes, is the pattern for a PLC that polls. Everything the PC does, reading and writing, is served from the holding-register area you map on MB_HOLD_REG with an absolute pointer into a DB without optimized access.
Give the server job to MB_SERVER #
In Modbus terms the PC is client and master, the PLC is server and slave — two names for the same two roles. The PC software initiates every transaction; the PLC only answers. Configure it that way:
- Keep the master role on the PC. Nothing in the PLC has to initiate a read or a write.
- Call MB_SERVER cyclically for the connection the PC holds. It listens on the port you set, accepts each request, executes it against the mapped area and answers.
- Do not call MB_CLIENT for this job. A client block opens a connection to a remote server and issues requests — the opposite direction. The two-instance read/write split belongs to a PLC acting as master.
- One server block serves both directions: the holding register holds the values a Modbus client may access with function 3 (read), function 6 (write single) and function 16 (write multiple).
Map the holding registers with an absolute pointer #
Function 3 reads holding registers, and on this CPU the holding registers are exactly the area MB_HOLD_REG points at; a request outside that area is what 16#8383 reports.
- Create a global DB for the Modbus data and untick the optimized-access setting in its properties; the pointer needs fixed absolute offsets, which an optimized block does not have.
- Connect an absolute pointer to MB_HOLD_REG. The configuration that cleared the reported fault was
P#DB103.DBX0.0 WORD 10— DB 103, byte offset 0, ten words. - Check the arithmetic: WORD 10 is ten 16-bit words, 20 bytes, and one holding register is one word, so the mapping exposes holding registers 40001 through 40010, with 40001 at byte offset 0.
- Size the length to the range the PC touches, in words: last register minus 40001 plus 1. Worked example: the PC's longest read runs to 40012, so 40012 − 40001 + 1 = 12 words, which is 24 bytes, and the pointer becomes
P#DB103.DBX0.0 WORD 12. - Keep the mapping tight instead of mapping whole DBs: one report shows 16#8187 once the pointer spanned more than 3000 words.
- Because function 6 and 16 writes from the PC land directly in these words, never map an output word; keep the area as data memory and let the program decide what a written command does.
- If the PC software uses the 4xxxx convention, the word-to-register layout follows the standard Modbus holding-register and input-register memory map.
Fill the connection data #
- The call takes its connection parameters through CONNECT. Set the local port there to 502, the standard Modbus TCP port, and point the PC software at the same port.
- Enter the hardware identifier of the PROFINET interface the PC is cabled to as InterfaceID; with the PC on the X2 port it is that port's identifier, the same point behind why an S7-1500 X2 Modbus server accepts TCP but no DONE arrives.
- Work through the call, its instance DB and the download once with the guide to connect an S7-1500 to Modbus TCP in TIA Portal.
Add a second server connection correctly #
More than one MB_SERVER call is allowed; the online help states its rules per connection.
- Give the second call its own instance DB. Each server connection must use a unique instance DB, because that is where the call keeps its connection state.
- Assign a unique connection ID in its CONNECT data as well. Reusing an ID is the common cause of the connect error a second instance throws, reported as a TCON-type status.
- Give the second connection its own local port number too, following the multi-connection example.
- Count resources: the total of all Modbus TCP client and server connections on the CPU must not exceed the maximum the CPU supports, so several masters plus any MB_CLIENT calls all draw from one budget.
- Treat the instance DB and the connection ID as a fixed pair for the life of the project — the same reason each instruction instance needs its own tag.
Prove the mapping from a master simulator #
- Write a known value into the mapped words, for example 1234 into the first word.
- From a Modbus master simulator, send function 3 to 40001 for ten registers; ten words must come back with 1234 first and no exception.
- Send function 6 with a new value to 40002 and watch the second DB word change in the online view — that proves the write path end to end.
- Then ask for eleven registers at 40001, one past the mapping: the master reports an illegal data address and the server's STATUS shows 16#8383. Seeing that failure exactly where the arithmetic put it is the proof the boundary is right.
The setup to download #
- One PC master: one MB_SERVER call, CONNECT with the standard port and the cabled interface's identifier, and an absolute pointer sized to the register range.
- A second master or a bench simulator: a second MB_SERVER with its own instance DB, connection ID and port, inside the CPU's connection total.
- Status 16#8383: the request ran past the mapping — widen the word length or shorten the request, and change nothing else.
Questions asked
Can the PC read and write the same area through one MB_SERVER call?
Yes. Functions 3, 6 and 16 all act on the one area MB_HOLD_REG points to, so a single mapping carries both directions and no second block is needed. Because the PLC program shares those words, copy a command word to internal memory and range-check it before acting on it, and write measured values back into the area for the PC's next read.
What caused status 16#8383 before the pointer fix?
In the reported case a struct tag was connected symbolically, as MyDB.MyVar, and the requested range did not fit what that connection exposed, so the CPU answered with the status for data outside the address area. Disabling optimized access and connecting an absolute pointer cleared it. If you keep a symbolic structure, it must cover the entire range the master requests.
Does an HMI panel on the PLC's other Ethernet port interfere?
No. A panel connected over PROFINET uses the CPU's HMI connection resources, not a Modbus TCP connection, so it needs no change and does not draw from the Modbus budget. Enter the hardware identifier of the interface the PC is cabled to as InterfaceID, and the Modbus server and the panel link run side by side on their own interfaces.
Does the PC master need a GSDML file or a hardware object in TIA Portal?
No. Modbus TCP is ordinary TCP communication, so the PC never appears in the device configuration and there is no GSDML to import. The PLC-side objects are the MB_SERVER call, its instance DB, the CONNECT data and the mapped DB; on the PC side the software needs only the PLC's IP address and the port you set, 502 in this setup.


