A Modbus client polls a device on the machine for values, using its register map and read function codes 01-04 only. For OEE, read run status and a total count every second or two, and calculate the changes in your software.
What Modbus gives you, in plain terms
Modbus is a simple request and reply protocol. A client asks a device for a block of values, and the device answers.
You will find it on many PLCs, drives, power meters, temperature controllers, counters and remote I/O modules. That makes it a common way in when a machine has no modern interface.
It comes in two common forms. Modbus RTU runs over serial, usually RS-485, and Modbus TCP runs over Ethernet, normally on port 502.
The older documents say master and slave, and newer ones say client and server. They mean the same roles.
The four data types and how to read them
Everything in Modbus lives in one of four tables. For monitoring, you need only their read function codes.
| Table | Usual notation | Size | Read code | Example use |
|---|---|---|---|---|
| Coils | 0xxxx | 1 bit | 01 | A run or output bit |
| Discrete inputs | 1xxxx | 1 bit | 02 | A sensor or contact state |
| Input registers | 3xxxx | 16 bits | 04 | A measured speed or current |
| Holding registers | 4xxxx | 16 bits | 03 | Counters, status words, setpoints |
Read the register map first
Without a register map, Modbus is a list of numbers with no labels. Get it from the device manual or from the person who programmed the machine.
A map tells you the address, size and scale of each value. Here is what one might look like for a hypothetical machine.
| Register | Value | Type | Note |
|---|---|---|---|
| 40001 | Status word | 16-bit bits | Bit 0 = running, bit 2 = fault |
| 40002 | Fault code | 16-bit unsigned | 0 = no fault |
| 40003 | Speed | 16-bit unsigned | Value / 10 = parts per minute |
| 40011-40012 | Total count | 32-bit unsigned | 40011 = high word |
Decoding the values
Four traps that give wrong numbers
- The off-by-one address. Register 40001 is sent on the wire as address 0 of the holding registers. Some tools want 40001 and others want 0, so one wrong setting shifts every value.
- Word order. A 32-bit value spans two registers, and devices disagree on which comes first. If a count jumps wildly near each 65,536 step, swap the words.
- Signed against unsigned. The same 16 bits can read as 65,000 or as -536. Check the type in the map.
- Hidden scaling. A value of 1234 may mean 123.4 or 12.34, so confirm the scale by comparing with the machine's screen.
An error reply can help you here. Exception code 01 means an illegal function, 02 an illegal data address, often a wrong address or a block that runs past the map, and 03 an illegal data value, such as asking for too many registers.
How polling works, and how long it takes
Modbus devices usually do not send anything until they are asked. So a client loops through its list, reading each device in turn.
On an RTU bus only one request can be in progress at a time, so the loop time grows with each device. You can estimate it before you wire anything.
Example: a client reads 10 registers from each of 8 devices with an 8E1 serial format (8 data bits, even parity, 1 stop bit), which uses 11 bits per byte once you add the start bit. The request takes 8 bytes, and the reply takes 25.
That fits a 1 or 2 second poll. Double the devices or read much larger blocks, and it may no longer fit, so measure the real loop on your bus.
Modbus TCP removes the shared serial line, and each device has its own connection. Many devices still limit how many clients they accept, so check before you add a second one.
What to poll, and how often
Poll the fast-changing values often and the rest slowly. A sensible start for OEE looks like this.
- Status word and count: every 1-2 seconds.
- Speed and fault code: every 1-5 seconds, or read the fault code when status changes.
- Order or recipe number: every 30-60 seconds.
Polling has a blind spot, because it sees only the moment of each read. A bit that turns on and off between two polls never appears at all.
Counts suffer less, because a counter keeps its total between reads. So prefer a running total over a "part made" pulse bit, and take the change between reads.
The right read rate and counter rollover math are in PLC signals for OEE, which also covers which signals to choose. Then turn those signals into states with machine state detection.
Connecting safely
Note the address or IP, and for RTU the baud rate, parity and device ID.
A qualified electrician or controls technician does any cabinet wiring. On RS-485, check each maker's A and B labels, as they differ, and terminate the two ends of the bus.
Use a test tool on a laptop, with read function codes only.
The running bit and the count must match the machine's own screen and a hand count.
Add values slowly, and watch for timeouts or any effect on the machine.
- Only one RTU client per bus. If an HMI already polls the serial bus as its client, you cannot simply add another. A second port, a gateway designed to share the bus, or a read from the HMI side may solve it.
- Lock writes out. Some gateways can restrict a connection to read codes, so use that where available.
- Keep it off open networks. Classic Modbus has no login or encryption, and anyone who can reach the device can send it commands. Keep it on a separated machine network.
- Go gently on old devices. A slow device can time out under fast polling. Start slow, then speed up.
Where a gateway fits
Your OEE software may not poll Modbus devices itself. An IIoT gateway polls the devices, adds time stamps and sends the results on, often using a different protocol.
It can also store data during a network gap, which protects your counts.
Worked example: from registers to OEE inputs
Example: the count register reads 68,000 at the start of a shift and 87,200 at its end. The status bit shows 400 minutes of running out of 480 scheduled, with an ideal rate of 60 parts a minute.
- Parts made = 87,200 - 68,000 = 19,200
- Availability = 400 / 480 = 83.3%
- Performance = 19,200 / (400 x 60) = 80.0%
Quality needs a good or reject count, from another register or a separate source. Then check the full result in the OEE calculator.
Modbus is one route, and not every machine offers it. If yours does not, see how to connect old machines.
Registers are only the raw input to an OEE number. Fabrico is a light MES for OEE: it takes stops, speed and counts live from PLCs or IoT sensors, with add-on AI cameras counting output where a machine has no usable signal, gives OEE per line and shift, and lets operators tag the cause at the line. See how Fabrico connects to machines.
What people ask next
What is the difference between Modbus RTU and Modbus TCP?
RTU runs over a serial line, usually RS-485, and one client talks to devices in turn. TCP runs over Ethernet, normally on port 502, and each client uses a network connection. The register model is the same in both, so the same map applies.
How many registers can I read at once?
The standard allows up to 125 registers in one read with function code 03 or 04, and up to 2,000 bits with 01 or 02. Some devices allow less, so check the manual. Reading neighboring values in one block is faster than many small reads.
Why do my Modbus values look wrong?
The usual causes are an off-by-one address, swapped word order on 32-bit values, a signed or unsigned mix-up, or a missing scale factor. Read one value with a test tool and compare it with the machine's screen. Change one setting at a time.
Can Modbus tell me the cause of a stop?
Only as far as the device reports it. A fault code register can show the machine's alarm, but a human cause such as waiting for material needs an operator tag. See downtime reason codes.
Can polling Modbus affect the machine?
Reads are normally low risk, but a slow device or a busy bus can be affected by heavy polling. Start slowly, watch the machine and raise the rate step by step. Keep write function codes out of the setup entirely.
Fabrico is a light MES for OEE. It takes stops, speed and counts from PLCs or IoT sensors, with add-on AI cameras counting output where a machine has no usable signal, and operators tag the cause at the line.
Related guides: MES vs HMI: Two Screens, Two Different Jobs · MES OPC UA Integration: Setup and Common Traps