当前位置:网站首页>Analysis and test of ModbusRTU communication protocol
Analysis and test of ModbusRTU communication protocol
2022-07-05 21:36:00 【MrL_ JJ】
List of articles
Concept
Modbus It is a communication protocol widely used in industrial control industry , It has nothing to do with the physical layer , It supports a variety of electrical interfaces , Include RS232、RS485、TCP/IP.Modbus The protocol is the application layer message transmission protocol , Define a message structure that the controller can recognize and use ,, Include ASCII、RTU、TCP Three message types . among Modbus-RTU The most commonly used , This chapter mainly analyzes ModbusRTU agreement .
One 、 Tool preparation
For more intuitive analysis ModbusRTU Communication protocol message format , The following debugging tools are used in this chapter .
VSPD( Full name Configure Virtual Serial Port Driver): When there is no physical serial port , Used to create virtual serial port for computer .
ModbusPoll Software : Mainly used for simulation Modbus Master station or Modbus client , Select one of the serial ports paired with the virtual serial port software , And set the parameters , You can connect to .
ModbusSlave Software : Mainly used for simulation Modbus Slave station or Modbus The server , Select another serial port paired with the virtual serial port software , And set the parameters , You can connect to .
Two 、 Protocol analysis
1. Message format
Modbus The message format of the protocol on the serial link is as follows :
2. register
Modbus The agreement provides for 4 A register , As shown in the following table :
3. Function code
Modbus The protocol adopts function code , Used for reading and writing the above registers , As shown in the following table :
3、 ... and 、 Protocol testing
1. Read holding register


As shown in the figure above : The master station sends messages :01 03 00 00 00 0A C5 CD.
Slave reply message :01 03 14 00 11 00 16 00 21 00 2C 04 83 12 34 33 FF EE FF 11 23 EE 36 DC 4B.
The meaning of the message sent by the master station :0x01: Slave address ,0x03: Function code , 00 : Address start ( high ),0x00: Address start ( low ),0x00: Number ( high ),0A: Number ( low ),2C 04 : check . Read 1 No. slave station holding register , The starting address is 0, The number of 0x0A=10, common 10 Hold the value of the register .( notes : The addresses represented by the message are relative addresses )
The meaning of the message replied by the slave station :01: Slave address ,03: Function code ,0x14: Byte count , 00 11 00 16 00 21 00 2C 04 83 12 34 33 FF EE FF 11 23 EE 36 : Every two bytes correspond to the high and low order of the value of each holding register . DC 4B: check .
2. Read the output coil

As shown in the figure above : The master station sends messages :01 01 00 00 00 0A BC 0D.
Slave reply message :01 01 02 A2 00 C0 9C
The meaning of the message sent by the master station :0x01: Slave address ,0x01: Function code , Read the status value of the output coil , 00 : Address start ( high ),00: Address start ( low ),00: Number ( high ),0A: Number ( low ),2C 04 : check . Read 1 No. slave station holding register , The starting address is 0, The number of 0x0A=10, common 10 The status value of a holding register .
The meaning of the message replied by the slave station :0x01: Slave address ,0x01: Function code , Read the status value of the output coil ,0x02: Byte count ,0xA2 = 1010 0010 Address 0-7 The corresponding state values of the coils .0x00 = 0000 0000 Address 8-9 The status value corresponding to the coil .
边栏推荐
- vant 源码解析 event.ts 事件处理 全局函数 addEventListener详解
- ESP32
- xlrd常见操作
- Add ICO icon to clion MinGW compiled EXE file
- Influence of oscilloscope probe on signal source impedance
- one hundred and twenty-three thousand four hundred and fifty-six
- Kingbasees v8r3 cluster maintenance case -- online addition of standby database management node
- Zhang Lijun: la pénétration de l’incertitude dépend de quatre « invariants»
- 递归查询多级菜单数据
- How to send samples when applying for BS 476-7 display? Is it the same as the display??
猜你喜欢

"Grain mall" -- Summary and induction

xlrd常见操作

基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)

Why can't Chinese software companies produce products? Abandon the Internet after 00; Open source high-performance API gateway component of station B | weekly email exclusive to VIP members of Menon w

Influence of oscilloscope probe on signal source impedance

MySQL InnoDB Architecture Principle

MMAP

R language learning notes

leetcode:1139. The largest square bounded by 1

Teach yourself to train pytorch model to Caffe (I)
随机推荐
Get JS of the previous day (timestamp conversion)
JMeter installation under win7
oracle 控制文件的多路复用
Scenario interview: ten questions and ten answers about distributed locks
Making global exception handling classes with aspect
Two ways to realize video recording based on avfoundation
Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
Ethereum ETH的奖励机制
The primary key is set after the table is created, but auto increment is not set
阿里云有奖体验:用PolarDB-X搭建一个高可用系统
Haas506 2.0 development tutorial - Alibaba cloud OTA - PAC firmware upgrade (only supports versions above 2.2)
DBeaver同时执行多条insert into报错处理
Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
How to send samples when applying for BS 476-7 display? Is it the same as the display??
Robot framework setting variables
Uni app Bluetooth communication
js常用方法封装
EN 438-7 laminated sheet products for building covering decoration - CE certification
股票开户选择哪家证券公司比较好哪家平台更安全
MMAP学习