What is meant by Modbus protocol?

Modbus Protocol is a serial communication protocol, which was published by Modicon company (now Schneider Electric) in 1979 for the use of programmable logic controller (PLC) communication. Modbus has become the industry standard (De facto) of communication protocols in the industrial field and is now a common connection method between industrial electronic devices.

What is Modbus Protocol?

Modbus Protocol Features

The main reasons why Modbus is more widely used than other communication protocols are:

  • Published publicly and without copyright requirements
  • Easy to deploy and maintain
  • For suppliers, there are not many restrictions on modifying mobile local bits or bytes

Modbus allows multiple (approximately 240) devices to be connected on the same network to communicate. For example, a device that measures temperature and humidity and sends the results to a computer. In the data acquisition and monitoring control system (SCADA), Modbus is usually used to connect the monitoring computer and the remote terminal control system (RTU).

How does a Modbus work?

Modbus is a master/slave communication mode with a single master station. There can only be one master station on the Modbus network, and the master station has no address on the Modbus network. The address range of the slave station is 0-247, where 0 is the broadcast address. The actual address range of the slave station is 1-247. Modbus communication standard protocol can be transmitted through various transmission methods, such as RS232C, RS485, optical fiber, radio, etc.

Modbus has two serial transmission modes, ASCII and RTU. They define different ways of how data is packaged and decoded. Devices that support Modbus protocol generally support RTU format. Both communication parties must support one of the above modes at the same time.

The above is the official definition, let’s use ordinary words to explain:

This is actually the communication protocol, and any protocol is similar. There are only two communication formats and communication specifications.

If you want, you can also define a communication specification yourself. Use PLC or VB language to process according to this specification defined by yourself. If the reliability exceeds Modbus, then your communication specification is the most popular!

The Modbus protocol is only a kind of communication protocol, there is nothing mysterious, the communication protocol includes two aspects:

  1. Communication format, namely: baud rate, inspection method, data bit, stop bit.

Baud rate: The number of digits transmitted in one second is the communication rate; for example, the baud rate is 9600, that is, 9600 digits can be transmitted in one second. For the concept of bits, see the introduction of data bits below.

Check mode: odd check or even check or no check, the purpose is to judge whether there is an error in the transmission process! It is only used to judge whether there is an error in the transmission of a character (such as 8 bits or 7 bits forming a character). But it cannot fully determine whether the transmission is wrong. For example, even parity, when the test sends eight “11111111”. If it reaches the receiver, it becomes “10111101” due to interference, and the number of “1” is still an even number, and the receiver cannot determine that the transmitted character has been an error!

Data bit: Transmit a character consists of several bits. The basic unit of the computer is “bit”. Its value is not “0” or “1”. Another example is the transmission of A. When the communication format is defined, it is defined as 8 bits. The data may be: 00001010;

Stop bit: There are several stop bits for transmitting a character. It takes days to judge whether the transmission of a character is over, so as to start receiving the next character.

The function of the communication format is to standardize the transmission format of the sender and the receiver. If the communication formats of the two parties are different, the receiver cannot correctly determine what the sender is sending.

For example, if the baud rate set by the receiver is 10 (only 10 bits per second), and the baud rate of the sender is 20 (20 bits per second), then the sender will send 20 bits per second. It is impossible for the receiver to receive all characters, only 10 characters can be received, causing communication errors.

Verification method: If the verification methods of the two parties are not the same, there is no uniform standard to determine whether the transmission has errors.

Data bit, the 7 bits set by the receiver, that is, it is considered to be a character when it receives 7 bits, but the actual sender sets 8 bits, so the character recognized by the receiver is different from the character sent by the sender Up.

The communication format set by the two parties participating in the communication must be the same! !

  1. Communication standards (this term is defined by myself, cannot be quoted, it will be laughed at).

The communication format only ensures that the receiver correctly receives every character transmitted by the sender (actually, as mentioned above, the inspection method cannot guarantee complete correctness. The checksum calculation in the communication specification must be used to verify the overall correctness. The following Will continue to explain). So is the use of the entire string of characters received dependent on the communication standard?

The MODBUS communication specification is very simple!

Let me talk about the ASCII method first:

The specification definition when sending in ASCII mode is as follows:

Start character + device address + function code + data + check + end character


When you receive a string of characters, you must always know where the string of characters starts. This is the function of the start character. The receiver does not matter how many characters it has received before. When the start character is received, the previous characters are ignored, and the subsequent characters are analyzed from the start character!

The start character of MODBUS ASCII mode is a colon “:”

2\Equipment address:

As mentioned earlier, MODBUS is a master/slave communication mode with a single master station, and more than ten slave stations can be connected to one master station. Everyone is hanging on the same line. If there is no device address, I don’t know which slave station it is sent to. If everyone responds, the signal on this line will be messed up, and the master station doesn’t know what it is receiving.

Therefore, suppose such a device address is for the slave station. As long as this slave answers, the others shut up! “No. Two, please answer, and the others will stop talking.”

I often ask certain product promoters, “What is the communication protocol of your device”. He replied: “232” or “485”. Today you read the above-mentioned vernacular, please stop answering like this.

The Modbus communication standard protocol can be transmitted through various transmission methods, such as RS232C, RS485, optical fiber, radio, and so on.

“232” or “485” is just a line transmission method, and has nothing to do with the protocol! The 232 transmission has poor anti-interference, and the 485 transmission has relatively strong anti-interference.

As a standard protocol, MODBUS is used in various PLCs, controllers, and meters. In these instrument or controller applications, the communication address of the component is definitely different; the meaning of each part of each command code may also be different;

However, it will definitely comply with the MODBUS protocol specification. That is, the composition of each command code must conform to the MODBUS specification! Not much, but a lot!

Let’s talk about a specific read/write example for a certain controller that supports the MODBUS protocol.

1\ Read the fifteen register values ​​of a certain controller, the string sent is: (ASCII mode)

“: 01031000000FDD”+ Chr(13)+Chr(10)
Start character “:” + station number (01) + read command (03) + start register communication address (1000) + number of words (15; converted to hexadecimal 000F) + checksum (DD) + end character

The number of characters returned by the controller is 71
Start character “:” + station number (01) + read command (03) + number of words (0F) + 60 data characters (a register is 4, fifteen in total) + checksum (DD) + end character (Two)

2\ Write values ​​to two registers of a certain controller respectively, and the string sent is: (ASCII mode)

“: 01101000000204” + written value (8 characters) + checksum + Chr(13)+Chr(10)

Start character “:” + station number (01) + write command (10) + start register communication address (1000) + number of words (2; converted to hexadecimal 0002) + number of bytes (04) + check Sum (because the written value is changed, it needs to be calculated to get the checksum) + terminator

The number of characters returned by the controller is 17
Start character “:” + station number (01) + write command (10) + start register communication address (1000) + number of words (02) + error code (2) + checksum (DD) + end character ( Two)

*Error code, what is when the communication is correct, what is when the communication is wrong, the specific controller will explain

When reading a certain value of other meters, refer to the above-mentioned reading specification. That is to change the starting register communication address, the number of words, checksum (checksum is automatically calculated by the programming block.)
It is easier to read the same detection value of multiple instruments, just change the station number.

Request a Quote

Please provide your measurement parameters or details. Sino-Instrument support customer customization and OEM

Leave a Reply

Your email address will not be published. Required fields are marked *