What is Modbus and what is it used for?

Modbus is an open industrial communication protocol developed by Modicon in 1979. To this day, the Modbus protocol is used in the communication of PLCs, meters, sensors, SCADA systems and many peripheral devices. Due to its ease of implementation and open standard, the Modbus protocol is very popular with installers and integrators of industrial systems.

What is Modbus used for?

The Modbus protocol allows for the quick integration of various slave devices with a master device. It is most commonly used in building automation, factories, the energy sector and IoT systems, mainly for industrial process control. A huge number of devices used in industry are equipped with Modbus communication, which significantly facilitates and speeds up the integration of the entire system. The popularity of the protocol reduces the time and resources needed to commission any Modbus-based system.

How does the Modbus protocol work?

The protocol works on the basis of master-slave communication, where one master device queries (read function) or saves (write function) data from slave devices. The master device can read data from e.g. energy meters or sensors and also write variables to control the settings of various devices, e.g. the temperature and airflow of an air conditioner. Modbus registers are variables that allow the representation of a parameter value in digital form, its storage and reading.

The data frame in the Modbus protocol consists of:

  • The slave device address - in the RTU version, this is an address from 1 to 247, and in the TCP version, it is the IP address of the device
  • Function code - 01, 02, 03, 04, 05, 06, 07, 08, 15, 16, 17
    • 01 - Read Coils
    • 02 - Read Discrete Inputs (most commonly used)
    • 03 - Read Holding Registers (most commonly used)
    • 04 - Read Input Registers
    • 05 - Write Single Coil
    • 06 - Write Single Register (most commonly used)
    • 07 - Read Exception Status
    • 08 - Device diagnostics (Diagnostics)
    • 15 (0F) - Write multiple coils (Write Multiple Coils)
    • 16 (10) - Write multiple registers (Write Multiple Registers)
    • 17 (11) - Read registers with slave ID
  • Data, i.e. the value of a parameter
  • CRC/LRC checksum (only in RTU and ASCII)

The Modbus protocol comes in three varieties. Modbus RTU with RS485 or RS232 communication (fast, binary protocol version), Modbus ASCII also with RS485 and RS232 (slower than Modbus RTU, human-readable) and Modbus TCP based on IP and Ethernet (allows communication via LAN and Internet).

Modbus RTU

Modbus RTU is a popular variant of the Modbus protocol. The fast binary transmission via RS485 or, less commonly, RS232 allows up to 256 devices to be connected to a single bus. The standard bus is limited to a maximum of 32 devices and 1200m in length, but can be extended to a maximum of 256 devices using RS485 repeaters. In one bus, there can only be one master and an unlimited number of slave devices, regardless of the number of devices.

Modbus TCP

Due to the gradual migration of all industrial devices to TCP/IP communication, Modbus TCP is an equally popular protocol variant. Thanks to the use of the IP protocol and the Ethernet layer, it allows communication with Modbus devices in LANs and the Internet. It is characterised by a practical lack of limitations in the number of devices connected to the system, higher transmission bandwidth than Modbus RTU and easier integration with IT systems. Modbus TCP has a client-server structure, allows communication with multiple devices at the same time and lacks CRC/LRC error checking (this is handled by the TCP/IP layer).

Modbus gateways - how to connect RTUs to TCP?

Since higher-level systems such as SCADA or PLCs usually support the Modbus TCP protocol, we usually use Modbus gateways. Modbus gateways allow for easy and fast integration of RS485 devices with devices in an Ethernet network.

Modbus diagnostic tools

The Modbus protocol has become so popular that many diagnostic tools have been developed to facilitate and accelerate system integration. The most popular tools are:

  • Wireshark - for analysing Modbus TCP/IP packets
  • Modscan32 - diagnostics and testing of Modbus RTU and TCP
  • Modbus pool - testing, simulating reading and writing Modbus RTU and TCP registers
  • Simply Modbus (for Modbus RTU and TCP)
  • Cas Modbus Scanner (for Modbus RTU and TCP)
  • QModMaster
  • Radzio Modbus master - free diagnostic tool

Communication devices in Modbus networks

If you need help choosing the right devices for Modbus communication, contact our expert, who will help you choose the right devices such as: