Modbus and RS-485
Modbus connects a huge amount of industrial equipment, and most of its problems sit in the gaps between hardware, firmware and software. We work on all three.
ModbusAt a glance
- Protocols
- Modbus RTU and Modbus TCP
- Physical
- Two-wire RS-485 and Ethernet
- Roles
- Master and slave, client and server, gateways
- Functions
- Coils, inputs and registers: 01 to 06, 15 and 16
- Data
- 16 and 32-bit integers and floats, any word order
Hardware
RS-485 interfaces designed for real cable runs: modern transceivers with true fail-safe receivers, termination fitted where the bus ends, surge protection sized for the line, and a protected ground so a surge on the cable doesn't reach the processor.
We also build our own listening hardware to capture bus traffic without disturbing it.
Firmware
Masters that poll sensors, slaves that publish values for a PLC to read, and boards that do both on two separate buses at once.
Gateways that bring an RS-485 device onto Ethernet as Modbus TCP, with a settings page in the browser.
Software
Windows tools that scan a bus for devices, read and write registers, and log and chart values. C# libraries that let your own software talk to a device without handling raw registers.
Register maps
| Register | Name | Type | Units | Access |
|---|---|---|---|---|
| 30001–30002 | Flow rate | float32 | L/min | Read |
| 30003–30004 | Temperature | float32 | °C | Read |
| 30005 | Status flags | uint16 | bit field | Read |
| 40001 | Device address | uint16 | 1 to 247 | Read and write |
| 40002 | Baud rate | uint16 | 9600 to 115200 | Read and write |
| 40003–40004 | Alarm setpoint | float32 | °C | Read and write |
Word order
A 32-bit value needs two 16-bit registers, and devices disagree about which goes first. Take 22.5 as a float, which is 41B4 0000 in hex.
Sent high word first
Read correctly: 22.5
Sent low word first
Read the wrong way round: 2.36 × 10⁻⁴¹
The sensor is fine and the cable is fine, but the screen shows zero. We check word order, scaling and signed values on every register before the data goes anywhere.
When a device won't answer
It is usually one of five things, and we check them in this order:
- Wrong address
- Wrong baud rate or parity
- A and B swapped
- Missing termination or bias
- Registers numbered from 0 on one side and from 1 on the other
If it is none of those, we capture the bus and look at the timing.
Got a Modbus problem?
Send the device manual, the register map and a description of what you see. Photos of the wiring help too.