IMDHMIControls LibraryShop main store

Troubleshooting

Reading Modbus TCP from a ControlLogix PLC without a gateway

Industrial networks Published 9 min read

Short answer

Yes — ControlLogix reads Modbus TCP without a gateway card through Rockwell's sample Modbus TCP driver, but only on controller firmware version 20 or later with socket-capable Ethernet hardware such as a 1756-EN2xx module at firmware 5.007 or later. If either side misses the gate, use a standalone EtherNet/IP to Modbus TCP converter. When the driver runs, prove one request against a known-good PC client and match unit ID, start address and count field by field.

On this page
  1. Can a ControlLogix read Modbus TCP registers without a gateway?
  2. Why does MBTI_Connected read 1 but no register data arrives?
  3. Which controller firmware and Ethernet modules run the Modbus TCP sample code?
  4. What does Modbus exception 02 illegal data address actually tell you?
  5. How do you prove one known-good request before touching the PLC code?
  6. Which fields do you set in the sample transaction block?
  7. When is a standalone EtherNet/IP to Modbus TCP converter the better choice?
  8. What is the fix for each failure case?
  9. Questions asked

You can read Modbus TCP holding registers from ControlLogix logic with no in-chassis gateway card, but only through Rockwell's published sample Modbus TCP driver, and only when the controller runs firmware version 20 or later and the Ethernet module supports socket services, such as a 1756-EN2xx at firmware 5.007 or later. Miss either side of that gate and the right answer is a standalone EtherNet/IP to Modbus TCP converter, because a connected adapter proves nothing about the request you send. This article walks the gate first, then matches the PLC transaction against a known-good PC client field by field — unit identifier, start address, count — so an illegal-data-address exception gets fixed in the request, not in the network.

Can a ControlLogix read Modbus TCP registers without a gateway? #

Yes — the published sample Modbus TCP driver builds the protocol in controller logic over socket MSG instructions, and it runs only on a Logix 5000 controller at firmware version 20 or later with socket-capable Ethernet hardware, such as a 1756-EN2xx module at firmware 5.007 or later.

EtherNet/IP and Modbus TCP share the same cable and switches but speak different application protocols, the same split that stops Modbus carrying a ladder program over TCP. An ordinary CIP message or I/O connection cannot read a holding register. The sample closes that gap with a complete Modbus TCP master written in Logix code: it opens a TCP socket through the MSG instruction's socket mode, builds the request bytes, tracks transaction identifiers, parses replies, and handles exceptions, timeouts and retries. Rockwell documents the socket interface, including which modules support it, in its EtherNet/IP Socket Interface application technique, publication ENET-AT002. Treat it as protocol firmware living in your project: connections, transaction bookkeeping and recovery are now logic you own, which is exactly the maintenance load a converter would have absorbed for you.

Why does MBTI_Connected read 1 but no register data arrives? #

No — MBTI_Connected reading 1 proves only that the TCP session opened; the Modbus application layer on top of it can still carry a wrong unit identifier, wrong register type, wrong start address or wrong count, and each of those comes back as an exception instead of data.

Three layers sit between your logic and a value, and the sample's status words report them one at a time. MBTI_Connected = 1 is the transport layer. A TransID that increments means the logic is attempting transactions, so read the returned exception before changing any network setting. In the documented GE Multinet case, Enervista read all seven relays through the adapter, which proves the adapter serves Enervista's requests — it does not prove the PLC sends the same unit identifier and register span. The Multinet adapter adds its own addressing layer: depending on its mapping, the request selects the adapter endpoint, a downstream relay, or both, and the correct values live in the adapter configuration and in the working client's traffic. Prove one register from one relay before scaling to all seven, because unit-selection errors, unsupported ranges and polling load are much harder to separate once everything polls at once.

Which controller firmware and Ethernet modules run the Modbus TCP sample code? #

Version 20 or later on the controller and socket-capable Ethernet hardware gate the sample: 1756-EN2xx modules need firmware 5.007 or later, 1756-EWEB modules 4.006 or later, and 1768-EWEB 1.002 or later.

Check both sides before editing any logic. A 1756-L63 at version 19 — the documented case — cannot execute the driver: studying a printed report of the version 20 project shows its structure but adds no socket services to a version 19 controller. Publication ENET-AT002 lists every supported module, including several onboard-Ethernet CompactLogix 1769 controllers, so read its full list rather than trusting this article's short one. The decision per case: controller at version 20 or later with socket-capable hardware at its firmware floor — import the sample and configure it. Controller below version 20 — upgrade the controller firmware, add socket-capable communications hardware, or move the protocol conversion outside the chassis. And in every below-floor case, stop tuning register fields first, because no valid request can leave the module until the gate passes.

What does Modbus exception 02 illegal data address actually tell you? #

Exception 02 means the server received your request and rejected the data range: either the starting address does not exist for the selected unit, or the span from start through count runs past the end of an implemented block.

The Modbus application protocol specification defines exception code 02 as illegal data address, and it is good news in one sense: the server, the network and the cabling all work, so leave IP settings and switches alone and work on the request. Three causes cover nearly every occurrence. The address base is wrong, because device tables print human-readable register numbers while the wire carries a zero-based offset, one less than the printed number. The unit identifier selects a target for which that range does not exist, which is common behind an adapter that maps unit IDs to downstream devices. Or the count spans past the end of a block, so a valid first register still fails. In the documented power-meter case, TransStat = -1 with TransLastError = 2 traced back to exactly this exception, and the fix was in the address fields. The same code appears on any server: a CODESYS Modbus TCP server throwing exception 0x0002 fails for the same reasons.

How do you prove one known-good request before touching the PLC code? #

Prove the request on a PC Modbus TCP client first, then copy its six fields — server address, unit identifier, register type, register number, protocol start address and quantity — into the PLC transaction one for one.

Put the client on the same wire as the adapter and read one register whose live value you can recognize. Record these fields from the working exchange:

  1. the server endpoint: the adapter IP address and TCP port 502;
  2. the unit identifier the working client sends;
  3. the register type: holding (4x) or input (3x);
  4. the register number exactly as the device table prints it;
  5. the protocol start address: the printed number minus the table's base, 40001 for a holding-register table;
  6. the quantity.

Worked example, illustrative: the table lists holding register 40101, so the protocol start address is 40101 - 40001 = 100. The working client reads quantity 2 for a 32-bit value, covering addresses 100 through 100 + (2 - 1) = 101. If the device implements that block only up to address 100, the identical request from the PLC with Count = 2 returns exception 02 while Count = 1 succeeds — the start was valid and the span was not. Match the full span, not just the first address, and raise the quantity only after a count of 1 reads back correctly.

One safety note: the sample driver can write registers as well as read them, so keep write transactions off any device that actuates a running process until the read path is proven.

Which fields do you set in the sample transaction block? #

Set the transaction block from the proven client request, not from guesses: Enabled = 1, Transtype = 3 to read holding registers, UID as the adapter's mapping requires, BeginAddress as the protocol start address and Count as the proven quantity.

The transaction that failed against the documented power meter was set as Enabled = 1, PollInterval = 10, Transtype = 3, UID = 0, BeginAddress and Count device-specific, and Local Offset = 1; treat that block as a checklist of fields to prove, not a template to copy. UID = 0 worked because that meter answers at unit 0 directly attached; behind the Multinet adapter, the unit identifier comes from the adapter's mapping and from the working client. BeginAddress needs a variable large enough for the address: the documented Diris A40 case required a begin value larger than a 16-bit INT can hold, so the variable became a DINT — and the same edit did not by itself resolve a later Diris A60 install, which still needed its unit, address and count matched. PollInterval's unit and legal range come from the sample's own instructions, which also walk the import and configuration step by step.

When is a standalone EtherNet/IP to Modbus TCP converter the better choice? #

Buy the standalone EtherNet/IP to Modbus TCP converter whenever either side of the gate fails or you do not want transaction logic, exception handling and recovery living in your PLC project; the converter turns Modbus registers into ordinary EtherNet/IP input data.

The converter reads the Modbus registers itself and publishes them as EtherNet/IP input data the controller consumes like any other I/O, and writes flow back through output data into the Modbus registers. Nothing about transactions, exceptions, retries or reply buffers lives in your logic. The sample driver costs no extra hardware, but it moves configuration, exception handling, recovery, memory and long-term maintenance into the PLC project, and that is the load integrators who have carried both usually pay to avoid. Building conversion into a controller is a legitimate pattern when the protocol pair calls for it — using a PLC as a Modbus RTU to Profibus gateway shows the shape — but it carries the same burden as the sample code. If you would rather run the conversion as software beside the controller than as logic inside it, an industrial mini PC sized as a protocol-converter host does that job in the cabinet.

What is the fix for each failure case? #

Match the failure to its layer and the fix follows: no connection means IP, routing or the firmware gate; a connected socket with TransStat = -1 and TransLastError = 2 means exception 02, so fix the address fields, not the network.

Work the cases in this order:

  • No connection at all: the failure sits below the register layer. Verify the adapter's IP address and subnet, the route from the controller, and that the Ethernet module is socket-capable at its firmware floor; then recheck the gate above.
  • Socket connected, TransID incrementing, transaction failing: the server answered with Modbus exception 02, illegal data address. Correct the unit identifier, start address and count against the proven client request and leave the network alone.
  • Socket connected, transaction timing out: a timeout is a different failure from an exception reply, and why read timeouts mean no valid reply arrived explains that split. Check the endpoint address and that the adapter routes the request to the right downstream device.
  • Valid words, wrong engineering value: transport and addressing are correct, so fix data type, signedness, scaling or word order in the controller, comparing raw register words before any conversion.
  • Either side below the gate: upgrade the controller, add socket-capable communications hardware, or fit the converter — do not import and tune the sample.

The decision: pass the gate, prove one register from one device with a PC client, match the PLC request field by field, and scale out only after the first value reads correctly — or skip the controller code entirely and let a converter translate.

Questions asked

What does Transtype 3 mean in the Modbus TCP sample code?

Transtype 3 selects Modbus function code 03, read holding registers, the 4x range. Function code 04 reads input registers, the 3x range, and the sample exposes it through its own transaction type. Use the type your working PC client used: reading a holding-register address as an input register returns a wrong range or an exception, never the value you saw in the client.

Why did changing BeginAddress from INT to DINT fix one meter but not another?

A Logix INT is a signed 16-bit variable that stops at 32,767, while a DINT holds up to 2,147,483,647. In the documented case the meter required a begin value beyond 32,767, so only a DINT could carry it. The edit fixes range and nothing else: the second meter still needed its unit identifier, start address and quantity matched against a working client before any read succeeded.

How many holding registers can one Modbus TCP request return?

The Modbus protocol caps a read holding registers request at 125 registers, and a larger quantity is rejected with exception 03, illegal data value. Start at quantity 1, prove the address, then raise the count only to the smallest complete value, because every transaction also occupies a socket round trip and controller memory for the reply buffer.

Can I just embed the relay vendor's web page in my SCADA window instead?

You can display it, but an embedded page is not integration. It shows the vendor interface in a browser pane while creating no controller tags, no alarm logic and no logged values, so the SCADA system cannot alarm, trend or act on the data. If the values must live in the PLC or the historian, they still have to arrive through the converter or the sample driver.

Keep reading

  • Troubleshooting

    Fixing CODESYS Modbus TCP server exception 0x0002

    Exception 0x0002 means the CODESYS Modbus TCP server holds no point at the address the client requested. The Data Model start-address fields are offsets within each data type's standard range, so entering 10001 for Discrete Inputs pushes the first bit to reference 20002. Set each start address to 0, confirm the client's notation, then prove one point with a scanner.

    Industrial networks

  • How-to

    How to build a virtual PLC test bench for protocol practice

    One laptop runs the whole bench: a Modbus TCP server simulator, a master test client, a Node-RED OPC UA server and a SCADA trial connect over loopback, so you can practice addressing, sessions, scaling, alarms and fault diagnosis without a PLC. Work through three bounded projects and finish with seven pass criteria you can defend.

    Industrial networks

  • How-to

    Using a PLC as a Modbus RTU to Profibus gateway

    Keep the regulator and let one PLC carry both buses. Poll the regulator over Modbus RTU on a fixed cyclic interval, map every register to a defined PROFIBUS DP location with documented scaling, and hand the BMS a data-valid flag instead of stale values. Terminate each bus at its own two ends; never join RS-485 and PROFIBUS into one network.

    Industrial networks