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

Example register map. We write one like this for every device we build: address, type, units and access in a single table.
RegisterNameTypeUnitsAccess
30001–30002Flow ratefloat32L/minRead
30003–30004Temperaturefloat32°CRead
30005Status flagsuint16bit fieldRead
40001Device addressuint161 to 247Read and write
40002Baud rateuint169600 to 115200Read and write
40003–40004Alarm setpointfloat32°CRead 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

41B40000

Read correctly: 22.5

Sent low word first

000041B4

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:

  1. Wrong address
  2. Wrong baud rate or parity
  3. A and B swapped
  4. Missing termination or bias
  5. 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.