基于Modbus的智能控制器研究与设计

 2023-02-07 08:02

论文总字数:34134字

摘 要

伴随着工业技术的发展,现代工业系统的规模和复杂度越来越大,工业设备也不断更新换代。与此同时,工业设备之间的通信质量要求越来越高,传统的通信方式实时性较差、抗干扰能力弱,从而浪费了大量的资源和成本。现场总线是用于分布式实时控制的工业计算机网络协议的总称。作为一种现代工业设备的连接方式,它取代了传统场设备和控制器之间的点对点通信,所有数据仅在一条数字链路上传输,并且具有简单、可靠性高、经济性好等优点。其中,由莫迪康公司推出的Modbus(串行通信协议)现场总线技术具有良好的兼容性和拓展性,是性能和成本之间的良好折衷方案,如今已成为全球工业领域最流行的通信标准之一。2007年,我国Modbus节点数已经达到一千万。如今,已经有数百万个Modbus设备,并有超过三百个Modbus兼容设备厂商。Modbus协议让不同公司生产的设备连接到同一个工业通信网,实现集中控制与管理。

本文设计的智能控制器系统就是基于Modbus通信协议实现的。该控制器主要使用Modbus RTU(远程终端单元)协议的05号功能码对设备状态进行控制。控制器软件的开发环境为微软公司的Visual C ,发送数据功能由MicrosoftCommunication控件完成,软件界面选择MFC(微软基础类库)进行设计。随后通过虚拟串口软件和Modbus Slave仿真软件对控制器设计进行验证和测试工作。测试结果符合设计要求,实现了对多个设备的集中控制。随后对该控制器的应用前景进行讨论。考虑到目前的工业信息网络在高层都采用高速以太网,仅在底层使用传统的现场总线技术,因此对该控制器的未来发展提出构想,后期若对控制器加入Modbus TCP(传输控制协议)到Modbus RTU协议的报文转换功能,即可组成一个完备的多层多节点工业信息网络,以实现对大范围内多个工业设备的远程无线集中控制,达到真正的工业智能化。

关键词:Modbus;远程终端单元;传输控制协议;微软基础类库

Research and Design of an Intelligent Controller Based on Modbus

Abstract

With the development of industrial technology, the size and complexity of modern industrial systems are increasing, and industrial equipment is constantly being updated. Meanwhile, the demand of communication quality between industrial devices are also accelerating. Because the traditional communication methods have poor real-time performance and weak anti-interference capability, it wastes a lot of resources and costs. Fieldbus is a general term for industrial computer network protocols for distributed real-time control. As a connection method for modern industrial equipment, it replaces the point-to-point communication between traditional field devices and controllers. All data is transmitted on only one digital link, so it has the edge of simplicity, high dependability, and affordable expenditure. Among them, Modbus fieldbus technology introduced by Modicon has good compatibility and expandability. It is a good compromise between performance and cost, and it has grown as the most utilized communication standards of global industry. As early as 2007, the amount of Modbus nodes in China has reached the number of 10 million. Today, there are millions of Modbus devices and more than 300 Modbus device manufacturers. The Modbus protocol allows devices produced by different companies to be connected to the same industrial communication network, thus realizing centralized control and management.

The intelligent controller system designed in this dissertation is realized via the Modbus communication protocol. The controller mainly utilizes No. 05 function code of the Modbus RTU to alter the status of devices. The development environment of the controller software is Microsoft Visual C , the function of sending data is realized via the MicrosoftCommunication tool, and the software interface is designed by MFC (Microsoft Foundation Classes). The controller is then verified and tested via virtual serial port software and Modbus Slave simulation software. The verification outcome satisfies the design requirements and realized the centralized control of multiple devices. The application prospects of the controller are then discussed. Considering that the current industrial information network adopts high-speed Ethernet at the upper level, and it only employs the traditional fieldbus technology at the bottom layer, so the future development of the controller is proposed. If the function of converting messages from Modbus TCP to Modbus RTU is added to the controller, it can then be applied to a multi-layer multi-node industrial information network to realize the remote wireless centralized control of industrial equipment on a large scale, thereby achieving industrial intelligence.

Keywords: Modbus, Modbus RTU, Modbus TCP, MFC

目 录

摘 要 I

Abstract II

第一章 引 言 1

1. 1 课题研究背景 1

1. 2 课题研究目的 1

第二章 现场总线技术 2

2. 1 现场总线概述 2

2. 2 常见的现场总线 3

2. 3 现场总线与工业以太网 5

第三章 Modbus通信协议 6

3. 1 Modbus协议简介 6

3. 2 Modbus的通信机制 7

3. 3 Modbus的协议版本 7

3. 3. 1 Modbus ASCII(美国信息交换标准代码) 7

3. 3. 2 Modbus RTU(远程终端单元) 8

3. 3. 3 Modbus协议版本对比 8

3. 4 Modbus RTU的消息结构 8

3. 4. 1 起始位和结束符 8

3. 4. 2 设备地址 8

3. 4. 3 功能代码 8

3. 4. 4 数据段 9

3. 4. 5 错误校验代码(CRC校验) 9

第四章 软件设计 11

4. 1 开发环境介绍 11

4. 2 设计步骤 11

4. 2. 1 界面设计 11

4. 2. 2 窗口初始化 13

4. 2. 3 打开串口 14

4. 2. 4 串口数据发送 14

4. 2. 5 控制功能的设计 14

4. 2. 6 错误校验:CRC校验 14

4.3 本章小结 15

第五章 控制器软件的仿真验证 16

5. 1 仿真环境介绍 16

5. 2 仿真验证 16

5. 3 本章小结 21

第六章 基于Modbus TCP与Modbus RTU的多层工业通信网讨论 22

6. 1 多层工业通信网络 22

6. 2 Modbus TCP协议介绍 22

6. 3 硬件架构 23

6. 4 软件架构 24

6. 5 预期功能 24

6. 6 报文转换:Modbus TCP与Modbus RTU 24

6. 7 本章小结 25

第七章 结束语 26

致 谢 28

参考文献(References) 30

附 录 32

第一章 引 言

1. 1 课题研究背景

在工业自动化水平的发展进程中,工业系统的规模和复杂度呈现出增长的趋势,工业设备也不断更新换代。新设备的出现在一定程度上大大提高了工业生产效率。自动化系统通常由多个协同工作的自动化设备构成。每个设备在其特定的情形和条件下工作,因此需要进行设备-设备的通信[1]。然而,目前工业设备开始呈现出数量多、分布广的特点。与此同时,由于高压设备的电磁干扰,设备极易受到影响[2]。如何集中控制和管理这些分散的工业设备,已经成为现代工业中急需解决的一大难题[3]。传统的设备管理方式严重依赖于人力,智能化和集中化水平都相对较低,效率低下。因此,传统的工业设备管理方式已经不能应对这一发展趋势。目前的解决方法是建立一个可靠的工业网络来连接不同的子系统,以保证它们之间的高效通信和及时传输[4]

剩余内容已隐藏,请支付后下载全文,论文总字数:34134字

您需要先支付 80元 才能查看全部内容!立即支付

该课题毕业论文、开题报告、外文翻译、程序设计、图纸设计等资料可联系客服协助查找;