How-to
Connecting an HMI to remote PLCs over a WAN
Short answer
Yes, it is feasible: an operator panel supervises geographically distributed PLCs over Modbus TCP on port 502 exactly as on a LAN, provided every site is reached through a site-to-site VPN or approved routed path with a valid return route. Never expose port 502 by public port forwarding, because Modbus TCP carries no authentication or encryption.
On this page
Yes — feasible, and it is a networking job more than an HMI job. An operator panel polls geographically distributed PLCs over Modbus TCP on port 502 exactly as it polls them on the plant LAN: one device entry per PLC, each with its own address and register map, the panel reading I/O status and writing the data you choose to expose. The remote CPUs keep their local logic untouched. What you must engineer is the WAN path: every site reachable through a site-to-site VPN or an approved routed private network, with a verified route back for the replies. Never expose port 502 to the public Internet with a forwarding rule, because plain Modbus TCP carries no authentication and no encryption.
What the WAN changes and what it does not #
Moving the link from LAN to WAN changes the path, not the protocol or the data. Modbus TCP carries the same register reads and writes over TCP, and the service listens on port 502, the port IANA registered for Modbus TCP. A request that works on the bench works across the country once packets flow both ways, so treat "remote" as an addressing and routing problem, not a driver problem.
Two conditions must hold for each site: the panel must reach the PLC's address on TCP 502, and the PLC's replies must have a route back to the panel's subnet. A firewall between the sites that blocks 502 stops the exchange even when ping succeeds — ping proves the host is reachable, not that the Modbus service is open.
Keep failure classes separate before touching the panel configuration. A TCP connection that opens on the LAN and times out across the WAN points at routing, filtering or a missing return route; values that arrive but are wrong point at the register map, data type or word order. The same isolation applies when the WAN is cellular and Modbus TCP works locally but fails remotely over cellular. When the panel is the moving end and the controllers stay put, the mirror case is remote HMI access with dynamic DNS and a VPN.
The path decision: a tunnel, not a forwarding rule #
Port forwarding is an inbound mapping on a site's gateway: traffic arriving at the gateway's public address on one port is redirected to a device address and port inside. It makes the PLC's Modbus service reachable, and it adds nothing else. Ordinary Modbus TCP has no authentication and no encryption, so a forwarded 502 is an unauthenticated, remotely operable read-and-write interface to your machine — the wrong security boundary for control.
| WAN path per site | What it provides | Decision |
|---|---|---|
| Public port forwarding of TCP 502 | Reachability only | Do not use |
| Site-to-site VPN between gateways | Private addressing, encrypted transport, no PLC exposure | Use this |
| Routed private carrier circuit | Private routing without Internet exposure | Acceptable where it already exists |
A site-to-site VPN terminated on the site gateways gives you the path without asking the panel or any PLC to run VPN software. Only the endpoint that must accept inbound tunnel connections needs a stable public address: with a hub-and-spoke design that is the single hub site, and spoke sites behind dynamic addresses can initiate outward. Confirm what each site's provider offers before fixing the architecture.
One hard requirement remains: site subnets must not overlap. If two plants both use 192.168.1.0/24, the panel has no unambiguous destination — renumber one site before configuring anything.
Setting up the panel, one device per remote PLC #
- Prove each link on the LAN first: connect the panel to one PLC, read a known register, and confirm the value in the PLC's programming tool. Debugging a remote path you have never proven locally wastes the tunnel work.
- Document each site's addressing: PLC address, subnet, gateway, service port, and the panel-side subnet. Resolve overlaps here, on paper.
- Bring up the tunnel and verify routes on both gateways: the remote PLC subnet resolves through the tunnel from the panel side, and a return route to the panel subnet exists at the far end.
- Open the minimal firewall rule — panel subnet to each PLC address, TCP 502, through the tunnel only — and leave inbound 502 from the Internet blocked on every site gateway.
- Add one device entry per remote PLC in EasyBuilder Pro, Weintek's engineering tool, each with its own address and its own register map, using the same driver settings that worked on the bench. Label screens and commands by site so an operator always sees which machine a setpoint targets.
- Run read-only for a shift, then test writes on one designated nonhazardous register: write it, confirm the PLC accepts it, read it back, and only then widen to operational setpoints.
- Enable communication-loss indication for every device, so a dead link shows as stale data instead of a frozen live-looking value.
Sizing the poll plan for three remote PLCs #
Inputs: three remote PLCs, each polled once per cycle for 50 holding registers with read function 03 — a typical project list, so substitute your own counts. Round-trip latency 30 ms, an example value: measure yours across the live tunnel with ping at commissioning. Every poll below pays that latency once. Link capacity 100 Mbit/s. Refresh targets to evaluate: 1 s and faster. The frame sizes below are documented Modbus facts, not assumptions.
Rule: one read is one request plus one reply, which is one round trip. On a WAN the round trip, not the data volume, sets the budget. Keep the total round-trip time in each refresh period under half the period, so one full retry still fits inside the cycle.
Arithmetic:
- Request frame: 7-byte MBAP header + 5-byte body (function 03, start address, register count) = 12 bytes.
- Reply frame: 7-byte header + 1-byte function + 2-byte count + 50 registers × 2 bytes = 110 bytes.
- Serialization per poll: (12 + 110) bytes × 8 bits = 976 bits ÷ 100 Mbit/s ≈ 10 µs — three thousand times smaller than the round trip, so latency dominates and data volume is irrelevant at this size.
- At a 1 s refresh: 3 PLCs × 1 poll each = 3 polls per second; busy time 3 round trips = 90 ms per 1000 ms = 9% duty.
- Retry budget: half of 1000 ms = 500 ms; 500 ms ÷ the round trip ≈ 16 polls per second before a retry stops fitting.
- At a 250 ms refresh: 3 × 4 = 12 polls per second → 12 round trips = 360 ms per 1000 ms = 36% duty — fits.
- At a 100 ms refresh: 3 × 10 = 30 polls per second → 30 round trips = 900 ms per 1000 ms = 90% duty — over budget; one retry blows the cycle.
Result: on this link, three sites at a 1 s refresh run at 9% duty with room to retry, and 250 ms still fits at 36%.
Decision: set remote refresh to 250 ms or slower on this link, and group registers so each PLC is one read per cycle — function 03 returns at most 125 registers per request, so 50 registers in a single read is fine. If you need faster than 250 ms on all three sites, shorten the polling list or reduce latency; the binding limit is the link's round trip, not the panel. The one number to read from the panel's specification is its documented maximum simultaneous device count — across a WAN, the round-trip arithmetic above usually binds first.
Acceptance checks before go-live #
- Path check — tunnel status and route tables on both gateways. Expected: the remote PLC subnet resolves through the tunnel from the panel side, and the return route to the panel subnet is present at the far end.
- Service check — from an authorized host on the panel subnet, open TCP to the PLC's address and port through the tunnel. Expected: the connection opens; a successful ping alone is not proof of Modbus availability.
- Data check — compare one panel value against the same variable in the PLC programming tool. Expected: identical value, sign and scaling.
- Write check — write the designated test register. Expected: the PLC accepts it or explicitly rejects it under the application's rules, and the readback matches.
- Link-loss check — pull the WAN during a controlled test. Expected: the machine keeps running on its own logic, the panel flags the communication loss, displayed values are marked stale, and no write appears to succeed silently.
- Reconnection check — restore the link. Expected: values refresh to current, and nothing written during the outage executes merely because the tunnel came back.
Keep the control authority in the local PLC #
Safety note: the WAN adds variable delay and can disappear entirely, so interlocks, sequencing and protective functions stay in the local PLC and its safety system — the remote panel supervises, and nothing essential may depend on the link being up.
Treat a command as three different things: requested by the operator, accepted by the PLC, and actually executed. A completed write proves data transfer, not physical action, so let the PLC validate every command against operating mode, permitted range and interlocks, and expose acceptance and machine state for the panel to display next to the button.
Questions asked
Is port forwarding to 502 acceptable if I use a high port number instead?
Renumbering the forwarded port does not fix the problem: Modbus TCP still carries no authentication or encryption, so anyone who finds the mapping can read registers and issue writes, and 502 remains the port the protocol and panel drivers are built around. The tunnel is the fix, not the port number.
Do all my PLC sites need static public IP addresses?
No. Only the gateway that must accept inbound tunnel connections needs a stable public address. With a hub-and-spoke design that is the single hub site, and spoke sites behind dynamic addresses or carrier NAT can initiate outward. Confirm the public-address situation with each site's provider before locking the design.
How many remote PLCs can one panel supervise?
Two limits apply: the panel's documented maximum simultaneous device count, which you read from its specification, and the poll budget you can calculate. At a 30 ms round trip, 16 one-read polls per second is the ceiling that still leaves room for a retry, so sixteen sites at a 1 s refresh is the practical cap on that link; faster refresh lowers it.
What should the operator see when the WAN drops?
The panel must flag communication loss per device and mark displayed values as stale rather than leaving the last value looking live; local machines keep running on their own logic. On reconnection, values refresh and nothing written during the outage executes merely because the tunnel returned. One site can drop while the others stay connected, so per-device indication tells the operator exactly which values are stale. Test it by pulling the link before go-live.
Do the remote PLCs need program changes?
Not for reads: the panel maps existing registers. For writes, add validation in the PLC — range, mode and interlock checks — and expose an acceptance flag and the actual state so the operator can tell a requested command from an executed one. That logic belongs in the local program, not in the panel.