本文主要为广大网友提供“单片机与PC机串行通信”,希望对需要单片机与PC机串行通信网友有所帮助,学习一下!
论文编号:DQ323 论文字数:15402,页数:32
摘 要
随着计算机系统的普及与外围设备技术的发展,计算机与外围设备之间的通信就显得越来越重要了。其中,计算机与单片机之间串口通信的应用也越来越多,由于串行通信所用的传输线少,可靠性高,并且可以借助现成的电话网进行信息传送,因此,特别适合于数据采集及远距离传输。对于那些与计算机相距不远的人-机交换设备和串行存储的外部设备如终端、打印机、逻辑分析仪、磁盘等,采用串行方式交换数据也很普遍。本文介绍了单片机与PC 机串行通信的方法,设计了单片机与PC 机之间RS232 标准串行通信接口电路,并给出了在Windows环境下实现异步通信的方案、相应的软件程序以及一个应用实例,实现上位PC机和单片机间的串行通信,给出了硬件线路图、通信协议和程序流程图及使用VB编写上位机通信软件方法,以及部分串行通信程序。这种实现上位机和下位机的串行通信的方法具有使用简单、编写程序方便的特点。
关键词: 串行通信、RS232 标准、单片机
Abstract
Along with computer system''''s popularization and the auxiliary equipment technology''''s development, between the computer and auxiliary equipment''''s correspondence appeared is getting more and more important. And, between the computer and the monolithic integrated circuit the serial port correspondence''''s application are also getting more and more, because the serial message center uses the transmission line are few, the reliability is high, and may draw support from the ready-made telephone network to carry on the information transmission, therefore, especially qualify in data acquisition and long-distance transmission. Regarding these with the computer close not far person - machine commutation equipment and serial storage''''s external instrumentation like terminal, the printer, the logical analyzer, the floppy disk and so on, uses the serial mode exchange data to be very also common. This article introduces the serial communication method between pc and single chip processor, then design the interface circuit according to RS232-standard, and gave has realized the asynchronous communication plan, the corresponding software routine as well as an application example under the Windows environment, realized superior PC machine and between monolithic integrated circuit''''s serial communication, has given the hardware circuit diagram, the communication protocol and the program flow diagram and uses VB to compile the superior machine correspondence software method, as well as part serial communication procedure. This kind realizes the superior machine and the lower position machine serial communication method has the use to be simple, write program convenient characteristic.
Keywords:Serial communication、RS232-standard、single chip
目 录
摘要. . ..I
1 绪论.1
1.1 本课题的背景与意义..1
1.2 国内外串行通信的现状与发展....1
1.3 PLC串行通信的发展前景...2
1.4 本设计所完成的工作......2
2 单片机的硬件设计... . . ..4
2.1单片机的硬件系统.....4
2.1.1单片机内部结构...4
2.1.2相关的寄存器...5
2.2 89C51单片机串行接口的结构.5
2.2.1串行接口控制寄存器SCON..9
2.3 74HC2244芯片的介绍...12
2.3.1 74HC2244芯片的功能.12
2.3.2应用74HC244芯片扩展...12
2.4 89C51通信波特率设置.13
2.4.1方式0的波特率...13
2.4.2方式2的波特率...14
2.4.3方式1和方式3的波特率...14
3 PC机与89C51单片机的软件通信........16
3.1 单片机和PC机串行通信的原理...16
3.2 RS 232C 通讯协议特性.........18
3.3 RS 232C 与TTL 电平转换............18
3.4 89C51单片机通信软件的设计..........19
3.4.1通讯协议...19
3.4.2多从机时的通信协议...22
3.5 串口通信设置...............23
3.6 校验...............23
4 总结....25
参考文献.....26
致谢......27