登录

  • 登录
  • 忘记密码?点击找回

注册

  • 获取手机验证码 60
  • 注册

找回密码

  • 获取手机验证码60
  • 找回
毕业论文网 > 毕业论文 > 电子信息类 > 通信工程 > 正文

基于51单片机串行通信的ModBus协议实现毕业论文

 2021-03-15 08:03  

摘 要

Modbus一种工业级的通信协议。该协议由施耐德电气公司在20世纪70年代提出,一经提出便在工业领域得到了很好的应用,直至现在,该协议仍然扮演着其特有的作用,熠熠生辉。Modbus协议主要是用于计算机和可编程控制器件进行通信,其间的媒介可以是公用线路抑或局部线路,该系统由软件和硬件一同组成。直至今天,Modbus协议的应用范围有增无减,工商业、经济、工程、建筑、制造业等诸多领域都可以看得到Modbus协议的影子。现场总线的种类非常繁杂,Modbus现场总线是其中重要的一种,相比于其它而言,Modbus工业网有着其不可替代的优势和特点:1)共享,用户可以免费使用而不用缴纳相关费用;2)可兼容,支持性强,兼容众多电气化接口;3)简单易操作;4)安全性高稳定性强,能够报障信息的安全和稳定。因为Modbus协议的众多鲜明优点,因此其应用非常广泛,在诸多行业都有广泛应用,也得到很多用户的好评。目前该协议主要运用于电子控制器上。除此之外,Modbus协议还具备监控功能,即便是不同厂商,只要其采用了Modbus协议,都可以进行统一的监控,大大提高了整个平台的可运营性。

本次设计基于51单片机系统和Modbus协议,具体利用PC机和KST51单片机开发板来实现,其中利用自己的DELL笔记本作为上位机,KST51开发板作为下位机,采用了USB转RS485接口进行通信,编写基于串口通信和ModBus协议的程序,结果用LCD显示,实现本次设计的任务要求和目标。

关键词:RS485;51单片机;Modbus协议;串行通信

Abstract

Modbus An industrial-grade communication protocol. The agreement was made by Schneider Electric in the 1970s and has been well applied in the industrial sector until now, and the agreement is still playing its unique role and shining. Modbus protocol is mainly used for computer and programmable control devices to communicate, during which the medium can be a public line or a local line, the system consists of software and hardware together. Until today, the scope of application of Modbus protocol continues unabated, industry and commerce, economy, engineering, construction, manufacturing and many other areas can see the shadow of Modbus protocol. The field bus is very complicated, Modbus field bus is one of the important one, compared to other terms, Modbus Industrial Network has its irreplaceable advantages and features: 1) sharing, the user can be free to use without paying the relevant costs; 2) compatible, supportive, compatible with a large number of electrification interface; 3) easy to operate; 4) high stability and stability, to report information security and stability. Because of the many distinctive advantages of the Modbus protocol, so its application is very extensive, in many industries have a wide range of applications, but also get a lot of users praise. At present the agreement is mainly used in electronic controller. In addition, the Modbus protocol also has monitoring capabilities, even if different manufacturers, as long as it uses the Modbus protocol, can be unified monitoring, greatly improving the operational capacity of the entire platform.

This design is based on 51 SCM system and Modbus protocol, the specific use of PC and KST51 microcontroller development board to achieve, which use their own DELL notebook as the host computer, KST51 development board as the next bit machine, using the USB to RS485 interface for communication, Based on the serial communication and ModBus protocol procedures, the results with LCD display, to achieve the design of the task requirements and objectives.

Key words:RS485;51 Single Chip Microcomputer; Modbus protocol; Serial Communication

目 录

第1章 绪论 1

1.1 研究目的及意义 1

1.2 国内外研究现状 1

1.3 本文内容及安排 2

第2章 Modbus协议 3

2.1 Modbus协议的串口 3

2.2 Modbus协议简介 4

2.3 Modbus协议的串行通信栈 5

2.4 Modbus协议下的串行传输模式 6

2.4.1 RTU传输模式 7

2.4.2 ASCII传输模式 8

2.5 Modbus协议下的CRC校验 9

第3章 Modbus协议通信过程的设计及实现 10

3.1 Modbus协议的硬件设计 10

3.1.1 硬件部分的结构 10

3.1.2 USB转RS485接口 10

3.1.3 单片机开发板 11

3.2 Modbus协议的软件设计 13

3.2.1 软件流程框图 13

3.2.2 Modbus协议的CRC校验 14

3.2.3 通信结果的LCD显示 15

3.2.4 main主函数 16

3.3 Modbus协议通信的实现 18

第4章 总结与展望 20

4.1 总结 20

4.2 展望 20

参考文献 21

致 谢 22

第1章 绪论

1.1 研究目的及意义

随着国民经济的深入发展,居民消费水平的提高,与之相干的工商业科技也越来越发达,人们对科技的要求特别是信息的需要也随之成指数型增长,电子产品也越来越小型化、轻薄化、快速化,原始的并口通信技术成为制约信息传输速度进一步提高的短板。在通讯范畴内,主要有串行接口和并行接口两种,其区别在于传输数据和信息的方式,具体表现为:并行通信可同时传输多位数据,相比而言,串行通信则只能采用一位一位地方式,但相比并行通信而言,串行通信传输距离远,抗干扰能力强,因此在工业生产领域多用串行通信。尤其是在工业领域,工业现场复杂,各种电磁干扰比较多,对接口技术的要求就更为严苛。在工业生产,机械制造,仪器仪表等诸多领域,相比RS232接口而言,更常用RS485接口来实现控制及数据通信。

在当今工业制造与生产中,因为监控目标,监控设备的差别,以及监控与控制对即时性要求的区别,地域、空间分散性等不同标准的存在,实现不同设备信息有效通信和交换就显得越来越困难和复杂,由此不可避免地就产生了“信息孤岛”。随着信息技术在工业领域的深入应用,Modbus协议也应运而生,Modbus是一种协议平台,由于它具备操作简单、对外开放、产品共享的诸多特性,使得控制器与其余设备之间,控制器与控制器之间大多基于该协议完成数据通讯。Modbus协议目前也已成为一种工业标准,在诸多方面得以应用,从而达到打破不同厂商设施壁垒,连接成工业网络,进行统一集中监控的目标。

1.2 国内外研究现状

Modbus协议是由Modicon公司在1979年提出的,从初步研发创作至运用于现实工业制造与生产,历经更新和完善。20世纪80年代末期,为满足广大用户日益增长的需求,该公司基于前期的协议又提出了Modbus plus。Modbus Plus是在Modbus的原理上建立的,它所使用的网络结构为对等网络、即插即用,该协议能够为广大用户提供更快的传输速率。多年的实践证实,Modbus Plus在工业生产领域仍然起着举足轻重的作用。1997年,为进一步提高传输速率,施耐德电气公司进一步提出了Modbus TCP协议,该协议是首个被应用于工业自动化范围的以太网协议。截止2007年,Modbus的安装节点已超过1000万个,涉及地区全球各地,可见其普及的程度,已成为实际上的工业标准[1]

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

企业微信

Copyright © 2010-2022 毕业论文网 站点地图