Troubleshooting
Why WinCC Modbus TCP reads fail on an FX5U server
Short answer
A Modicon-driver WinCC connection to an FX5U Modbus TCP server fails when it uses port 299 and remote slave ID 255 while the FX5U listens on port 502 and answers unit ID 1, and when D0 is not addressed as holding register 4x400001. Correct those three settings, then verify ping, TCP port, a capture and a known value in D0.
On this page
- Where does the Modbus request stop?
- Why is port 299 wrong for the FX5U connection?
- Why does remote slave ID 255 fail and 1 work?
- How do you map FX5U D0 to a WinCC tag?
- What exactly do you change in the WinCC project?
- How do you prove each hop works?
- What comes back to bite you on the next connection?
- When is the fault the decision?
- Questions asked
A WinCC runtime using the Modicon Modbus TCP driver fails to read an FX5U configured as a Modbus TCP server, while the same runtime reads an S7-1200 and a Schneider M340, and a Modbus test tool reads the FX5U without trouble. That pattern convicts three settings in the HMI connection, not the PLC's server function or the cabling: the server port was 299 instead of 502, the remote slave ID was 255 instead of 1, and D0 must be addressed as holding register 4x400001. Fix those three values and verify the link hop by hop. If you are instead setting up the FX5U server side from scratch, the native-connection setup is covered in making an FX5U a Modbus TCP server for a KTP700 panel; this article is about the Modbus client side.
Where does the Modbus request stop? #
The request dies at the connection layer and again at the address layer: the TCP session never opens because the client calls port 299 while the FX5U listens on the registered Modbus TCP port 502. Trace it as five hops, because each has a distinct failure signature. A working test tool proves the first two hops only.
| Hop | What must be true | Evidence in this case |
|---|---|---|
| Ethernet | Link up, same subnet or routed path | Test tool works from a PC, so the FX5U port is alive |
| TCP session | Client connects to the port the server listens on | Connection used port 299; server listens on 502 |
| MBAP unit ID | Unit identifier accepted by the server | Connection used 255; the FX5U answers 1 |
| PDU address | Function code and register offset map to a valid device | Tag must be in the 4x holding area, for example 4x400001 for D0 |
| HMI tag layer | Tag bound to the right connection and data type | Tags go under the FX5U connection, 16-bit first |
Why is port 299 wrong for the FX5U connection? #
Port 502 is the port registered for Modbus TCP, and the FX5U's Modbus TCP server listens there by default; a SYN to port 299 hits a closed port, the session never opens, and every tag on that connection goes to bad quality. Port 502 is a convention with teeth: any other port requires the server to be explicitly configured to listen there in its own project. So the decision is simple: set the WinCC connection to 502 unless you have deliberately changed the FX5U's Modbus server port in the PLC engineering software, in which case match whatever that setting says. The earlier S7-1200 and M340 connections prove the driver and runtime work; they do not prove the parameters transfer, because each server applies its own port and unit ID rules.
Why does remote slave ID 255 fail and 1 work? #
The unit identifier sits in the 7-byte MBAP header of every Modbus TCP request, and the FX5U's server answers unit ID 1 in this configuration, so a request carrying 255 is dropped or ignored and shows up as a timeout even with TCP open. Some Modbus TCP servers treat 255 as an ignore-all value, which is why the setting can work against one PLC and fail against another; do not rely on that behavior, set the ID the target actually uses. Read the unit ID configured in the FX5U's Modbus device assignment and enter exactly that value in the connection's remote slave ID field. The Modbus TCP addressing errors between an HMI and a PLC guide on fixing Modbus TCP addressing errors between an HMI and a PLC covers the same unit ID and offset classes of fault for other server brands.
How do you map FX5U D0 to a WinCC tag? #
D0 is holding register 4x400001 in the tag table: the Modicon driver prefixes the register number with a function-area digit, holding registers use the 4x prefix, and the addressing is one-based, so protocol address 0 appears as 400001. Create the tag under the FX5U connection with that exact address and a 16-bit integer type first; add 32-bit and floating types only after the 16-bit read is confirmed, because word order comes from the FX5U's Modbus device assignment, not from the Modbus specification. Check the device assignment table in the FX5U project to confirm which Modbus register range points at D0 and how D, M, X and Y map; do not extrapolate the D0 example to other device classes. If a value reads one register off, suspect the one-based versus zero-based convention before touching the PLC mapping; the details of how PLC-side Modbus TCP server configuration works decide that mapping.
What exactly do you change in the WinCC project? #
Change three values, compile, download and test; the whole fix is five minutes of editing. Do it in this order:
- Open the connection to the FX5U in the HMI's Connections editor (driver: Modicon Modbus TCP/IP).
- Confirm the partner IP address equals the FX5U's configured IP and that the HMI sits on the same subnet or has a route to it.
- Change the server port from 299 to 502.
- Change the remote slave ID from 255 to 1.
- In the HMI tag table, create a test tag under that connection with address 4x400001 and a 16-bit integer type.
- Set the acquisition cycle to about one second while testing, so the runtime does not flood the FX5U's connection handler.
- Compile, download and start the runtime, or simulate it from a PC with network access to the FX5U.
How do you prove each hop works? #
Verify in hop order so each result isolates one layer; skip nothing, because a pass at one hop says nothing about the next. Close the Modbus test tool before starting the runtime, since the FX5U's server connection slots are limited and a second client may be refused while the test tool holds its session.
- Ping the FX5U's IP address from the machine running the runtime. No reply means the fault is at layer 2 or 3: address, subnet, VLAN or cable.
- Test the TCP port from the same host. From PowerShell:
Test-NetConnection 192.168.3.250 -Port 502(that address is an example; use your FX5U's IP).TcpTestSucceeded : Trueconfirms the server listens on 502 and nothing blocks it. - Capture with Wireshark on the HMI-side port using the filter
tcp.port == 502. A completed handshake followed by a request with unit ID 1 and a matching response shows the session is up; a request with no reply points to unit ID or an unmapped register; a response carrying an exception code points to an invalid address or function. - Compare the capture against the test-tool session that worked: unit ID, function code (read holding registers, FC03) and starting address must all match what the runtime sends.
- Write a known value to D0 from the FX5U program or device monitor, for example 1234, then read 4x400001 in the runtime and confirm the displayed value tracks it, changing it once to rule out a stale read.
What comes back to bite you on the next connection? #
Four habits prevent the repeat: close the test tool before the runtime starts, keep 16-bit tags until the mapping is proven, re-enter parameters for every new server, and document the one-based convention. Duplicating the working S7-1200 or M340 connection carries over their port, unit ID and addressing assumptions, which is exactly how port 299 and slave ID 255 arrived in this project. The built-in Modbus driver follows Modicon-style behavior; a third-party server that follows the Modbus specification works once port, unit ID and addressing match, but confirm each device class separately before building screens around it.
When is the fault the decision? #
Commit to these values for this configuration: port 502, remote slave ID 1, tag address 4x400001 for D0 under the FX5U connection, and a one-second test cycle. If the ping, the port test and the capture all pass and the known value still does not track, the remaining fault is in the tag layer: connection binding, data type or word order, and the capture's exception code tells you which. If the port test fails, the fault is the FX5U's server setting or a firewall, not the HMI, and you go back to the PLC project's Modbus configuration before touching another tag.
Questions asked
Why does the test tool work but WinCC does not on the same FX5U?
The test tool was set to the port and unit ID the FX5U accepts, so its requests reach a listening server. The WinCC connection carried port 299 and slave ID 255, so its TCP session opened against a closed port or its request was dropped at the unit ID. Driver compatibility is not the problem; the connection parameters are.
Can I keep port 299 if I set the FX5U to listen there?
Yes, if the FX5U project explicitly configures its Modbus TCP server on that port. Port 502 is the registered Modbus TCP port and the usual default, but the pair only has to match on both ends. Match the HMI to whatever the PLC project actually sets rather than the other way round, and keep the setting documented for the next technician.
Why does 32-bit tag read garbage after 16-bit reads work?
The word order and starting register of a 32-bit value depend on the FX5U Modbus device assignment and the driver's float or double-word convention. Confirm the mapping table in the PLC project, then try the swapped word order setting in the tag. The Modbus specification does not fix word order, so two servers can split a 32-bit value differently.
How many WinCC connections can I run to third-party servers?
The Modbus TCP driver documentation for the runtime limits third-party communication driver connections; check the current limit in the driver manual for your version before planning a large screen set. One connection to the FX5U carries many tags, so build all FX5U tags under that single connection rather than opening one connection per screen.