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:zhuanlan.zhihu.com/p/19 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 codeFunction NameOperation TypeApplicable register typesRegister address rangeOperation quantity limitCore Purpose
1readCoil statusreadCoil00001~099991~2000 continuous coilsObtain discrete output states (such as switch values)
2readDiscrete input statereadDiscrete Input10001~199991~2000 continuous discrete inputsObtain discrete input states (such as the Sensor switch)
3Read and hold registerreadHolding Register40001~499991-125 consecutive registersRead readable and writable numerical data (such as set values, cumulative values)
4Read input registerreadInput Register30001~399991-125 consecutive registersRead read-only collected data (such as temperature, pressure)
5Write a single coilWriteCoil00001~099991 coilControl a single switch output (such as relay on/off)
6Write a single hold registerWriteHolding Register40001~499991 registerModify a single set value (such as target temperature, frequency)
15Write multiple coilsWriteCoil00001~099991~1968 continuous coilsBatch control switch output
16Write multiple hold registersWriteHolding Register40001~499991-123 consecutive registersBatch modify multiple setting parameters
图片

评论

此博客中的热门博文

DAQ-IOT Modbus RTU RS485 Split Core Current Transformer CT AC Analog Signal Coil Sensor DC 12V 5A DC Current Transformer Power On or Off Status Monitoring