
工业自动化
机电工程技术2017年第46卷第03期
DOI: 10.3969/j.issn.10099492.2017.03. 019
基于PC与单片机的数字化打印通信协议研究
陈林林,贾华坡,陈贝贝,杨晨
(郑州科技学院机械工程学院,河南郑州450064)
摘要:针对当前的数字化打印系统,提出采用串行通信的通讯方式实现对打印图像的数字化控制。研究了数据赖的协议模型,议。提出的通信协议程序编写简单,无需增加外部硬件结构,程序调试方便,很大程度上解决了串行通信在通信时可靠性差的
间题,保证了数据传输的正确性。关键词:单片机;赖;串行通信协议
中图分类号:TN919.6
文献标识码:A
文章编号:10099492(2017)03007404
Study of theCommunicationProtocol of theDigitalPrintingBased on
PC and SingleChipMicrocomputer
CHEN Lin-lin, JIA Hua-po, CHEN Beibei, YANG Chen
(College of Mechanical Engineering, Zhengzhou University of Science &Technology, Zhengzhou 450064, China) Abstract: In view of the curent digital printing system, this paper puts forward serial communication methods to realize the digital control of printing image. First, this paper studies the protocol model of data frame and the asynchronous transmission format; And second, this paper proposes a digital printing system which based on PC and single chip microcomputer communication protocols, and the serial port communication protocol of digital printing system was implemented. In this paper, the communication protocol program is simple and can easily be realized, without adding external hardware structure and program debugging is convenient. It not only solves the
poor reliability of the serial communication, but also guarantees the validity of the data transmission. Key words: single chip microcomputer; data frame serial; communication protocol
0引言
随着信息化时代的到来,信息的数字化深人到当今社会的各个方面。数字化打印将许多复杂多变的信息转变为可以度量的数据,再以这些数据建立起适当的数学化模型,通过事行通信将这些数据发送到下位机,下位机依据这些数据进行打印。在打印控制系统中,数字化的打印系统使打印进人了数字化时代,使打印的速度和正确率得到了进一步的提高,而数字化打印系统中的通信协议成为这一现象产生的重要原因之一。
当前存在的通信协议往往考虑了通信的格
式、类型等信息,而在实际的应用对程中,数据的可靠性、正确性等因素非常重要。为满足这些要求,文中以一种基于PC与单片机的数字化打印
收稿日期:20160912 万方数据
74
机的控制系统为背景,以顿的协议为模型,采用异步传送的格式,结合STC89C52单片机的特点,提出了一种比较规范的串行通信协议,实现PC与
下位机传输数据的可靠性和安全性。 1数据帧及通信协议设计思想 1.1数据顿
单片机与PC常用串行通信的异步传送工作方式来传送数据,在异步传送中,每个字的传送用起始位和停止位作为字传送的开始和结束标志,它是以字为单位一个一个地顺序发送和接收的,异步通信的格式如图1所示。
异步通信的内容包含起始位、数据位、奇偶校验位和停止位4部分,每部分的功能如下所示:
起始位:表示数据传输的开始,其功能是通