Analyse des termes liés au protocole Modbus

When you read through the Modbus protocol, you will always encounter some confusing terms, which leads to problems in interpreting the protocol. In this article, we provide relevant explanations for the terms in the Modbus protocol that may cause confusion to you.

1. Function code:

Function codes are used to represent the function of information frames in the modbus protocol. Commonly used function codes are 03, 04, 06, 16, etc. Among them, the function code 03 is used to read the contents of the holding register, and the function code 04 is used to read the contents of the input register ( The difference between input registers and holding registers (see below), the content of function code 06 is to preset a single holding register, and the content of function code 16 is to preset multiple holding registers.

2. Input registers and holding registers:

The function code 04 is to read the input register, while the function code 03 is to read the holding register. Many people always hope to find the difference between the two function codes when they see these two function codes. The holding register and the input What is the difference between registers? Modbus protocol was originally used to solve the communication protocol problem of PLC. It is mainly used to input and output digital signals and analog signals. The so-called input register is derived from the analog signal input, that is, input The register can only be changed from the analog signal input end, and the host cannot change the data of the input register by issuing instructions. The holding register is used to output analog signals. The host can change the register data. That is to say, for As far as the host is concerned, the input register is read-only, while the holding register can be read and written. When the host uses the 06, 16 function code instructions to preset the input register, the device will return an error code of 0x81, that is An attempt was made to write to a read-only register.

3.Data address format in Modbus:

In the Modbus protocol, registers similar to 3xxxx and 4xxxx often appear, which represent the data types supported by the register. We use a list to illustrate, and the Modbus data address format starts from 0. For example, the following register 40009 means a holding register. The register address is 00 08. Similar data address formats are often used in configuration software and PLC systems. .

Mapping addressfunction code usedAddress typeAccess methoddécrire
0XXXX 01,05,15Discrete outputRead and writeEach volume represents a single switch bit
1XXXX 02discrete inputread onlyEach volume represents a single switch bit
2XXXX 03,04,06,16floating point registerread only/read-writeTwo consecutive 16-bit registers represent a floating point number
3XXXX 04input registerread onlyEach register represents a 16-bit unsigned integer
4XXXX 03,06,16holding registerRead and writeEach register represents a 16-bit unsigned integer
5XXXX 03,04,06,16 ASCII charactersRead and writeEach register represents two ASCII codes

4.Modbus RTU/ASCII/TCP:

The Modbus protocol was originally used for communication between programmable logic controllers (PLCs). Due to its openness, it is widely used in field smart instruments. There are multiple variants of the Modbus protocol, the most famous of which are Modbus RTU /Modbus ASCII and Modbus TCP communication protocols. The RTU/ASCII protocol is based on serial port communication, while the TCP protocol is based on Ethernet communication.

5.Modbus error code table:

Modbus has function codes, check codes, abnormal function codes and error codes, among which abnormal function codes and error codes are very easy to confuse. Generally speaking, the abnormal function code refers to the corresponding abnormal function code that occurs when a certain function code is executed. Generally, 0x80 is added to the function code. For example, the exception code that appears in the 03 function code is the 0x83 abnormal function code. The abnormal function code corresponding to function code 16 is 0x90, and the error code indicates the specific situation of the error. For example, the register address does not exist. Whether it is reading or writing, if the register address does not exist, the error code is 02.

X

Veuillez activer JavaScript dans votre navigateur pour remplir ce formulaire.
Saisissez les détails du produit tels que la configuration de l'interface, l'environnement, etc. et d'autres exigences spécifiques pour recevoir un devis précis.

fr_FRFrench
Veuillez activer JavaScript dans votre navigateur pour remplir ce formulaire.
Saisissez les détails du produit tels que la configuration de l'interface, l'environnement, etc. et d'autres exigences spécifiques pour recevoir un devis précis.