随着数据通信技术的发展,采用PC 与多台单片机构成的分布式系统、工业控制系统、数据传输系统等越来越受到广泛应用。本课题在国内外已受到非常多的关注与研究,并且不断的得到改进,在实际应用中也取到了较好的效果,具有非常好的应用推广价值。
本课题的主要研究工作是在PC机与单片机的数据通信中采用RS485 总线组建的远程双向数据通信系统的系统结构、硬件设计。因此本文主要介绍了基于RS485总线的远程双向数据通信系统平台构成,描述了上位PC机负责通信(包括与单片机之间的串行通信和数据的远程通信)、数据处理以及用VB6.0建立在Window2000/ XP 环境下的计算机端通信软件和用单片机KeilC51 编写的下位机通信软件等工作。另外,也对本系统所采用的可靠性、抗干扰措施和容错设计作了一些介绍.在本系统中,上位机以PC和Windows操作系统为软、硬件资源;下位机采用ATMEL公司89S52,总线标准采用的是测控系统常用的RS-485。
将该系统运用到宾馆客房环境监测系统中,下位机的温湿度传感器SHT11和烟雾传感器MQ-N5采集数据到数据后,通过此485总线系统能将测量数据(温湿度)传送到PC机上显示,对检测到烟雾起报警作用。试验结果最终表明,该系统整体实现了实时性较好,运行稳定可靠。
关键词:串行通信;RS-485总线;VB6.0; 89S52;远程双向数据通信;
Abstract
With the development of digital communication technology,the distribute-type systems, industrial control systems, data transmission systems,.etc, which adopts PC to constitute with many microcontrollers to be subjected to more and more extensively applied. This topic is continuously having already been subjected to quite a few concern and research at home and abroad, and getting a continuous improvement, also taking better result in physical application, having very nice expansion value.
The main research work of this topic is the system structure, hardware design in the PC and SCM data communications,which is using Long-range two-way data communication system established by RS-485 . So this text mainly introduced the terrace according to the constitute of the Long-range two-way data communication system established by RS-485 ,describing the place of honor PC machine to be responsible for correspondence (including with the line correspondence to scm and data in the long-disdance correspondence), data processing , using VB6.0 builds the computer software and communications - SCM software prepared with KeilC51 in Window2000 / XP environment and so on. Moreover, also making some introduction to the credibility, anti- interference measure and the system-permitted- wrong design .In this system ,the honor PC machine uses PC and Windows operating system for software and hardware resources ; the lower computer adopts 89S51 which is produced by ATMEL Corporation, Bus standard adopts the monitoring system that is commonly used RS-485 .
Make use of that system to the environment monitor of the hotel room in the system, , after the temperature and humidity sensor SHT11 and smoke senstor MQ-N5 of the lower PC collecting the data to the data,can send measurement data(temperature and humidity) to the PC by 485 bus system , it rightly plays an alarm starting role to the process that detects smoke . Final test results show that the system achieved a better real-time, stable and reliable operation as a whole.
Keyword: Serial Communication ; RS-485 bus ;VB6.0; 89S52; Long-range two-way data communication ;