-I-摘要本课题设计的是一套计算机控制的温度、湿度实时监测与报警系统,可应用于多种需要采集温湿度数据的场合,本文完成了整个系统的软硬件设计。系统采用单总线传感器网络和RS485传输网络的设计思想。其中温度、湿度传感器都以智能终端的形式挂接到单总线上,多条单总线汇总到一起,由一台数据采集器集中控制,每台数据采集器负责一定区域内的温湿度监测。数据采集器的核心部件为单片机,主要完成对其所连接传感器件的测量与控制以及与主机的通信等功能。各采集器以网络结点的方式挂接到RS485传输网络上,传输距离远,还可有效的抑制共模干扰。设计中的RS232/RS458转换器用来实现RS485总线网络与主机RS232串口通信的相互转换。系统中为主机与各采集器之间的数据通信制定了完备的通信协议,采用主机调度工作形式,CRC技术校验数据,以保证通信的可靠性。用Delphi开发了具有温湿度数据显示、告警、历史数据和曲线显示与打印等功能的主机用户管理软件。关键词:单总线,单片机,循环冗余码校验,通信协议-II-AbstractThispaperintroducesakindofreal-timemonitoringsystemfortemperatureandhumiditycontrolledbycomputer,whichiscanbeusedformanyapplications.Thepapercompletesboththesoftwareandhardwaredesign.Thesystemadopts1-WiresensornetandRS485transmissionnettechnique.Manysensorsareconnectedto1-Wirebusasintelligentterminals.Thedatacollectionstationgathersallbuses.Eachdatacollectorisresponsibleforaregion.ThekernelofdatacollectorisMCU,whichtakeschargeofmeasurement,controlandcommunicationwiththehostcontroller.TheRS485transmissionnetismadeupofthedatacollectionstation,whichcantransmitforremotedistanceandrestraincommonmodeinterference.TheRS232/RS485converterisusedforconversionbetweenRS485andRS232,whichisusedbythehostcontroller,computer.Aself-containedserialcommunicationprotocolisdefined,whichcanhelpthehostcontrollercommunicatewiththedatacollector.Thehostcontrollerworksasadispatcher.CRCtechnologyisadoptedtoverifydataandguaranteethedependabilityinthecommunication.TheDelphiisusedtodesigntheuserinterfacefordisplayandmonitoringoftemperatureandhumidityinformation,showingandprintingforhistoricalrecordsandcurvesetc.Keywords:1-Wire,MCU,CRC,CommunicationProtocol-III-目录摘要..........................................................................................................................................IAbstract........................................................................................................................................II1绪论...........................................................................................................................................11.1课题研究的目的和意义.................................................................................................11.2温度、湿度数据采集与监测技术的发展历程.............................................................11.3本课题的主要特点.........................................................................................................22系统的总体设计.......................................................................................................................32.1系统功能.........................................................................................................................32.2系统主要技术指标.........................................................................................................32.3系统的总体结构.............................................................................................................42.4系统的工作过程.............................................................................................................53单总线与温度、湿度传感器...................................................................................................63.1温度传感器DS18B20...................................................................................................63.1.1DS18B20简介......................................................................................................63.1.2DS18B20的内部结构..........................................................................................63.1.3CRC校验原理与实现..........................................................................................93.2单总线系统...................................................................................................................103.2.1单总线协议.........................................................................................................103.2.2单总线系统中ROM搜索算法的研究与实现................................................133.3湿度传感器选择及外围电路设计...............................................................................143.3.1湿度传感器HIH3610........................................................................................143.3.2单总线数字湿度传感器外围电路设计.............................................................154温湿度数据采集器与RS232/RS485转换器......................................................................184.1数据采集器的结构与电路设计...................................................................................184.1.1单总线接口电路.................................................................................................184.1.2采集器地址选择开关电路.................................................................................194.1.3RS485总线接口电路.........................................................................................204.1.4供电电路.............................................................................................................204.2数据采集器的软件设计...............................................................................................214.2.1数据采集器中单总线器件的预处理.................................................................234.2.2数据采集系统中对单总线器件的访问...........................