当前位置:网站首页>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详解
- Detailed explanation of memset() function usage
- Chapter 05_ Storage engine
- JMeter installation under win7
- 1.2 download and installation of the help software rstudio
- leetcode:1755. Sum of subsequences closest to the target value
- regular expression
- Kingbasees v8r3 data security case - audit record clearing case
- sql常用语法记录
- 2.2.5 basic sentences of R language drawing
猜你喜欢
Teach yourself to train pytorch model to Caffe (I)
基于vertx-web-sstore-redis的改造实现vertx http应用的分布式session
Deployment of Jenkins under win7
R language learning notes
递归查询多级菜单数据
Simple interest mode - evil Chinese style
DBeaver同时执行多条insert into报错处理
R语言【数据管理】
ArcGIS\QGIS无插件加载(无偏移)MapBox高清影像图
Zhang Lijun: la pénétration de l’incertitude dépend de quatre « invariants»
随机推荐
leetcode:1755. Sum of subsequences closest to the target value
基于vertx-web-sstore-redis的改造实现vertx http应用的分布式session
Sorting out the problems encountered in MySQL built by pycharm connecting virtual machines
Kingbasees v8r3 data security case - audit record clearing case
How to prepare for the algorithm interview and answer the algorithm interview questions
使用Aspect制作全局异常处理类
Golang (1) | from environmental preparation to quick start
Test of incombustibility of cement adhesives BS 476-4
vant 源码解析 之深层 合并对象 深拷贝
Clion configures Visual Studio (MSVC) and JOM multi-core compilation
阿里云有奖体验:用PolarDB-X搭建一个高可用系统
Selenium gets the verification code image in DOM
Learning robots have no way to start? Let me show you the current hot research directions of robots
Some things make feelings nowhere to put
R language learning notes
uni-app 蓝牙通信
Sequence alignment
Gcc9.5 offline installation
Introduction to TS, constructor and its this, inheritance, abstract class and interface
Which securities company is better and which platform is safer for stock account opening