IMDHMIControls LibraryShop main store

Troubleshooting

Why an S7-1200 Modbus TCP client shows no data through a gateway

Industrial networks Published 6 min read

Short answer

When a Modbus TCP test utility reads the instrument through the gateway but the S7-1200 shows nothing, the Ethernet path already works; the PLC's request does not match it. Copy the working request's destination, unit identifier, function code, address and count, capture the PLC at a switch mirror port, and read MB_CLIENT STATUS to place the fault at connection, timeout or exception stage.

On this page
  1. What a working utility run proves
  2. Capture the PLC at a mirror port, not at the PC
  3. Read the STATUS word before the next request erases it
  4. Match the fields the gateway routes on
  5. Worked example: rebuild one proven request
  6. From the observed exchange to the decision
  7. Step-by-step checklist
  8. Questions asked

If a Modbus TCP test utility reads the instrument through the serial gateway while the S7-1200 shows nothing in TIA Portal, the Ethernet path already works: the gateway answers, its service on TCP port 502 accepts connections, the serial route is alive and the instrument returns data. What the test has not proven is that your PLC sends the same request. Treat the utility's successful exchange as a specification, not as a verdict on the PLC: copy its destination, unit identifier, function code, starting address and register count into the client instruction, capture the PLC's packets at a switch mirror port rather than at the engineering PC, and read the MB_CLIENT STATUS word to decide whether the fault sits in the connection, the timeout or the request itself.

What a working utility run proves #

The successful utility exchange proves four things at once: the gateway's IP address answers on the network, its Modbus TCP service accepts connections on TCP port 502, its serial route to the instrument works, and the instrument returns valid register data. None of that involves the PLC.

It does not prove that the PLC program runs its communication routine, that the client instruction's connection parameters point at the same gateway, or that the request carries the same unit identifier, function code, starting address and register count. A configured connection alone moves no data; the instruction has to execute on a request condition in the running program. Going online with TIA Portal opens an engineering connection for watching program values — it does not poll the instrument.

If the PLC was earlier verified against a Modbus simulator, that run verified the PLC side only. A simulator accepts almost any addressing; a real gateway routes on fields a simulator ignores. Compare the two configurations instead of treating the simulator result as an end-to-end success.

Capture the PLC at a mirror port, not at the PC #

On a switched Ethernet network, a PC port receives only the frames addressed to that PC. If your capture tool running on the engineering PC shows the utility's traffic but nothing between the PLC and the gateway, that proves where the capture sat — not that the PLC sends nothing.

Configure the switch to mirror the port facing the gateway or the PLC, or use a network tap. Validate the capture first by rerunning the utility's exchange through it: you must see both the request and the response frames before an absence of packets means anything. Then close the utility and capture one PLC polling attempt, so the only frames on the wire are the PLC's.

Read the STATUS word before the next request erases it #

While an exchange runs, the instruction's STATUS output in the instance data block walks through busy states — 16#7005 while the request is being sent, 16#7006 while the response is being received. After a failed execution the ERROR output is TRUE for one scan only, so copy STATUS into a holding variable in that same scan, or you will read the next attempt's state instead of the failure.

The documented codes split the fault into families. Diagnostic code 16#0000 runs a loopback test of the connection path without touching the instrument, which is the first check when no data arrives at all — this is covered step by step in Why MB_CLIENT shows STATUS 16#0000 but no data arrives. Connection-class errors point at addressing and reachability. Timeout-class errors — request sent, no answer — point at gateway routing or the serial side. Exception and data-access errors such as 16#8383, an error reading or writing data, point at the request fields; access outside the server's register map is the typical cause, and the register-count pattern behind it is covered in Why MB_CLIENT returns error 8383 on multi-register reads.

Match the fields the gateway routes on #

The gateway's IP address identifies the box; the unit identifier selects the downstream serial device. Some pure Ethernet servers ignore the unit identifier; a serial gateway in front of one instrument usually does not. Before sweeping identifiers such as 1, 16 and 255, read the identifier the working utility sends and use exactly that value.

Match every field the same way:

  • Destination: the same gateway IP address and TCP port 502 the utility used.
  • Mode: the instruction's operation input set to read, not write.
  • Function code: the same code, normally 03 for holding registers.
  • Starting address: the numeric address on the wire, not the display reference. Display 40001 is wire address 0, and 40101 is wire address 100 — display minus 40001.
  • Quantity: the same register count, small enough for one read.

Worked example: rebuild one proven request #

Suppose the utility's captured request reads: destination 192.168.1.10, TCP port 502, unit identifier 1, function code 0x03, wire address 0, quantity 2. The expected response is fully determined by those fields: byte count = 2 registers × 2 bytes per register = 4 data bytes; total frame = 7 MBAP header bytes + 1 function byte + 1 byte-count byte + 4 data bytes = 13 bytes. Capture that response and keep it as the reference.

Now suppose the PLC sends the same function, address and quantity but a unit identifier of 16. The gateway's route points at serial device 1, so nothing downstream answers; the client waits out its timeout and reports a timeout-class status, and the receive buffer stays empty. Change only the unit identifier to 1 and leave every other field identical. The PLC now receives the same 4 data bytes the utility received. If the buffer fills but the monitored tags stay wrong, the fault is on the PLC side — buffer addressing, data type or word order — not in the network.

From the observed exchange to the decision #

With a validated mirror capture, the observed exchange places the fault at one stage and names the fix:

What the capture shows Where the fault sits Decision
No frame from the PLC at all Connection configuration, or the routine never runs Verify destination IP and port, and that the request condition occurs in the running program
TCP open attempt refused or unanswered Gateway service or an access restriction Match the port and check the gateway's connection limits
Request sent, no response Gateway routing or the serial side Copy the working unit identifier; check the instrument address on the serial route
Exception response returned Protocol-level rejection Decode the exception code, then correct the function code, wire address or quantity
Normal response, empty tags PLC-side buffer handling Check buffer address, data type and word order

Work top to bottom: a normal response with correct bytes but wrong tags is the only case that stays inside the PLC.

Step-by-step checklist #

  1. Capture the working utility request and record its destination, unit identifier, function code, wire address and quantity.
  2. Close the utility; competing polling sessions hide which client sent each frame.
  3. Validate a switch mirror port (or tap) by rerunning the utility exchange through it.
  4. Capture one PLC polling attempt on that validated point.
  5. Read STATUS in the scan the ERROR output fires, held in a copy variable.
  6. Apply the fix the table names for the observed stage.
  7. Rerun a single request and compare the response byte count with the utility's reference exchange.

Questions asked

Why does the MB_CLIENT ERROR output stay TRUE for only one scan?

The ERROR output of MB_CLIENT is TRUE for a single scan after an execution ends with an error, so periodic monitoring misses it. Add logic that copies the STATUS value from the instruction's instance data block into a separate holding variable during the same scan the error fires, then read the copy from a watch table. Otherwise the next request's state overwrites the failure information before you ever see it.

What does MB_CLIENT status 16#8383 mean?

16#8383 reports an error reading or writing data, and a request reaching outside the server's register map is the typical cause. Check the wire address and quantity against the map size the gateway publishes. Remember the display-to-wire offset: holding register display 40001 is wire address 0, so display 40101 is wire address 100. Persistent 8383 values on a read that carries many registers point at the read length itself.

Does going online in TIA Portal poll the instrument?

No. The online connection between the engineering station and the CPU carries program and diagnostic traffic only. Modbus requests are issued by the client instruction executing in the running program whenever its request input is triggered. A CPU that sits online with no communication logic cycling shows an empty receive buffer indefinitely, even with a completely healthy gateway and instrument.

Can the unit identifier matter when the network side is Modbus TCP?

Yes. The IP address selects the gateway, and the unit identifier tells the gateway which downstream serial device to route the request to. Some pure Ethernet servers ignore the field; serial gateways usually do not. Take the identifier from a captured request that is known to work instead of sweeping values such as 1, 16 and 255 until something happens to answer.

Keep reading

  • Troubleshooting

    Why MB_CLIENT shows STATUS 16#0000 but no data arrives

    A no-error STATUS of 16#0000 from MB_CLIENT certifies that the request cycle completed, not that the values reached the receive array. With an empty array, audit the request definition first: make the address span satisfy end minus start equals quantity minus one, set the unit identifier the converter forwards to the downstream slave's ID, and give the bit-type objects a destination of the matching type. Until those three checks pass, treat the clean status as unproven.

    Industrial networks

  • How-to

    Set up a CLICK Plus as Modbus TCP client to an S7-1200

    Yes: make the S7-1200 the Modbus TCP server with MB_SERVER mapped to a data block of INTs, and make the CLICK Plus the client with Send and Receive instructions aimed at the CPU's IP address and port 502. Write the shared register map first; the S7 logic copies physical inputs into it and applies its output words to the real outputs.

    Industrial networks

  • Troubleshooting

    Fix Modbus TCP FC02 discrete inputs returning no data

    FC02 finishing with no error while the client BOOLs stay FALSE is a mapping fault, not a network fault: the server block's discrete-input buffer is BYTE storage, and unpacked bytes read back as zero bits. Declare the buffer in BYTE, pack each state into its bit, and match the requested range. The FC03 reads that already work prove the connection.

    Industrial networks