Run the link as Modbus RTU: your HMI is the client, a Modbus server function block in your PLC is the server, and one WORD array carries every register between them. Wire RS232 as transmit-to-receive with a shared signal common, set both ends to 19,200 baud, 8 data bits, even parity, 1 stop bit, and give the server address 1. Read-only display values sit at the front of the array, writable setpoints at the end, and one test register proves the whole map before you build a screen. If the HMI has no Modbus RTU driver, budget a raw serial driver instead: message framing, boundaries and checksums by hand, days of work rather than an hour of mapping. A bench link inside one cabinet stays RS232; a second HMI or a longer run moves you to RS485 with the same register map.
Modbus RTU or a raw serial driver: decide first
RS232 defines the electrical layer only: voltage levels, connector styles and cable length. What crosses the wire is whichever protocol both ends speak, so the real decision is software. When the HMI lists a Modbus RTU driver, take it, and the protocol work disappears: the HMI becomes the client, the traditional master, sending every request, while the PLC runs a Modbus server function block, the traditional slave, that only answers. The PLC needs no protocol code of its own.
With no Modbus driver on the HMI, the honest cost is a hand-written serial driver in the PLC runtime: message boundaries, request parsing, response construction and a checksum, all on top of your application logic. In a CODESYS V3 runtime that means the SysCom serial library. Price those days of code against a Modbus-capable panel before you commit to them.
Modbus brings no device-description file either. CANopen hands you a file that lists every variable and its index; Modbus publishes nothing about itself, so the register map is a contract you write and both sides keep. That map comes after the copper below. When the job grows past one HMI and one PLC, the counting changes with it too: how many Modbus devices fit an HMI connection covers the limits once several devices share the link.
What you need
- An HMI with a Modbus RTU client driver on its serial port; most industrial panels list one.
- A PLC runtime with a serial Modbus server function block or device; in CODESYS V3, a Modbus serial slave added under the controller's serial port.
- Shielded two-core cable with a drain wire; 22 AWG [0.33 mm²] is ample at RS232 speeds.
- Connectors or terminal adapters to match both ports, chosen after you read the two pinouts.
- A USB-RS232 monitor or the runtime's own diagnostics, for the one-register test.
- Your register list: count the display values and setpoints on every screen before you size the array.
Wiring the RS232 link
RS232 is point-to-point: one HMI, one PLC, nothing else on the cable. The planning limit carried by the TIA/EIA-232 guidance is 15 m [50 ft] at full speed, and a machine cell sits far inside that. Read both pinouts before you crimp, because identical DB9 shells hide DTE and DCE wiring: on the PC-style DB9, a DTE receives on pin 2, transmits on pin 3 and carries signal common on pin 5. Build the cable so transmit meets receive and the two commons join. A cable copied from the connector's look rather than the pinouts puts TX on TX, and the link stays silent.
Segregate the run on the backplate. Keep it at least 4 in [100 mm] from drive output and other power wiring, crossing at right angles where they must meet, as cabinet EMC practice has it; the backplate and DIN rail layout guide lays out that separation. Bond the shield's drain wire at one end only, usually the cabinet entry. At the HMI end, size the gland entry from the cutouts, glands and HMI windows guide, and rear wiring protection at an HMI enclosure covers what the rear cover must carry.
For a second HMI or a run beyond 15 m [50 ft], change the physical layer, not the protocol. RS485 carries the same register map over a planning figure of 1,200 m [4,000 ft] at low baud, with 32 devices on the line before a repeater. One client per line still holds, so the second HMI needs its own serial port or a move to Modbus TCP. Where a wiring trough carries the trunk between two enclosures, keep the boxes' connection gasketed; connecting a wiring trough to a panel without losing the rating walks that joint.
Serial settings that must match at both ends
The Modbus serial line specification sets the default at 19,200 baud, 8 data bits, even parity, 1 stop bit. With parity switched off, use 2 stop bits, so every character still carries 11 bits; that count is what every RTU timing figure rests on. Server addresses run 1 to 247, with 0 held for broadcast, which an HMI link has no use for. Most drivers insert the 3.5-character silence between frames themselves, 2.0 ms at 19,200 baud, so the values that need your judgement are the response timeout and the poll interval, both sized in the worked example below.
| Setting | HMI (client) | PLC (server) | A mismatch looks like |
|---|---|---|---|
| Baud rate | 19,200, the specification default | same | CRC errors or silence |
| Data bits | 8 | 8 | garbled frames |
| Parity and stop bits | even with 1 stop; none with 2 stops | same | CRC errors on every frame |
| Server address | target 1 | 1, from the range 1-247 | timeouts |
| Frame silence | 3.5 characters, 2.0 ms at 19,200 baud | same | lost frames at fast poll rates |
| Response timeout | 500 ms at 9,600 baud | n/a | alarms on a healthy link |
| Poll interval | 1,000 ms at 9,600 baud | n/a | a saturated line |
One mismatched digit shows as silence or a stream of CRC errors. A PLC with no server block looks identical from the outside, so confirm that function block exists before you blame the cable.
Laying out the register map in one WORD array
Size one array to the whole map: 33 words for the screen used below. Point the server block at it with a register count of 33, starting at protocol address 0. Read-only display values occupy entries 0 to 27 and operator setpoints occupy entries 28 to 32, so a mis-addressed display object cannot land on a setpoint.
| Array entries | Owner | Direction | Handling |
|---|---|---|---|
| 0 to 27 | PLC application | PLC to HMI | display values; mark the range read-only where the server block allows it |
| 28 to 32 | HMI operator | HMI to PLC | setpoints; validate, then republish the accepted value |
Map by convention, then prove it. Editors that label holding registers from 40001 point at protocol address 0; other editors number from 1, or from 0. Write 12,345 to entry 0 in the PLC and read entry 0 at the HMI: whichever convention shows the value is yours, and you document it once for the whole project.
Treat every 32-bit value as two registers with an agreed word order. Write 1 into the pair and read it back as a 32-bit integer: 65,536 on screen means the words are swapped, so flip the order in the driver. Signed 16-bit values betray themselves the same way, because -256 read as unsigned shows 65,280.
For the setpoints, copy each incoming write into a working variable, range-check it, and publish the accepted value back to the same entry. A rejected setpoint then snaps back within one scan, 10 ms in the worked example, instead of sitting on screen as if it had been accepted. Where the server block offers per-range access flags, marking entries 0 to 27 read-only adds a second guard behind the HMI objects.
Timing a 33-register poll at 9,600 baud
The case: one screen of 28 display values and 5 setpoints, one client, 9,600 baud 8E1, and a PLC scan of 10 ms. The register count comes from the map above. The character size, the frame lengths and the 125-register cap on one read come from the Modbus serial line specification, which counts 11 bits per RTU character. Swap in your own count and baud, and every line below scales with bytes and inversely with baud.
The rule: line time for any frame is bytes × 11 bits ÷ baud, and 3.5 character times of silence separate frames. A function 03 request for 33 registers is 8 bytes long. Its response is 71 bytes: three header bytes, 66 data bytes and a 2-byte CRC. At 9,600 baud one character takes 11 ÷ 9,600 = 1.146 ms. The request costs 8 × 1.146 = 9.2 ms, the gap 3.5 × 1.146 = 4.0 ms, and the response 71 × 1.146 = 81.4 ms. Round trip: 9.2 + 4.0 + 81.4 = 94.6 ms, call it 95 ms, plus the 10 ms scan for about 105 ms end to end.
Set the response timeout to 500 ms and the poll interval to 1,000 ms. A working floor is three times the round trip for the timeout and five times for the poll, so a late reply never queues behind the next request. At 19,200 baud the same poll runs 47 ms on the wire and 57 ms with the scan, where a 200 ms timeout and a 500 ms poll clear both floors. The register cap bites above this size: a full 125-register response is 255 bytes, 292 ms at 9,600 baud or 146 ms at 19,200, so split a bigger map into two reads or raise the baud.
Connecting the link, step by step
- Read both pinouts and mark TX, RX and signal common at each end before touching a screwdriver.
- Build the cable: transmit to receive, receive to transmit, common to common, with the shield drain bonded at the cabinet-entry end only.
- Set 19,200 baud, 8 data bits, even parity, 1 stop bit and server address 1 at both ends.
- Add the serial Modbus server in the PLC project. In CODESYS V3 that is the Modbus serial slave device added under the
Modbus_Slave_COM_Portobject, where you enter the slave address and the port parameters. Point it at the 33-word array with a register count of 33 and enable it in the scan. - Add the Modbus RTU client driver in the HMI project on its serial port: the same parameters, a 500 ms response timeout and a 1,000 ms poll interval.
- Prove the path with one register: move 12,345 to entry 0 in the PLC and read entry 0 at the HMI, trying each address convention until the value lands.
- Map entries 0 to 27 as display objects, all read-only.
- Map entries 28 to 32 as write objects using function 06 for single registers, and set each object's format to match the PLC: signed, unsigned or 32-bit.
- Run the word-order test on every 32-bit object: write 1, expect 1; a 65,536 means swap the two words.
- Watch the driver's diagnostics for 10 minutes: zero CRC errors, with responses landing near 105 ms.
Checks that prove the link works
- The request-to-response time at the HMI sits near 105 ms at 9,600 baud; double that means the scan or the map grew.
- Pull the cable: the HMI raises its comms alarm inside the 500 ms timeout, and on-screen values freeze as stale rather than reading live zeros.
- Enter 150 into a setpoint bounded 0 to 100: the value snaps back within one scan, 10 ms.
- Power-cycle both ends and confirm the server block starts by itself; one that waits for a manual enable is a Monday-morning fault.
- Leave it polling for an hour, then read the counters again: zero CRC errors and zero timeouts.
Six faults that stop this link
- Parity and stop bits disagree between the ends; parity set to none without 2 stop bits garbles every frame.
- Both ends programmed as clients: a PLC with no server block never answers, however clean the frames look.
- A cable built from the connector's look instead of the two pinouts, leaving transmit on transmit.
- Polling faster than the round trip: below 105 ms at 9,600 baud the requests queue and the line saturates.
- An array shorter than the map: writes past the end return exception 02, illegal data address, in a five-byte reply that at least proves the wire.
- A cyclic copy that republishes application values over entries 28 to 32, erasing each operator write between scans, so the setpoints never take.
What to order for the HMI end
The link itself lives in software; the hardware worth specifying is the HMI station and its cable entry. Flush in a cabinet door, an HMI panel needs a sealed bezel and one gland. Hanging at the machine, it wants a housing: our HMI enclosures are 304 stainless with a VESA 100 rear mount and a gasketed rear cover, and the 10.1 in panel PC HMI housing and 15 in panel PC HMI housing are the sizes most operator stations land on. The front seal is IP65-type with the display installed, a manufacturer rating, not UL listed; the serial cable meets the gasketed rear cover, so plan its gland entry the way the cutouts and glands guide sets out.
When no catalog size fits, our custom enclosures build the same box in 304 or 316L stainless to your width, height, depth and every cutout, from one piece, delivered in 10 business days from your approval of the drawing.
Decide by case. One HMI within 15 m [50 ft] of the PLC: RS232 as wired here. A second HMI or a longer run: RS485 as the physical layer, one client, the same 33-register array. Several HMIs or a plant-wide link: Modbus TCP, where device counts set the limit instead. An HMI with no Modbus driver and no spare serial port: adding serial ports to a 10 in IP66 touchscreen covers the ways to gain one, and a replacement panel still beats days of raw serial code.
Catalog dimensions to compare
Compare these catalog dimensions with your component layout. Open each enclosure for its rating, material and usable space, then check those specifications against your application.
| Enclosure | Material | Outside H x W x D / display | Rating |
|---|---|---|---|
| 10.1" HMI enclosure | 304 stainless | 8.72 x 12.66 x 3.48 in | IP65-type front seal with the display installed, manufacturer rated; not UL listed |
| 15" HMI enclosure | 304 stainless | 12.91 x 16.06 x 3.88 in | IP65-type front seal with the display installed, manufacturer rated; not UL listed |
| 15.6" HMI enclosure | 304 stainless | 11.69 x 17.64 x 4.13 in | IP65-type front seal with the display installed, manufacturer rated; not UL listed |
Questions
Does the HMI have to be the Modbus RTU master?
Yes. A serial RTU line carries one client, the traditional master: the HMI sends every request and the server only answers. An HMI with a Modbus RTU driver is already that client, so the PLC side runs a Modbus server function block; a PLC programmed only as a client never answers. Server addresses 1 to 247 are free for you to assign.
What serial settings should both ends use?
Start from the Modbus serial line default: 19,200 baud, 8 data bits, even parity, 1 stop bit (8E1). With parity set to none, use 2 stop bits so every character still carries 11 bits. All settings must match exactly at both ends; one mismatch shows up as a stream of CRC errors or total silence.
Why does the HMI show a wrong value when the link is healthy?
Two usual causes. A one-register offset: editors that label holding registers from 40001 point at protocol address 0, so read entry 0 at both 40001 and 40002 and keep the convention that shows the value. Swapped word order on a 32-bit value: write 1 and read it back; a 65,536 means the two words are reversed.
How fast can the HMI poll a Modbus RTU screen?
At 9,600 baud a 33-register read takes about 95 ms on the wire, so set the poll interval to 1,000 ms and the response timeout to 500 ms. At 19,200 baud the same poll drops to about 47 ms and a 500 ms poll clears it easily; polling faster than the round trip only queues requests.





