没有合适的资源?快使用搜索试试~ 我知道了~
ModBus通讯协议教程
5星 · 超过95%的资源 需积分: 10 19 下载量 59 浏览量
2012-04-25
11:44:09
上传
评论
收藏 154KB PDF 举报
温馨提示
试读
45页
最权威,最全面的ModBus通讯协议。学习ModBus不可缺少的教科书。
资源推荐
资源详情
资源评论
MODBUS Application Protocol Specification MODBUS.ORG
modbus.org http://www.modbus.org/ 1/45
8May02
Content
1 Introduction .......................................................................... 2
1.1 Scope of this document .......................................................... 2
1.2 References............................................................................. 2
2 Abbreviations ....................................................................... 3
3 Context................................................................................. 3
4 General description .............................................................. 5
4.1 Protocol description................................................................ 5
4.2 Data Encoding........................................................................ 7
4.3 MODBUS data model ............................................................. 7
4.4 Define MODBUS Transaction ................................................. 9
5 Function Code Categories .................................................. 11
5.1 Public Function Code Definition.............................................12
6 Function codes descripitons................................................ 12
6.1 01 (0x01) Read Coils.............................................................12
6.2 02 (0x02) Read Discrete Inputs..............................................14
6.3 03 (0x03) Read Holding Registers .........................................17
6.4 04 (0x04) Read Input Registers .............................................18
6.5 05 (0x05) Write Single Coil....................................................20
6.6 06 (0x06) Write Single Register .............................................22
6.7 15 (0x0F) Write Multiple Coils................................................25
6.8 16 (0x10) Write Multiple registers ..........................................28
6.9 20 (0x14) Read File Record ...................................................29
6.10 22 (0x16) Mask Write Register ...........................................34
6.11 23 (0x17) Read/Write Multiple registers..............................35
6.12 43 (0x2B) Read Device Identification..................................38
7 MODBUS Exception Responses......................................... 43
modbus.org http://www.modbus.org/ 2/45
8May02
1 Introduction
1.1 Scope of this document
MODBUS is an application layer messaging protocol, positioned at level 7 of the OSI model, that provides client/server communication
between devices connected on different types of buses or networks.
The industry’s serial de facto standard since 1979, Modbus continues to enable millions of automation devices to communicate. Today,
support for the simple and elegant structure of MODBUS continues to grow. The Internet community can access MODBUS at a reserved
system port 502 on the TCP/IP stack.
MODBUS is a request/reply protocol and offers services specified by function codes. MODBUS function codes are elements of
MODBUS request/reply PDUs. The objective of this document is to describe the function codes used within the framework of MODBUS
transactions.
1.2 References
1. RFC 791, Internet Protocol, Sep81 DARPA
2. MODBUS Protocol Reference Guide Rev J, MODICON, June 1996, doc # PI_MBUS_300
MODBUS is an application layer messaging protocol for client/server communication between devices connected on different types of
buses or networks.
It is currently implemented using:
Ÿ TCP/IP over Ethernet.
Ÿ Asynchronous serial transmission over a variety of media (wire : EIA/TIA-232-E, EIA-422, EIA/TIA-485-A; fiber, radio, etc.)
Ÿ MODBUS PLUS, a high speed token passing network.
TCP
Modbus on TCP
MODBUS APPLICATION LAYER
IP
Ethernet
Physical layer
Ethernet II /802.3
EIA/TIA-232 or
EIA/TIA-485
Master / Slave
Physical layer
MODBUS+ / HDLC
Other
Other
Figure 1: MODBUS communication stack
MODBUS Application Protocol Specification MODBUS.ORG
modbus.org http://www.modbus.org/ 3/45
8May02
2 Abbreviations
ADU Application Data Unit
HDLC High level Data Link Control
HMI Human Machine Interface
IETF Internet Engineering Task Force
I/O Input/Output
IP Internet Protocol
MAC Medium Access Control
MB MODBUS Protocol
MBAP MODBUS Application Protocol
PDU Protocol Data Unit
PLC Programmable Logic Controller
TCP Transport Control Protocol
3 Context
The MODBUS protocol allows an easy communication within all types of network architectures.
PLC PLCHMI I/O I/O
I/O
Drive
MODBUS ON TCP/IP
Gateway Gateway Gateway
MODBUS ON MB+
MODBUS ON RS232
MODBUS ON RS485
Device
HMI
PLC
PLC
Drive
I/O
I/O
I/O
I/O
Device
MODBUS COMMUNICATION
Figure 2: Example of MODBUS Network Architecture
Every type of devices (PLC, HMI, Control Panel, Driver, Motion control, I/O Device…) can use MODBUS protocol to initiate a remote
operation.
MODBUS Application Protocol Specification MODBUS.ORG
modbus.org http://www.modbus.org/ 4/45
8May02
The same communication can be done as well on serial line as on an Ethernet TCP/IP networks.
Some gateway allows a communication between several types of buses or network using the MODBUS protocol.
MODBUS Application Protocol Specification MODBUS.ORG
modbus.org http://www.modbus.org/ 5/45
8May02
4 General description
4.1 Protocol description
The MODBUS protocol defined a simple protocol data unit (PDU) independent of the underlying communication layers. The mapping of
MODBUS protocol on specific buses or network can introduce some additional fields on the application data unit (ADU).
Additional
address
Function code
Data
Error check
ADU
PDU
Figure 3: General MODBUS frame
The MODBUS application data unit is built by the client that initiates a MODBUS transaction. The function indicates to the server what
kind of action to perform.
The MODBUS application protocol establishes the format of a request initiated by a client.
The function code field of a MODBUS data unit is coded in one byte. Valid codes are in the range of 1 ... 255 decimal (128 – 255
reserved for exception responses). When a message is sent from a Client to a Server device the function code field tells the server what
kind of action to perform.
Sub-function codes are added to some function codes to define multiple actions.
The data field of messages sent from a client to server devices contains additional information that the server uses to take the action
defined by the function code. This can include items like discrete and register addresses, the quantity of items to be handled, and the
count of actual data bytes in the field.
The data field may be nonexistent (of zero length) in certain kinds request, in this case the server does not require any additional
information. The function code alone specifies the action.
If no error occurs related to the MODBUS function requested in a properly received MODBUS ADU the data field of a response from a
server to a client contains the data requested. If an error related to the MODBUS function requested occurs, the field contains an
exception code that the server application can use to determine the next action to be taken.
For example a client can read the ON / OFF states of a group of discrete outputs or inputs or it can read/write the data contents of a
group of registers.
When the server responds to the client, it uses the function code field to indicate either a normal (error-free) response or that some kind
of error occurred (called an exception response). For a normal response, the server simply echoes the original function code.
Function code
Data Request
Client
Server
Initiate request
Perform the action
Initiate the response
Receive the response
Function code Data Response
剩余44页未读,继续阅读
资源评论
- taxiu2013-09-16英文版 没找到想要的东西
- lovejmm2015-06-05看了一下,学习可以,感谢共享
- hxz452014-04-16一般般啦。。。有点用
- cynric_wu_csdn2014-06-17最近做一个关于Modbus的项目,东西收藏下来看看了,多谢分享
- Chinaguohu2014-10-16值得学习和读读
litong860105
- 粉丝: 3
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Unity XR 手势射击控制脚本(适用于任何可手势识别的设备)
- 机械设计全自动电表(NB和IC卡表)控制和上壳装配线sw16可编辑非常好的设计图纸100%好用.zip
- 基于matlab的EAN-13条形码识别系统GUI界面.zip代码53
- matlab基于bp神经网络交通信号标志识别GUI界面13个标志.zip代码54
- 电子万年历答辩实物展示视频mp4格式
- 基于python实现的程序,包括哈希感知算法cvHash,图像切割cvsplit,固定目标检测cvRec(附文档ppt)等
- 计算0-10000之间所有偶数的和
- multiled.zip
- 基于php实现的哈希算法的人脸检索
- 单片机 电子钟 设计报告/课程设计
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功