How-to
HMI Modbus TCP client and server roles with no device driver
Short answer
With no dedicated driver, the HMI works as the Modbus TCP client and the controller's virtual Modbus TCP slave as the server that answers on port 502. Add and activate the virtual slave in PiCtory, add the generic Modbus TCP/IP device in EasyBuilder Pro, and take every register number from the server's process-image map — one register per two bytes of process image, so byte offset 20 is register 10.
On this page
- Which side is the Modbus TCP client, and which is the server?
- How do I make the controller answer Modbus TCP in PiCtory?
- Which device do I add in EasyBuilder Pro when no driver exists?
- Where do the Modbus register addresses come from?
- How do I enter the address so the HMI reads the right register?
- Why does a working connection still show the wrong value?
- In what order do I commission and prove the whole link?
- Questions asked
EasyBuilder Pro has no driver for a controller it was never written for, and none is needed: native Modbus TCP is the driver. Make the HMI the Modbus TCP client and the controller's virtual Modbus TCP slave the server — in PiCtory you add the virtual slave and activate the project so its Modbus service runs, and in EasyBuilder Pro you add the generic Modbus TCP/IP device with the controller's IP address, the server's listening port and the unit ID. Every request then starts at the HMI. Register numbers never come from the IP address: they come from the server's process-image map, where each register covers two bytes, so a channel at process-image byte offset 20 lives at register 10. The sections below configure both sides and prove each layer in order.
Which side is the Modbus TCP client, and which is the server? #
The HMI is the Modbus TCP client — the master that opens every transaction — and the controller's virtual Modbus TCP slave is the server that answers it. In PiCtory you therefore add the virtual slave, and every read and write on the screens starts from the HMI.
A Modbus TCP transaction has exactly two roles: the client sends a request carrying a unit ID, a function code, a data area and a quantity, and the server listens on one port and answers. The HMI takes the client role because the screens poll on their own refresh cadence and because operator writes originate there; a server never asks, it only answers.
This is also the decision behind the master-or-slave question in PiCtory. The virtual Modbus TCP Master entry makes the controller poll some other device and never accept a connection from the HMI. If both ends end up configured as masters, the two pollers block each other — the pattern behind the HMI Modbus timeout caused by a PLC master-slave conflict, and no register change fixes it.
How do I make the controller answer Modbus TCP in PiCtory? #
Add the virtual Modbus TCP slave (server) device in PiCtory, save the configuration, and run the activation procedure so the Modbus TCP service actually starts; the server then listens for client requests on TCP port 502 and serves the process image your I/O modules have built.
PiCtory lists the virtual Modbus TCP Master and the virtual Modbus TCP Slave alongside the physical I/O modules. The slave is the one that exposes the process image to clients, so place it in the configuration like any module. Saving alone starts nothing: apply the activation procedure for the installed RevPi software, then confirm the service is running and a listener is open on the controller's Ethernet interface — from a laptop, a TCP connect test to the controller on the Modbus port separates a stopped server from a wrong address in seconds.
Rule out one hardware dead end early: not every Ethernet interface can answer on the Modbus TCP port at all. If your controller side is a Mitsubishi FX3U-ENET, it cannot serve Modbus TCP on port 502 and none of the register work below will connect; that case is documented in why an FX3U-ENET cannot serve Modbus TCP on port 502.
Which device do I add in EasyBuilder Pro when no driver exists? #
Add the generic Modbus TCP/IP Ethernet device: in EasyBuilder Pro open System Parameter Settings, open the Device tab, select New Device/Server and pick the Modbus TCP/IP entry — the HMI becomes the Modbus client the moment this device exists.
EasyBuilder's device list carries several Modbus flavors: Modbus RTU on a COM port, RTU over TCP for serial frames wrapped by a gateway, and native Modbus TCP/IP. Choose the native TCP/IP entry; the RTU-over-TCP device expects encapsulated serial traffic and will not talk to a native server — why Modbus RTU over Ethernet is not Modbus TCP for an HMI walks through that difference.
Set the destination to the controller's IP address, leave the port at the server's listening port, and enter the unit ID the server accepts. The unit ID is a field of its own, separate from the address: a project whose unit ID does not match the server times out or collects exception responses even with flawless IP settings, and a single server typically answers one fixed small number such as 1 — its documentation states which.
The same System Parameter Settings dialog holds the Conversion setting, where the data format of the Modbus device types is configured; that is where the word order for multi-register values gets fixed later in this article.
Where do the Modbus register addresses come from? #
From the server's process-image mapping, not from the IP address: the IP locates the server, while each register number comes from the process-image byte offset that PiCtory shows for your I/O module, divided by two because one Modbus register carries 16 bits.
A Modbus request never names a variable; it names a unit ID, a function, a data area, a starting address and a quantity, and the server's own map translates that into process-image bytes. On the RevPi virtual Modbus TCP slave the map is fixed: the input process image is served as input registers (the read-only 3x area, function 04), the output process image is served as holding registers (the 4x area, readable with function 03 and writable with functions 06 and 16), and the register number is the byte offset divided by two.
The register table you may have found under a virtual Modbus TCP Master in PiCtory belongs to the other role entirely — it lists the requests the controller would send to a different server and has nothing to do with what your HMI reads here. Ignore it.
How do I enter the address so the HMI reads the right register? #
Translate once, then enter: a holding register at protocol address 12 is entered as offset 12 in a zero-based field and as reference 40013 in a one-based field, because one-based reference numbering starts at 40001 for protocol address 0.
Modbus counts locations from zero; the 3x and 4x reference convention on paper counts from one. The Modbus device's help page in EasyBuilder Pro states which base its address fields use, and mixing the bases is the most common off-by-one in HMI register work.
Worked example — one 16-bit analog input channel:
- PiCtory lists the module's input data at input process-image byte offset 20, and the channel is the first word there.
- Two bytes make one register, so the register number is 20 ÷ 2 = 10: input-register protocol address 10.
- One-based input-register references start at 30001 for protocol address 0, so protocol address 10 is reference 30011 (30001 + 10).
- In the HMI object, select the input-register (3x) data area and enter offset 10 under a zero-based driver, or reference 30011 under a one-based one.
- Force a known value onto that channel from the control program and confirm the object shows it before mapping anything else — every remaining screen is the same arithmetic.
The same +1 relationship on the holding-register side, walked register by register through a 450001-style address, is in decoding Modbus holding register 4500001 from PLC to HMI.
Why does a working connection still show the wrong value? #
A valid reply proves the path, not the value: width, signedness and word order decide what the bytes mean, and a 32-bit Real spanning protocol addresses 10 and 11 reads as garbage until its word order matches the controller's.
Each failure signature points at exactly one layer:
| What the HMI shows | What it decides | Where to look |
|---|---|---|
| Timeout or disconnected object | No server answered | Service running, listener open, IP address, port, unit ID, routing |
| Exception response | The path works; the request was refused | Function, data area, start address, quantity against the server map |
| Valid but unrelated number | Wrong location or wrong base | Data area, zero- vs one-based offset, the byte-offset arithmetic |
| Plausible but wrongly scaled | Right location, wrong interpretation | Width, signedness, word order in the data-format Conversion setting |
Test with a value you control: force a changing number onto one channel in the control program, read the raw register contents in the HMI, and only then add scaling or formatting. Never flip word-order options until a plausible number appears — a plausible wrong number is harder to catch than an obvious one. When the location itself is the suspect, fixing Modbus TCP addressing errors between an HMI and a PLC walks the byte-offset arithmetic between the two ends.
One safety line: enable a write object only after the read path is proven and you know which application owns the variable, because a write aimed one register off drives a real output on the controller.
In what order do I commission and prove the whole link? #
Prove the layers in order — network, server, device, one register, one value, then writes — and do not move on until the current layer passes, so any failure points at the single thing you changed last.
- Ping the controller's IP address from a laptop on the same network; success proves reachability, not Modbus.
- In PiCtory, add the virtual Modbus TCP slave, save, and run the activation; confirm the service is running and the listener is open.
- In EasyBuilder Pro, add the Modbus TCP/IP device under System Parameter Settings, Device tab, New Device/Server, with the controller's IP address, the server's listening port and the accepted unit ID.
- Download the project and create one read-only numeric object bound to the worked-example register.
- Force a known changing value onto that channel in the control program and watch the object follow it.
- Check the raw number before any scaling; correct data area, offset base, width, signedness or word order until the raw value matches.
- Only then enable a write object, on an isolated bench, with a test value that cannot move machinery.
Run the disconnect test the same way: drop the link, restore it, and watch a counter you control; the value it climbs to after recovery is the number that tells you the poll cycle caught up, and the device's timeout and polling settings decide how fast. Once one register reads true, the rest of the project is repetition, not diagnosis.
Questions asked
Why do some Modbus TCP examples use port 5020 instead of 502?
Port 502 is the standard Modbus TCP port and the one most controllers and HMIs answer on. Some software examples and test servers listen on 5020 instead, often because ports below 1024 require elevated privileges on Linux systems. The two ends only need to agree: the server's listening port and the port entered in the HMI device settings must match. Stay on the controller's documented port rather than copying a tutorial number.
What does the unit ID do when one IP address serves several slaves?
The unit ID distinguishes slaves that share one IP address, which is how a serial Modbus network sits behind a gateway with one Ethernet side. A controller that is itself a single server usually answers one fixed ID. If the HMI's unit ID does not match what the server accepts, requests come back as exceptions or time out even though the address and port are correct. Use the ID the server's documentation states.
Can the HMI write values back to the controller through this link?
Yes, but only through the data areas the server maps as writable. In this arrangement that is the holding-register area carrying the controller's output process image, where a write changes the values the control program consumes as its outputs. Prove the read path first, confirm which application owns the variable, and start with a test value that cannot move machinery.
Does Modbus TCP have any built-in security for a plant network?
None. Modbus TCP carries no authentication or encryption, so any device that reaches the port can read the process image and, on writable areas, change values. Keep the link on a segregated machine network or VLAN, firewall it away from office and remote networks, and reach it through a VPN rather than exposing the Modbus port to the internet.