密级:公开
基于单片机的空调温度控制器设计 The design of air conditioning
temperature controller based on MCU
学 院:信息科学与工程 专 业 班 级:测控技术与仪器1003班 学 号:100401316 学 生 姓 名:刘 和 平
指 导 教 师:颜 华 (教授)
2014 年 6 月
II
摘 要
随着经济的发展和人们生活水平的提高,空调机受到了广泛的应用。空调机的温度控制器主要是由温度传感器感受室内温度变化,将采集到的温度信号处理后与设定的温度值进行比较,控制继电器的通断,使温度被控制在设定值左右,使空调器的工作状态随着人们要求和环境状态而自动变化,迅速准确的达到人们的要求,并使空调器的工作状态保持在最合理的状态下。在工农业生产、科学研究和在人们的生活领域中,温度测控系统占有很重要的地位,得到了广泛的应用。因此,温度传感器的应用数量居各种传感器之首。目前,温度传感器正从模拟式向数字集成式方向飞速发展。
本文主要从硬件和软件两方面介绍了单片机温度控制系统的设计。该系统以STC12C5608AD单片机为核心,主要由温度检测电路、按键与显示电路、继电器控制电路等构成。在本系统中,主要是同过DS18B20采集被测温度并转换成数字信号送单片机,以单片机为核心数据处理系统,通过两位数码管,显示设定温度,通过继电器来控制压缩机、四通阀从而控制空调制冷或制热。本论文概述了温控器的发展及基本原理,介绍了温度传感器的原理及特性,分析了DS18B20温度传感器的优劣。在此基础上描述了系统研制的理论基础,对测温系统的一些主要参数进行了讨论。同时在介绍温度控制系统功能的基础上,提出了系统的总体构成。针对测温系统温度采集、接收、处理、显示部分的总体设计方案进行了论证,进一步介绍了单片机在系统中的应用,分析了系统各部分的硬件及软件实现。
关键词:DS18B20;单片机;温度控制;空调
I
Abstract
With the development of economy and the improvement of people's living standard, the air conditioner has been widely applied. Temperature controller of air conditioner is mainly composed of sensors to monitor indoor temperature, the temperature signal processing the collected with the set temperature value, to control the on-off relay, the temperature is controlled in the set value, the air conditioner working condition with people demand and the state of the environment changes rapidly and automatically, accurate to the requirements of the people, and make the air conditioner working state is maintained in a reasonable state. In the industrial and agricultural production, scientific research and in people's lives, temperature measurement and control system plays a very important role, has been widely applied. Therefore, the number of temperature sensor applications of various sensors of the first home. At present, the temperature sensor from analog to digital integrated development.
This paper mainly describes the hardware and software aspects of the design of single-chip temperature control system. The system STC12C5608AD microcontroller core, mainly by the temperature detection circuit, buttons and display circuit, relay control circuit, etc.. In this system, mainly through the DS18B20 collection with the measured temperature and converted into a digital signal sent to the microcontroller, microcontroller as the core data processing system, through two digital tube display set temperature, the compressor is controlled by relays, Stone valve to control the air conditioning, refrigeration or heating. This paper outlines the development and the basic principles of the thermostat, introduced the principle and characteristics of the temperature sensor. Analysis of the merits of the DS18B20 temperature sensor. Based on this description of the theoretical basis for the development of the system, some of the key parameters of the measurement system were discussed. While the introduction of a temperature control system functions is proposed based on the overall structure of the system. Temperature measurement system for collecting, receiving, processing, display part of the overall design has been demonstrated, further describes the SCM applications in the system, and analyzes the various parts of the system hardware and software.
Keywords: DS18B20; single chip microcomputer; temperature control; air conditioning
II
目 录
摘 要 ..................................................................................................................................... I Abstract ..................................................................................................................................... II 第1章 绪论 .............................................................................................................................. 1
1.1 课题研究目的 ............................................................................................................. 1 1.2 课题研究意义 ............................................................................................................. 1 第2章 系统总体方案设计 ...................................................................................................... 3
2.1 温度传感器产品分类与选择 ..................................................................................... 3
2.1.1 常用的测温方法 .............................................................................................. 3 2.1.2 温度传感器产品分类 ...................................................................................... 3 2.1.3 温度传感器的选择 .......................................................................................... 5 2.2 总体方案的确定 ......................................................................................................... 6 2.3 系统实现框图 ............................................................................................................. 7 第3章 系统单元电路设计 ...................................................................................................... 8
3.1 系统相关硬件及模块介绍 ......................................................................................... 8
3.1.1 温度采集电路 .................................................................................................. 8 3.1.2 STC12C5608AD介绍 ...................................................................................... 9 3.1.3 时钟电路 ........................................................................................................ 11 3.1.4 复位电路 ........................................................................................................ 11 3.1.5 温度显示电路 ................................................................................................ 12 3.1.6 按键功能设置电路 ........................................................................................ 13 3.1.7 继电器驱动电路 ............................................................................................ 14 3.1.8 继电器控制电路 ............................................................................................ 14 3.1.9 压缩机、四通阀 ............................................................................................ 15 3.1.10 电动机电路 .................................................................................................. 15
第4章 系统软件设计 ............................................................................................................ 17
4.1 DS18B20数据通信概述 ......................................................................................... 17 4.2 控制接口时序说明 .................................................................................................. 19 4.3 软件程序设计 ........................................................................................................ 20
4.3.1 主程序模块流程图 ........................................................................................ 21 4.3.2 DS18B20测温程序及流程图 ........................................................................ 22 4.3.3 按键扫描程序及流程图 ................................................................................ 25 4.4程序调试 ................................................................................................................... 26
I