Modbus

is a protocol that enables devices to communicate within a building.

How It Works

Modbus—not to be confused with M-Bus, a similarly named protocol—has been around since 1979 and remains a very popular means of communication between devices in a building.

There is always one client (formerly: master) connected to a maximum of 247 servers (formerly: slaves) via a serial line or by IP address.

Registers

A Modbus server has registers, which can be thought of as mailboxes that contain information.

Holding registers are registers to which the client can write. They often contain the device’s settings or parameters.

The client can read the input registers . These usually contain measurements or other information about the system.

All registers contain 16-bit values. These can be 16-bit signed or unsigned integers, but it is also possible, for example, for two registers to combine to form a 32-bit integer or a 32-bit float. The interpretation of the bits must be correctly implemented on the client side to ensure accurate reading.

TCP/IP or RTU

Modbus can communicate over Ethernet (TCP/IP) or a serial line using RTU (RS-485, RS-232).

We will always recommend Ethernet, both because of its reliability and because, in addition to Modbus, it can be used to transmit other types of information, such as a device’s web interface.

Serial cabling can be chosen to reduce installation costs or when a device is located at a very great distance from the rest and a network connection is not possible. We often find that the savings on installation are offset by additional labor hours required for debugging. This is because a serial bus can be prone to noise, interference, interactions between devices, and more difficult configuration, among other issues; as a result, the costs can sometimes end up being much higher than those of setting up a network connection.

Modbus RTU

The cabling must include a 120-ohm resistor after the last device on the bus. Unlike M-Bus, with Modbus you must pay close attention to the – and + terminals (also referred to as A and B in Modbus terminology)

The following settings must be the same for the client and all servers on the bus:

  • Baud rate (usually 9600 bits/s)
  • Stop bits (usually 1 bit)
  • Parity (usually None)

Each device must also have a unique slave ID , which must then be correctly selected by the client.

Modbus TCP

Modbus TCP is much simpler than RTU. All you have to do is select the correct IP address. The slave ID is therefore often left at 1, since there is usually only one server per IP address.

The default port used for communication is 502, so a firewall must allow traffic on this port.

A Modbus server has registers, which can be thought of as mailboxes containing information.

The holding registers are registers that the client can write to. These often contain the device’s settings or parameters.

The client can read from the input registers . These usually contain measurements or other information about the system.

All registers contain 16-bit values. These can be 16-bit signed or unsigned integers, but it is also possible, for example, that two registers together form a 32-bit integer or a 32-bit float. The interpretation of the bits must be correctly implemented on the client side to ensure accurate reading.