Joke Collection Website - Blessing messages - What is ModBus communication protocol?

What is ModBus communication protocol?

ModBus protocol content introduction

The device must have RTU protocol! This is stipulated in the Modbus protocol, and the default mode must be RTU, with ASCII as an option. Therefore, the equipment has RTU protocol, and there are few ASCII protocols. Modbus protocol, you only need to understand the RTU protocol, and ASCII is enough for learning.

The most basic communication unit of the ModBus protocol is the frame. The entire ModBus frame is also called the application data unit (ADU). The ADU also contains the protocol data unit (PDU) for fax transmission. data. The Modbus protocol frame can be seen from the above figure:

Frame structure = Address field function code data error check

Address field:

Occupies one byte, The range is 0-255, of which the valid range is 1-247. Others have special uses. For example, 255 is a broadcast address (the broadcast address is to respond to all addresses. Normally, two devices need to have the same address to query and reply). The address of each terminal device is unique. If you query a certain terminal device, the address of the device must be included. The terminal response will also contain this address, through which the host knows which terminal is communicating with it.

Function code:

Commonly used function codes are 01, 05, 03, 06, and 16. Generally, it occupies one byte. The meaning of the function code is to know what this instruction does. For example, you can query the data of the slave and modify the data, so different function codes correspond to different functions. Commonly used function codes are 03 and 06.

Data:

The main content of communication may be numerical values, reference addresses or limit values. It may be the data required by the terminal to perform a specific function or the data collected when the terminal responds to a query. It has different structures according to different function codes.

Error checking:

In order to ensure that the data is not wrong, add this, and then calculate the previous data to see if the data is consistent. If it is consistent, it means that the data is correct. I'll reply again; if it's different, it means there was a problem with your data during transmission. The data is incorrect, so it was discarded. Sometimes, due to electrical noise and other interference, a set of data may change on the line when being transmitted from one device to another. Error checking can ensure that the host or terminal does not respond to data that has changed during transmission. , which improves the security and efficiency of the system. Error checking uses a 16-bit cyclic redundancy method.