Is it a standard feature in the Modbus standard Protocol to perform read and write operations on a single register or multiple registers? Or is it a custom feature?
As a professional provider of IoT data acquisition solutions and an expert in industrial IoT data acquisition, the editor of Shanghai Data Acquisition IOT Technology Co., Ltd, (daq-iot) hereby presents the following introduction, and sincerely welcomes discussions and exchanges. Supported Communication Interfaces: CAN, RS485, Mbus, 4–20mA, Profibus, CC-Link, HART, digital I/O, etc. Industrial Protocols: Modbus RTU/TCP, HJ212, IEC104, DLT645, DLMS, IEC61850, MQTT, etc. Mail:export@daq-iot.com
As a professional provider of IoT, Data Acquisition, solution, and an expert (professional account) in the industrial Data Acquisition field, Daq IoT, the editor of IoT, would like to introduce the following content and sincerely welcome everyone to discuss and exchange ideas.
As a professional internet of things data acquisition solutions provider, industrial data acquisition experts (professional households), digital internet of things editor daq - iot here to do the following introduction, and sincerely welcome everyone to discuss and exchange. Author: Wireless Sensor Link:https://zhuanlan.zhihu.com/p/1984577892831757501 Source: Zhihu Copyright belongs to the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.

——————————————————————————————————————————————
in Modbus standard ProtocolThe operation of reading and writing single or multiple registers is a standard function, not a custom function, and these functions are defined by Modbus Protocolfunction codeTo identify and apply to different types of registers.
1. Read register operation (standard function)
Modbus defines specialized function codes for reading single or multiple registers, with core types divided into two categories:
holding register(Holding Register): readable and writable, with an address range typically ranging from 40001 to 49999
Read single/multiple holding registers: Function code 03 (Read Holding registers)
This is the most commonly used function code, which supports reading 1-125 consecutive hold registers or only reading one (i.e. a single register), fully compliant with the standard.
input register(Input Register): Read only, used to store input data such as Sensor collection, address range 30001~39999
Read single/multiple input registers: Function code 04 (Read Input Register)
It also supports reading 1-125 consecutive input registers, and a single read is also standard usage.
2. Write register operation (standard function)
The standard function code for writing operations also distinguishes between single and multiple registers:
Function code function description applicable scenarios
06 (Preset Single Register) Write a single hold register to modify the value of only one hold register
Write multiple hold registers to batch modify the values of 1-123 consecutive hold registers
3. Definition of custom functions
Only operations that meet the following conditions are considered custom functions:
Implement read-write logic using custom function code segments (function codes 65-72, 100-110) reserved by Modbus Protocol;
Read and write custom storage areas outside of standard register types (such as hold registers and input registers);
Tampering with the communication logic of standard function codes (such as implementing write operations using function code 03).
summary
Read and write single/multiple hold registers and input registers → belong to Modbus standard functions, corresponding to function codes 03, 04, 06, and 16.
Read and write operations for non-standard function codes and non-standard storage areas → belong to custom functions.
| function code | Function Name | Operation Type | Applicable register types | Register address range | Operation quantity limit | Core Purpose |
| 1 | readCoil status | read | Coil | 00001~09999 | 1~2000 continuous coils | Obtain discrete output states (such as switch values) |
| 2 | readDiscrete input state | read | Discrete Input | 10001~19999 | 1~2000 continuous discrete inputs | Obtain discrete input states (such as the Sensor switch) |
| 3 | Read and hold register | read | Holding Register | 40001~49999 | 1-125 consecutive registers | Read readable and writable numerical data (such as set values, cumulative values) |
| 4 | Read input register | read | Input Register | 30001~39999 | 1-125 consecutive registers | Read read-only collected data (such as temperature, pressure) |
| 5 | Write a single coil | Write | Coil | 00001~09999 | 1 coil | Control a single switch output (such as relay on/off) |
| 6 | Write a single hold register | Write | Holding Register | 40001~49999 | 1 register | Modify a single set value (such as target temperature, frequency) |
| 15 | Write multiple coils | Write | Coil | 00001~09999 | 1~1968 continuous coils | Batch control switch output |
| 16 | Write multiple hold registers | Write | Holding Register | 40001~49999 | 1-123 consecutive registers | Batch modify multiple setting parameters |

评论
发表评论