当前位置:网站首页>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 .
边栏推荐
- Selenium's method of getting attribute values in DOM
- vant 源码解析之 utils/index.ts 工具函数
- Sorting out the problems encountered in MySQL built by pycharm connecting virtual machines
- 2.2 basic grammar of R language
- 第05章_存储引擎
- Selenium gets the verification code image in DOM
- Emotional analysis of wechat chat records on Valentine's day based on Text Mining
- 張麗俊:穿透不確定性要靠四個“不變”
- Golang(1)|从环境准备到快速上手
- Some things make feelings nowhere to put
猜你喜欢
Clion configures Visual Studio (MSVC) and JOM multi-core compilation
Teach yourself to train pytorch model to Caffe (2)
EasyExcel的读写操作
Realize the function of verifying whether the user has completed login when browsing the page
R语言【数据管理】
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
秋招将临 如何准备算法面试、回答算法面试题
Opérations de lecture et d'écriture pour easyexcel
事项研发工作流全面优化|Erda 2.2 版本如“七”而至
2.2 basic grammar of R language
随机推荐
Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
Exercise 1 simple training of R language drawing
基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
Learning notes of statistical learning methods -- Chapter 1 Introduction to statistical learning methods
regular expression
int GetMonth( ) const throw( ); What does throw () mean?
postgres 建立连接并删除记录
张丽俊:穿透不确定性要靠四个“不变”
Emotional analysis of wechat chat records on Valentine's day based on Text Mining
Opérations de lecture et d'écriture pour easyexcel
oracle 控制文件的多路复用
PVC plastic sheets BS 476-6 determination of flame propagation properties
深信服X计划-网络协议基础 DNS
EasyExcel的读写操作
vant 源码解析 之深层 合并对象 深拷贝
js常用方法封装
123456
leetcode:1139. The largest square bounded by 1
终端安全能力验证环境搭建和渗透测试记录
办公遇到的问题--