Modbus Communication Protocol
Modbus Communication Protocol
1. Modbus RTU
2. Modbus ASCII
3. Modbus TCP
1. Modbus RTU.
Modbus RTU is the most often used Modbus protocol. Modbus RTU is a straightforward serial
protocol that may be sent using standard UART technology. At baud speeds ranging from 1200 bits
per second (baud) to 115200 bits per second, data is delivered in 8-bit bytes, one bit at a time. The
majority of Modbus RTU devices support only 38400 bits per second. A Modbus RTU operates a
Master to slave structure. A Modbus master can connect with up to 254 slaves and exchange data.
Each slave has its own 8-bit device address, often known as a unit number. The address of the slave
for whom the communication is intended is included in the packets transmitted by the master. The
slave must only answer if its address is recognized, and it must do so within a specific amount of
time, or the master will consider it a "no response" error.
A slave is any peripheral device that analyzes data and delivers a response message to the master
using Modbus, such as an I/O transducer, valve, network drive, or other measuring devices. The
communication media for an RTU network is serial, either using RS232, RS422, or RS485.
Figure 1 - Modbus Protocol | Physical connection of RS232, RS485, RS422 using a DB9 cable
2. Modbus ASCII.
Modbus ASCII is an older version of the protocol that contains all of the elements of an RTU packet but
is entirely written in understandable ASCII characters. Modbus ASCII isn't supported, isn't widely used,
and isn't included in the official Modbus protocol specification.
Since its inception, Ethernet IP/TCP has been the most common network protocol. Modbus TCP wraps
Modbus RTU data packets in a TCP packet that can be sent over conventional Ethernet networks. In
TCP, the slave address is not the primary method of addressing. The IP address, for example,
192.168.0.20, is the most essential here. The regular Modbus TCP port is 502, but it is frequently
reconfigured if necessary. Modbus TCP follows the OSI network model.
Modbus shifts from the conventional master to slave relationship to the client to server, where the
master becomes the client and the slave the server. There can be multiple clients and multiple slaves,
which is one of the beauties of Modbus TCP made possible through the peer-to-peer communication
of Ethernet IP. A standard RJ 45 cable (LAN) is used for physically connecting Modbus TCP compliant
devices.
1. Discrete inputs (contacts): Discrete inputs are bit contact registers, and they can only be read.
They can best be described as the contacts in PLC programming.
2. Discrete Outputs (Coils): Coils are one-bit registers used as outputs. They are both read and
write registers.
3. Input registers: Inputs registers are 16-bit registers used for inputs. They are read only.
4. Holding registers: Holding registers are 16-bit registers that are both read and write. They are the
most universal register as they can be used for inputs, outputs, and for holding any kind of data.
The function codes recognized by Modbus are listed in the table below. Although this is not an
exhaustive list of function codes, they are the most used and important ones to familiarize with.
VI. Conclusion.
This is only an introduction to what the Modbus protocol is all about. Numerous resources on the
internet will explain some of these concepts. I encourage the reader to explore some of these
resources. The Modbus protocol is a versatile industrial network protocol that has gained relevance in
the automation society; hence having a good understanding is imperative.