RS232与CAN总线协议转换器的设计
摘要:目前一种运用于生产的现场的现场总线一现场总线(Field bus),在现场设备和控制之间可以执行双向及串行及多节点的数字通信技术。但现场总线会在协议标准上存在的差异给实践带来一定影响,也影响了总线之间的开放性和互操作性。在这样的情况下,就要用接口转换器使不同的总线之间互联。因此,论文针对传统的RS-232网络与CAN总线网络之间的互联设计出RS-232/CAN与CAN接口转换器。
本文说明了CAN总线和RS-232与CAN接口转换器之间的设计和实现。主要从硬件设计和软件设计两个方面进行了论述。
首先,对现场总线技术及其要做到的工作进行了简要的介绍,并介绍了CAN总线技术的基本原理以及相关概念。
在硬件设计中,采用AT89C51作为微处理器,CAN总线通信接口采用Philips
公司的芯片P82C250作为CAN收发器。通过外围的电路设计完成RS-232电平和CAN总线电平信号的改变,对CAN控制器和CAN收发器P82C250的互联。软件设计包括:单片机程序的编写,上位机CAN通讯测试软件的编写。
关键字:现场总线,RS-232,协议转换,单片机
The design of the RS232 and CAN bus protocol converters
Abstract: At present a kind of applied to the scene of the production of fieldbus a fieldbus (Field bus), between the Field devices and control can perform bidirectional and serial and multi-node digital communication technology. But the fieldbus exist differences in protocol standards bring certain influence to practice, also affects the bus between the openness and interoperability. In this case, you should use interface converter connected between the different bus. Paper, therefore, in view of the traditional RS – 232 network and CAN bus network interconnection between the design of the RS – 232 / CAN and the CAN interface converter.
This paper illustrates the CAN bus and RS – 232 and CAN interface converter between the design and implementation. Mainly from two aspects of hardware design and software design are discussed.
First of all, the work of field bus technology and its to do a brief introduction, and introduces the basic principle of CAN bus technology and related concepts.
In the hardware design, AT89C51 as the microprocessor, CAN bus communication interface with Philips
The company’s P82C250 as the CAN transceiver chip. Through the peripheral circuit design to complete the RS – 232 level and CAN bus level signal changes, to the CAN controller and CAN transceiver P82C250 interconnection. Software design includes: single chip microcomputer, write superordination machine test software CAN write.
Key words: fieldbus, the RS – 232, protocol conversion, single-chip microcomputer
目 录
第一章 绪论…………………………………………………………………………………………………. 1
1.1现场总线的概述………………………………………………………………………………… 1
1.2现场总线的特点………………………………………………………………………………… 1
1.3现场总线的现状与意义……………………………………………………………………… 2
1.4小结………………………………………………………………………………………………….. 3
第2章 CAN总线及串口概述…………………………………………………………………………. 4
2.1 CAN总线的特点………………………………………………………………………………… 4
2.2 CAN的报文传送及帧结构………………………………………………………………….. 5
2.2.1 报文传送…………………………………………………………………………………. 5
2.2.2 CAN帧结构………………………………………………………………………………. 5
2.3串口协议标准及应用概述………………………………………………………………….. 7
2.4 RS-232概述……………………………………………………………………………………… 8
2.5串口数据收发原理…………………………………………………………………………….. 8
第三章 接口转换器的硬件设计…………………………………………………………………… 10
3.1接口转换器硬件设计的系统架构……………………………………………………… 10
3.2 CAN控制器的组成……………………………………………………………………………. 10
3.3 核心控制模块设计………………………………………………………………………….. 11
3.4 CAN总线接口模块………………………………………………………………………….. 13
3.4.1 CAN总线控制器SJA1000………………………………………………………. 14
3.4.2 SJA1000接口电路设计…………………………………………………………. 15
3.4.3 CAN收发器PCA82C250电路设计…………………………………………….. 16
3.4.4 CAN接口电路设计………………………………………………………………….. 17
3.5 RS-232接口电路设计……………………………………………………………………… 17
3.6 系统供电电路设计………………………………………………………………………….. 18
第四章 软件设计………………………………………………………………………………………… 19
4.1 软件组成及架构……………………………………………………………………………… 19
4.2 主程序模块…………………………………………………………………………………….. 19
4.3 CAN总线通信模块……………………………………………………………………………. 22
4.4 RS-232接口模块…………………………………………………………………………….. 23
4.5 人机交互程序………………………………………………………………………………… 24
第五章 总结……………………………………………………………………………………………….. 25
5.1 论文总结………………………………………………………………………………………… 25
5.2 后续工作展望…………………………………………………………………………………. 25
致谢……………………………………………………………………………………………………………. 26
参考文献…………………………………………………………………………………………………….. 27