IMDHMIControls LibraryShop main store

How-to

Connecting third-party Modbus TCP devices to a Modicon MC80

Industrial networks Published 8 min read

Short answer

Yes. A Modicon MC80 under Control Expert Classic exchanges data with any third-party Modbus TCP device through explicit READ_VAR and WRITE_VAR calls plus the device's register map — there is no ESD or EDS import, no IO Scanning and no DTM support. Run the MC80 as the TCP client, keep the exchange in the coil and holding-register tables, and latch each result in the reader so a 16 ms update survives a slower PLC poll.

On this page
  1. Why the device file has nowhere to go
  2. Choose the client role, then the map
  3. Map Modbus tables to Control Expert addresses
  4. Commission the link step by step
  5. Handle the 16 ms update with a latch and a handshake
  6. Symptoms and their causes
  7. Questions asked

Yes, it works: a Modicon MC80 programmed with Control Expert Classic exchanges data with third-party Modbus TCP devices such as barcode readers, and the integration is smaller than the missing documentation suggests. The MC80 supports no IO Scanning, no DTMs and no DHCP service, and Modbus defines no device description file, so there is nothing to import — the device's register map plus explicit READ_VAR and WRITE_VAR calls in your program is the entire job. Run the MC80 as the TCP client, keep the exchange in the coil and holding-register tables, and latch every result in the reader behind a trigger and acknowledge handshake so a 16 ms device update survives a slower PLC poll. The same client-polling discipline behind reading Modbus TCP from a ControlLogix PLC without a gateway applies here, with READ_VAR in place of the MSG instructions.

Why the device file has nowhere to go #

ESD and EDS files belong to EtherNet/IP and CANopen, and GSD files to PROFIBUS; Modbus defines no device description format at all. A Modbus device is documented by a data map — which table, which offset, how many registers, and what each bit or word means — and that map is the only device description this project uses. The ESD file shipped with the reader has no role on this link: the register layout comes from the reader's documentation or from your own firmware group, since the reader is developed in-house.

Two platform limits shape the work. Without IO Scanning, the MC80 runs no background cyclic exchange with the device the way a scanner-capable controller would; every exchange is a request your program issues and supervises. With no DTM support, nothing about the device is configured from a tool browser — the program calls carry everything.

Choose the client role, then the map #

A Modbus TCP link has two roles, decided by which side initiates the transaction.

Criterion MC80 as TCP client with READ_VAR / WRITE_VAR Reader as TCP client, MC80 memory as the map
Who initiates each exchange The PLC program, at the rate you program The reader firmware
What the reader must implement A Modbus TCP server and a published register map A full Modbus client with retry and timeout logic
Trigger bits PLC writes them into the reader's tables Reader polls %M and %MW in the MC80
Fit for a reader you develop in-house Best fit when the reader already serves Modbus TCP Only when updates must be paced by the device

Make the MC80 the client. The reader then needs nothing beyond a standard Modbus server and a documented map, the PLC owns the poll rate, and the trigger bits travel over a path you already control. Build the reader-as-client variant only when the device itself must pace the updates.

Map Modbus tables to Control Expert addresses #

The legacy Modbus reference numbers convert to Control Expert addresses table by table:

Modbus table Legacy reference Control Expert address Access
Discrete inputs (bits) 1xxxx1 and up %I0 and up Read only
Coils (bits) 0xxxx1 and up %M0 and up Read/write
Input registers (words) 3xxxx1 and up %IW0 and up Read only
Holding registers (words) 4xxxx1 and up %MW0 and up Read/write

Legacy references are one-based and the % addresses are zero-based, so the first object of each table sits at offset 0: a manual that lists 40001 and a request that carries offset 0 name the same register. An off-by-one here returns a neighboring register's data with no fault raised, so settle the convention against the reader's documentation before coding. A window that spans a hole in the map comes back as an exception rather than silence — the failure described in Modbus exception 02 when a read crosses a register map gap.

One platform limit decides the map design: the READ_VAR and WRITE_VAR family addresses the read/write areas — %M bits and %MW words, which are the coil and holding-register tables on the wire. Input registers and discrete inputs, the read-only 3x and 1x tables, are not fetched by these calls. Put the reader's status, length and data words in the 4x table, and put the trigger bits in coils or pack them into one 4x word that only the PLC writes; one writer per word removes every read-modify-write race.

  1. Put both devices in one IP domain. Assign static addresses on one subnet to the MC80 Ethernet port and to the reader; the MC80 provides no DHCP service. A reader on another subnet needs a router between them and a gateway address in the MC80. Confirm: ping the reader and the MC80 from a laptop on the same switch.
  2. Write the reader's map on one page. Trigger bits, status and valid bits, length word, data words — each with table, offset and count. Confirm: every item lands in the 4x or 0x table the calls can reach.
  3. Test the map before any PLC code. Point a Modbus test client such as ComTest Pro at the reader, or simulate the reader with ModRSsim2 when the hardware is not available. Confirm: the data words read back as documented, and a toggled trigger bit produces the documented behaviour.
  4. Reserve the PLC memory. Allocate %MW buffers for the received data and %M or %MW flags for triggers and status. Confirm: the cross-reference in Control Expert shows no other logic writing those addresses.
  5. Build the connection. Configure the Ethernet port, turn the destination into the address array the call consumes (ADDM exists for exactly that), and pass the management table the call requires with its timeout set above the reader's slowest documented response. Modbus TCP servers listen on TCP port 502.
  6. Call READ_VAR edge-triggered. A level enable starts one exchange and then idles — the same one-shot trap behind why a TM200 READ_VAR reads Modbus data only once — so drive the enable from a rising edge at the poll rate you want. Keep one request in flight per connection and gate the next on done or error. Confirm: the call's activity and error reporting cycle, and the buffer matches the test client's values.
  7. Send the trigger with WRITE_VAR, giving it its own completion handling. Confirm: the reader starts its read phase on the trigger edge and sets its valid bit.
  8. Run one full exchange at a time. Trigger, wait for valid, read the window, acknowledge — never overlapping requests on one connection.

Handle the 16 ms update with a latch and a handshake #

The reader refreshes its data every 16 ms; the PLC's request rate is bounded by its scan time and by how long each call takes. Take an illustrative 30 ms poll — a mid-size program's cycle plus the exchange — and compare the clocks: between two polls the reader produces 30 ms / 16 ms = 1.875 updates. Over 480 ms that is 480 / 16 = 30 updates against 480 / 30 = 16 polls, so at most 16 of 30 codes are captured and 14 are lost — 47% of the readings never reach the PLC when the reader overwrites unconditionally. A faster poll narrows the gap and never closes it, because poll and update are unsynchronized clocks.

The fix lives in the reader, and its firmware is yours to change:

  • Latch each result. The reader holds a code in its window until the PLC acknowledges — by clearing the trigger bit or setting a dedicated acknowledge bit — so unread data is never overwritten. The exchange becomes a poll-and-zero handshake rather than an interrupt: the device waits to be collected.
  • Use a fixed window plus a length word. Variable-length strings fit a fixed block of registers when one word states how many following words are valid; fetch the status, length and data words in a single request so the triple stays consistent.
  • Gate acceptance on the valid bit. Copy the buffer into working memory only while the valid bit is set, then acknowledge.

With latching in place, the 30 ms poll loses nothing: a value's age never exceeds the poll interval plus the exchange time, roughly 35 ms in this illustration. The handshake is mandatory, not optional, the moment scan time plus exchange time exceeds 16 ms. One boundary stays fixed regardless — Modbus TCP is a data protocol, not a safety one, so if a missing or wrong read can cause a hazardous move, that protection belongs in the PLC program or a safety controller, not in this handshake.

The window in numbers #

Put the trigger word at legacy reference 40101, the status word at 40102, the length word at 40103, and 25 data words at 40104 through 40128. Convert the references: 40101 - 40001 = 100, so the trigger is %MW100; the status word is %MW101 and the length word %MW102; the data words run %MW103 to %MW127. One READ_VAR beginning at %MW101 for 127 - 101 + 1 = 27 words fetches status, length and data together. A length word of 8 means the code occupies %MW103 through %MW110, because 103 + 8 - 1 = 110, and the rest of the buffer is padding. One WRITE_VAR of a single word to %MW100 clears the trigger and releases the reader for the next code.

Symptoms and their causes #

Symptom Cause Action
No place to load the ESD or EDS file Modbus has no device description; the MC80 has no DTM or IO Scanning Drop the file; use the register map and the program calls
Reader unreachable from the MC80 Different subnet with no router, or a wrong gateway address Correct the IP plan and verify with pings in both directions
Neighboring register's data, no fault Off-by-one: reference 40001 is %MW0 Rebase every offset from the one-based reference
Exception on a wide read The request crosses a gap in the map Shrink or split the request inside the documented window
READ_VAR runs once, then never again Level enable on the call Edge-trigger the enable at the intended poll rate
Codes go missing intermittently Reader overwrites between polls Latch results and require the acknowledge
Reads fine in the test client, fails from the PLC The window sits in the 3x or 1x table Move the window into the 4x table

Commission the gates in order and the link comes up in one session. The failures that dominate this integration — a level-enabled call, an off-by-one reference, and a map in the wrong table — each have a confirm gate above that catches them before startup ends.

Questions asked

Where do I load the ESD or EDS file for a Modbus TCP device in Control Expert?

Not in this project: the Modbus TCP world defines nothing to import, so the project tree has no slot for one, and the register map replaces the file as the source of table, offset, count and meaning. Keep the ESD file for the EtherNet/IP variant of the same hardware, where it is the right instrument.

Why does READ_VAR execute only once even though its enable stays true?

A level enable starts exactly one exchange; the call then reports done or error and waits for another edge instead of repeating. Drive the EN input from a rising edge — one common pattern is the %S6 system bit through an r_trig — and pace that pulse source at the poll rate you actually want. One edge then means one request, on your schedule.

Can the barcode reader write directly into MC80 memory instead of being polled?

Yes, if its firmware runs as a Modbus TCP client. The MC80's %M and %MW areas then become the data map and the reader paces every update, but the device must implement its own retry and timeout logic and the PLC still has to react to the memory. For a reader that only serves Modbus, keep the MC80 as the client: less firmware work and one owner of the poll rate.

What is actually lost when the PLC polls slower than the 16 ms update?

Without latching, every update that lands between two polls is overwritten before it is read. In the worked example a 30 ms poll captured 16 of 30 updates over 480 ms, so 14 codes vanished. With the reader holding each result until the acknowledge arrives, the same poll delivers every code, and the only cost is latency: a value is never older than the poll interval plus the exchange time.

Keep reading

  • How-to

    Setting up a CODESYS Modbus TCP client to talk through a gateway

    In CODESYS, Modbus TCP is an application library, not a fieldbus add-on: reference the Modbus TCP Client SL library, point the client at the gateway's IP on port 502 with the gateway's unit ID, and split the map into contiguous blocks of at most 125 registers per request. Every value is a cached copy whose worst-case age is the gateway poll cycle plus your client's map refresh time, so budget both against the freshness the process needs.

    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

    Linking Modbus RTU BMS SCADA to a redundant S7-1500R

    Use one Modbus RTU-to-TCP gateway as the Modbus TCP client, and run the Modbus TCP server on the S7-1500R system IP address that switched communication moves to the surviving CPU. The BMS keeps polling its RS-485 link unchanged; on a switchover the TCP session drops and the gateway reconnects. Set the comm-fail timeout to the measured gap plus one poll interval: 3 s at a 1 s rate in the example.

    Industrial networks