Modbus Protocol Terminology Analysis

freeFree Technical Resource

This content is free to read, suitable for basic learning and search traffic.

Modbus Protocol Terminology Analysis缩略图

When reading through the Modbus protocol, we often encounter some easily confused terms, which can lead to problems in interpreting the protocol. In this article, we will provide relevant explanations for the terms that may cause confusion in the Modbus protocol.

Modbus Protocol Terminology Analysis插图

1. Function code:

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

2. Input register and hold register:

The function of the 04 function code is to read the input register, while the function of the 03 function code is to read the hold register. Many people always hope to find the difference between these two function codes when they see them. What is the difference between the hold register and the input register, The Modbus protocol was originally used to solve communication protocol problems in PLCs, mainly for inputting and outputting digital and analog signals. The so-called input register is derived from the analog signal input, that is, the input register can only be changed from the analog signal input terminal to the register, and the host cannot change the data of the input register by issuing instructions. The hold register is used to output analog signals, and the host can change the register data. That is to say, for the host, the input register is read-only, while the hold register can be read and written. When the host uses instructions with 06 or 16 function codes to preset the input register, the device will return an error code of 0x81, which attempts to write the read-only register.

3. Data address format in Modbus:

In the Modbus protocol, registers such as 3xxxx and 4xxxx often appear, indicating the data types supported by the registers. We use a list to illustrate, and the Modbus data address format starts from 0. For example, the following register 40009 represents the hold register, with a register address of 00 08. Similar data address formats are often used in configuration software and PLC systems.

mapped addressFunction code usedAddress TypeAccess methodDescription
0XXXX01,05,15Discrete outputread and writeEach volume represents a single switch position
1XXXX02Discrete Inputread-onlyEach volume represents a single switch position
2XXXX03,04,06,16Floating point registerRead only/read-writeTwo consecutive 16 bit registers represent a floating-point number
3XXXX04input registerread-onlyEach register represents a 16 bit unsigned integer
4XXXX03,06,16holding registerread and writeEach register represents a 16 bit unsigned integer
5XXXX03,04,06,16ASCII 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), and due to its openness, it was widely used in field intelligent instruments. There are multiple variants of the Modbus protocol, among which the most famous isModbus 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, checksum codes, exception function codes, and error codes, among which exception function codes and error codes are easily confused. Generally speaking, an abnormal function code refers to the corresponding abnormal function code that occurs during the execution of a certain function code. It is usually added with 0x80 on the basis of the function code. For example, the abnormal function code that appears in the 03 function code is 0x83, and the abnormal function code that appears in the 16 function code is 0x90. The error code indicates the specific situation where an error occurs, such as the absence of a register address, whether it is read or written. If the register address does not exist, the error code is 02.

Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC verification and device debugging, or submit your requirements for selection and integration advice.

Engineer Membership

Turn this article into actionable debugging resources

After activation, you can use advanced message parsing, resource pack downloads, code examples, engineering cases and priority technical support, suitable for real project delivery.

Unlimited Advanced Tools
Resource & Code Packs
Complete Engineering Case Library
Priority Technical Support

Leave a Reply

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