摘要在工、农业生产和日常生活中,各个环节都与温度紧密相连,温度的测量及控制占有极其重要的地位。
温度已成为大多数仪器正常工作的前提,而且对温度的要求也越来越严格。
因此,温度检测与控制方法的研究也越来越受到人们的重视。
本文介绍的温度控制系统为两层结构,上位机由组态软件完成对下位机的监控。
下位机利用数字温度传感器DS18B20,结合单片机组成传感器网络,设计了相关硬件和软件,实现多点温度测量和控制。
论文中介绍了DS18B20进行循环温度检测的方法和采用增量式PID控制算法和PWM调功方式,通过控制固态继电器在一定周期内的通断占空比,最终实现对电烤箱的温度控制。
其中控制范围为室温到120℃,误差小于0.5℃。
上位机PC与单片机之间通过RS232串口实现数据交换,又组态软件King View具有强大的数据采集、处理功能和友好的人机界面,故基于单片机和组态王的温度控制系统,可以理想地实现对相关设备的实时监控。
此系统具有成本低、可靠性高、使用方便等特点,可广泛用于仓库测温、楼宇空调温度控制、生产过程监控等。
关键词: AT89S52;DS18B20;温度控制;组态王;RS232AbstractIn industrial and agricultural production and daily life,all sectors are closely related to temperature.Temperature Measurement and Control occupy a very important position. At present,temperature measurement and control equipment has become normal working majority of the premise that and the temperature requirements more stringent. Therefore,the temperature measurement and control method of attracting increasing attention.The paper introduces a temperature control system,the detection and control of the controlled objects are accomplished by slave computers,and the supervision of the controlled objects and slave computers is implemented in the host computer based on King View.DS18B20 and Microprocessor AT89S52 build up sensor networks,which achieve the design of hardware and software for multiple spots temperature detected and control system.The Paper describes the DS18B20 temperature measurement method and application of incremental PID loop control algorithm and mode of PWM power by controlling the solid state relay must cycle on/off duty cycle, and ultimately to electric oven temperature control.The entire temperature detected and control system is capable of detecting and controlling multiple-point temperature for accurate measurement,the controlling range from the room temperature to 120℃,control error is less than 0.5℃.The communication between PC and microprocessor based on RS2332 is described in detail in the paper.King View software supports a powerful platform for real time detection project.It supports powerful function for data acquisition and management and man-machine interface.The state detection for temperature detected and control system based on Microprocessor and King View software is designed to detect the devices and make sure the devices work in a reliable,effective and secure way.With low cost,high reliability and convenience of operators,the system can be used in many fields such as the temperature measurement system of warehouse,the air conditioning control of building and the monitor of productive process.Keywords: AT89S52; DS18B20; Temperature control; King View; RS232目录1 绪论 (1)1.1课题背景及现状 (1)1.1.1温度测量方面 (1)1.1.2温度控制方面 (2)1.2研究意义 (2)1.3课题要求 (3)2 方案论证与主要器件选型 (4)2.1方案比较与选择 (4)2.1.1温度测量方案选择 (4)2.1.2温度控制方案的选择 (5)2.2主要器件的选择 (6)2.2.1传感器 (6)2.2.2主控元件 (8)2.2.3显示器件 (9)2.2.4控制模块 (9)2.2.5通信模块 (11)2.3上位机组态监控 (12)2.4系统总体设计框图 (12)3 系统硬件电路设计 (14)3.1系统硬件电路框图 (14)3.2单片机最小系统设计 (14)3.3多点测量电路设计 (16)3.3.1.读序列号电路的设计 (16)3.3.2.温度测量电路的设计 (16)3.3.3 DS18B20使用中注意事项 (18)3.4显示和键盘电路设计 (18)3.4.1显示和键盘电路图 (18)3.4.2显示部分设计 (19)3.4.3键盘电路设计 (20)3.5控制模块电路设计 (21)3.5.1控制执行电路 (21)3.5.2报警电路 (21)3.6串口通讯电路 (22)4系统软件部分设计 (23)4.1软件总体设计 (23)4.2 DS18B20的测温程序 (24)4.2.1 DS18B20常用指令 (24)4.2.2 初始化子程序 (24)4.2.3 读子程序 (25)4.2.4 写子程序 (25)4.3显示和键盘扫描程序 (26)4.3.1显示扫描程序流程图 (26)4.3.2键盘扫描程序流程图 (26)4.4控制执行程序 (27)4.4.1控制思路及其流程图 (27)4.4.2 PID控制算法 (28)4.4.3 PID参数的整定 (29)4.4.4 PWM波的设计 (30)4.5通讯程序 (30)4.6组态王监控界面设计 (34)5 系统调试 (36)5.1 硬件部分调试 (36)5.2 软件部分调试 (37)6 总结 (38)参考文献 (40)致谢 (41)附录A 电气原理图 (42)附录B 主要程序 (42)1 绪论温度在现代社会中成为一个很重要的物理量,人们可以根据温度来调节个人的生活行为,气象工作者可以根据温度变化范围来提供可靠的天气预报。
在工农业生产中,人们根据温度值来调节生产过程。
因此,准确的温度测量和控制在现代化的社会生产中具有重要的研究意义。
1.1课题背景及现状1.1.1温度测量方面温度是与人们的生产生活密切相关的一个物理 ,因此产生了各种各样的温度测方法,在工业领域内 ,对温度的测控十分广泛。
在很多工业应用的场合下,环境非常恶劣,人工直接操作仪表很不现实 ,采用有线数据通信的方式也有限制,在数据记录上也需要人工抄写,因此需要一种无线隔离的操作方式。
温度作为在生产、科研、生活中需要测量和控制的重要物理量,其测量控制一般采用各式各样形态的温度传感器。
根据它们在讯号输出方式的不同,可以把它们分为模拟温度传感器、数字温度传感器和智能温度传感器。
(1)模拟温度传感器模拟温度传感器有多种输出方式(绝对温度、摄氏温度和华氏温度)以及电压偏移值。
后者让组件在使用单电源的情形下就能对负温度值进行检测。
模拟温度传感器的输出还可以送到比较器来产生超温指示信号,或直接送到模拟数字转换器的输入,用来显示实时温度数据。
模拟温度传感器适合需要低成本、小体积和低功耗的应用。
另一种是温度开关或逻辑输出传感器,这种传感器会在温度超过某个默认值时输出特定的逻辑讯号。
而这个触发点(限制值)可以预设,因此,这类组件让设计更加简单,成本也更低。
它的典型应用如关闭系统电源,启动风扇、空调、加热器等。
(2)数字温度传感器对于更紧密控制能力、更高精度和更大分辨率的需求带动了数字温度传感器的发展。
被测温度信号从敏感元件接收的非电量到转换为微处理器可处理的数字信号,环节较多,而且模拟信号在长距离传输的过程中,受到干扰较多、误差较大。
因此,从非电量转换到数字信号,一般将其处理过程集成在单片IC器件体内部,这样就形成了功能强大、精确的数字温度传感器。
数字温度传感器能够直接读取被测物体的温度值,而且体积小,电压适用范围宽3V~5V,用户还可以通过编程实现9~12位的温度读数,即具有可调的温度分辨率。