您好,欢迎来到佳博论文网!

基于串行通信的分布式测控系统研究(上位机部分)

论文编号:DQ192论文字数:17762,页数:39

摘 要

本次毕业设计主要研究基于串行通信的分布式测控系统中PC机与单片机之间串行通信的上位机部分, PC 机通信程序利用VB 提供的MSComm 串行通信控件来完成, 单片机的程序用C语言来编写。VB 提供了MSComm 串行端口控件来为应用程序提供串行通讯,该控件屏蔽了通信过程中的底层操作,程序员应用时只需设置、监视 MSComm 控件的属性和事件即可完成对串行口的初始化和数据的输入输出工作,利用MSComm控件及硬件设施进行串口通信, 可以很好地实现PC 机与单片机之间的实时数据传送。本文主要论述了如何实现这种串行通信,通信协议的制订以及上位机相关界面和程序的设计。

关键词:串行通信 PC机 单片机 VB

Abstract

The article is mainly about study the PC part in serial communication between PC and SCM ,which is a core of distributed measurement and control system which bases on the serial communication Distributed, PC-communication procedures use MsComm provided by VB to complete serial communication, while single-chip microcomputers use C language to write. VB provides a serial port control procedures called Mscomm for the using of serial communication, the control of the communication process shielding the bottom of operation, application programmers can complete initialization of the serial port and the input and output of data owing to set up and monitor Mscomm control attributes and events. real-time data transfer between PC and single-chip microcomputer can be acheieved by the serial communication making use of mscomm and the procedures and hardware facilities. This paper discusses how to achieve this serial communication, and complete the communication protocol and the procedures and interface related to the design in the VB.

Key words: Serial Communication PC SCM VB

目 录

摘要………………………………………………………………………………………………………I

Abstract……………………………………………………………………………………………… II

1 绪论…………………………………………………………………………………………………1

1.1 前言………………………………………………………………………. ……………………1

1.2本文的内容和结构………………………………………………………. …………………….2

2 串行通信的种类及比较…………………………………………………………………………3

2.1 串行通信的种类………………………………………………………………………………3

2.1.1 RS-232通信……………………………………………………………………………5

2.1.2 RS-485通信……………………………. ……………………………………………..6

2.1.3 USB通信……………………………. ………………………………………………...7

3 系统架构和上位机控件…………………………………………………………………………8

3.1 系统构架和RS-232设置……………………………………………………………………..8

3.1.1 RS-232的电气特性和字符传送……………………………………………………..9

3.1.2 RS-232的脚位定义和功能…………………………………………………………11

3.1.3 通信的工作模式…………………………………………………………………….12

3.1.4 速度及流量控制…………………………………………………………………….13

3.1.5 通信端口的初始化………………………………………………………………….15

3.2 上位机控制软件VB和MSComm控件……………………………………………………16

3.2.1 上位机VB软件简要介绍……………………………………………………………16

3.2.2 MSComm 控件的主要属性及事件………………………………………………..18

3.2.3 用MSComm控件进行串口通信一般步骤…………………………………………19

4 通信原理与程序设计 …………………………………………………………………………21

4.1 PC机和单片机串行通信的简要介绍……………………………………………………….21

4.2 通信原理的分析………………………………………………………………. ……………22

4.2.1 MSComm控件通信方式的选择……………………………………………………….22

4.2.2 PC机串行口中断通信管理程序框图………………………………………………23

4.3 通信协议和波特率的的设定……………………………………………………………….25

4.3.1 通信协议…………………. ………………………………………………………..26

4.3.2 波特率的设定……………………………………………………………………….27

5 总结………………………………………………………………………………………………28

致谢……………………………………………………………………………………………………29

参考文献 ……………………………………………………………………………………………30

附录一 电路原理图

附录二 VB程序

基于串行通信的分布式测控系统研究(上位机部分)......