Modbus
Introduction
Modbus
Introduction
The Modbus is a great way to start for most people who wish to understand how “true” automation and industrial control happens in the major manufacturing centres.
This is a message structure which allows for effective communication between masters and slaves.
Masters are those devices that give out commands and are in general control of the system. Slaves are those devices that execute the given commands and return the results.
Since this is just a messaging structure, this becomes independent of the hardware that is used for communication i.e. it can be used on most hardware devices available.
The communication can be said to work in a Request/Response manner.
Request
Here, the master will send a command / function code to the slave/s to read/write information.
Response
Here, the slave will send the results back to the master after executing the function code given by the master.
Message Structure
The message structure is important in any communication protocol since a common message structure amongst all devices is what allows all devices to communicate seamlessly.
The message structure will usually in the below form: | Slave_ID | Function Code (R/W) | Data | CRC/LRC |
Here, the Slave_ID is used to identify the slave device that the master wishes to communicate with.
The Function Code (R/W) informs the slave whether it must read or write data from the registers.
The Data is the necessary data that would be needed by the slave from the master to properly execute the command.
CRC/LRC is a checksum which allows the slave to validate whether the command received from the master is intact or altered in transmission.
Modbus Formats
The Modbus has 2 different formats of working:
- ASCII Format
- RTU Format
Modbus ASCII Format
The Modbus ASCII Format used ASCII Notation to send the commands over the communication line.
Here, the start of a message is demarcated by a colon : and the end of a message is demarcated by a Carriage Return Line Feed, CRLF .
Modbus RTU Format
The Modbus RTU Format used Hexadecimal Notation to send the commands over the communication line. RTU — Remote Terminal Unit Here, there is no clear start or end of message. It is a continuous stream of binary values over the communication line. The receiver device tends to keep 3.5 times the interval of a characters worth of silence as the start and the stop of a message. [Suppose 1 character takes up a period of 1.5ms. Then, a silence period of 5.25ms is considered to be the start and the stop demarcation of a message signal].
Which Is Better?
Here, it can be clearly said that the RTU Format is better than the ASCII Format in almost all aspects. Let us take an example to understand clearly.
Suppose we wish to send the code value of 4B.
In ASCII Format, we send 00110100 first [4], and then 01000010 next [B].
In RTU Format, we send 01001011 once, which translates to 4B in hexadecimal code.
As we can see, for every byte of data, ASCII Format transmits 2 bytes of data, whereas RTU Format transmits 1 byte of data. Hence, we attribute character density, better throughput and lower bandwidth consumption to the Modbus RTU Format over the Modbus ASCII Format.
Then Why ASCII Format?
The ASCII Format was adopted in the early days of industrial automation, since RTU Format was too unreliable for legacy hardware.
Older hardware devices had too much delay and transmission jitter, which would sometimes slow the transmission of a message between 2 devices. As we know, the RTU Format demarcates the start and the end of a message signal with the interval of silence before and after transmission. If this delay caused enough silence on the channel, then a delayed message may be split into 2 by the receiver.
In such a scenario, a clear demarcation of the start and end of a message transmission is needed. ASCII Format offers this solution, which is why the ASCII Format was important for use in legacy systems.
However, modern industrial automation sees the use of high speed network cables between hardware devices, which makes the use of RTU Format more appealing, since there would be almost no jitter.
Can You Use It?
Yes! Many libraries like PyModbus allow users to simulate how an industrial automation setup works. I have also worked on a similar project, linked below, where I designed a HMI [Human Machine Interface] for a water-tank monitoring system.
Further Reading
Do check out the below link for more detailed information on the topic!
https://www.modbustools.com/modbus.html
That‘s all I have. Thank you for reading all the way to the end!
메타데이터
- post_id
- 28ec2e6f7d24
- slug
- modbus-28ec2e6f7d24
- url
- https://medium.com/@muralirahul6210/modbus-28ec2e6f7d24
- canonical_url
- https://medium.com/@muralirahul6210/modbus-28ec2e6f7d24
- author_url
- https://medium.com/@muralirahul6210
- status
- ok
- fetched_at
- 2026-07-11 22:52:18