基于单片机的多功能温度检测系统的设计翻译

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

基于单片机的多功能温度检测系统的设计一、引言
随着社会的发展和技术的进步,人们越来越注重温度检测与显示的重要性。

温度检测与状态显示技术与设备已经普遍应用于各行各业,市场上的产品层出不穷。

温度检测及显示也逐渐采用自动化控制技术来实现监控。

本课题就是一个温度检测及状态显示的监控系统。

二、系统方案
本系统采用AT89S52 作为该系统的单片机。

系统整体硬件电路包括,电源电路,传感器电路,温度显示电路,上下限报警电路等如图1 所示。

图中报警电路可以在被测温度不在上下限X围内时,发出报警鸣叫声音。

温度控制的基本原理为:当DSl8B20 采集到温度信号后,将温度信号送至AT89S52 中处理,同时将温度送到LCD 液晶屏显示,单片机根据初始化设置的温度上下限进行判断处理,即如果温度大于所设的最高温度就启动风扇降温;如果温度小于所设定的最低温度就启动报警装置。

温度控制器的原理图二三、系统硬件设计1.单
片机AT89S52 的介绍
AT89S52 是一种低功耗、高性能CMOS8 位微控制器,具有8K 可编Flash 存储器。

使用Atmel 公司高密度非易失性存储器技术制造,与工业80C51 产品指令和引脚完全兼容。

片上Flash 允许程序存储器在系统编程,亦适于常规编程器。

在单芯片上,拥有灵巧的8 位CPU和在系统可编程Flash,使AT89S52 为众多嵌入式控制应用系统提供高灵活、超有效的解决方案[5]。

AT89S52 具有以下标准功能:8k 字节Flash,256 字节RAM,32 位I/O 口线,看门狗定时器,2 个数据指针,三个16 位定时器/计数器,一个6 向量2 级中断结构,全双工串行口,片内晶振及时钟电路。

另外,AT89S52 可降至0Hz 静态逻辑操作,支持2 种软
件可选择节电模式。

空闲模式下,CPU 停止工作,允许RAM、定时器/计数器、串口、中断继续工作。

掉电保护方式下,RAM 内容被保存,振荡器被冻结,单片机一切工作停止,直到下一个中断或硬件复位为止。

2.DS18B20 传感器的介绍
在传统的模拟信号远距离温度测量系统中,需要很好的解决引线误差补偿问题、多点测量切换误差问题和放大电路零点漂移误差问题等技术问题,才能够达到较高的测量精度。

另外一般监控现场的电磁环境都非常恶劣,各种干扰信号较强,模拟温度信号容易受到干扰而产生测量误差,影响测量精度[5]。

因此,在温度测量系统中,采用抗干扰能力强的新型数字温度传感器是解决这些问题的最有效方案,与其它温度传感器相比DSl820 具有以下特点:
(1)独特的单线接口方式。

DSl820 在与微处理器连接时仅需要一条接口线即可实现微处理器与DSl820 的双向通讯。

(2)多点功能简化了分布式温度检测的应用。

(3)DSl820 在使用中无需任何外围元件。

(4)可用数据线供电,电压X围从3.0V 到5.5V。

(5)可测量的温度X围从-55℃到+125℃,增量值0. 5℃;华氏温度X围从-67 到+257,增量值0.9。

(6)支持多点组网功能。

多个DS1820 可以并接在同一条总线上,实现多点测温。

(7)9 位的温度分辨率。

测量结果以9 位数字量方式串行传送。

(8)用户可设定温度报警门限值。

(9)有超温度搜寻功能。

(1)DSl8B20 的工作原理
DS18B20 的内部结构DSl8B20 的测温原理框图如图3.2 所示。

图中低温度系数品振的振荡频率受温度影响很小,用于产生同定频率的脉冲信号送给计数器l。

高温度系数晶振随温度变化其振荡频率明显改变。

所产生的信号作为计数器2 的脉冲输入。

计数器1、计数器2 和温度寄存器被预置在-55℃所对应的一个基数值。

计数器l 对低温度系数晶振产生的脉冲信号进行减法计数,当计数器1 的预置值减到O 时,温度计数器的值将加l,计数器l 的预置值将被重新装人,计数器l 重新开始对低温度系数晶振产生的脉冲信号进行计数,如此循环直到计数器2 计数到O 时,停止温度寄存器的累加,此时温度寄存器中的数值即为所测温度。

图3.2 中的斜率累加器用于补偿和修正测温过程中的非线性,其输出小于修正计数器l 的预置值。

(2)DS18B20 与AT89S52 的接口方式
DS18B20 与单片机的连接方式有两种:即寄生电源方式和外部电源方式。

寄生电源方式:在寄生电源供电方式下,DS18B20 从单线信号线上汲取能量:在信号线DQ 处于高电平期间把能量储存在内部电容里,在信号线处于低电平期间消耗电容上的电能工作,直到高电平到来再给寄生电源(电容)充电。

寄生电源方式有三个好处:1)进行远距离测温时,无需本地电源。

2)可以在没
有常规电源的条件下读取ROM。

3)电路更加简洁,仅用一根I/O 口实现测温。

要想使DS18B20 进行精确的温度转换,I/O 线必须保证在温度转换期间提供足够的能量,由于每个DS18B20 在温度转换期间工作电流达到1mA,当几个温度传感器挂在同一根I/O 线上进行多点测温时,只靠4.7K 上拉电阻就无法提供足够的能量,会造成无法转换温度或温度误差极大。

外部电源供电方式:在外部电源供电方式下,DS18B20 工作电源由VDD 引脚接入,此时I/O 线不需要强上拉,不存在电源电流不足的问题,可以保证转换精度,同时在总线上理论可以挂接任意多个DS18B20 传感器,组成多点测温系统。

本系统采用外部电源方式。

连接方法即DS18B20 的1 脚接地,2 脚(DQ 引脚)与AT89S52 的一根I/O 口线相连,3 脚接+5V。

在A89S52 的I/O 口线与+5V 之间连接一4.7K 的上拉电阻,以保证数据采集的正常进行。

若要组成多点温度检测系统,可在单片机的同一根I/O 口线上,以相同的连接方法并联多片DS18B20 芯片。

3、LCD1602 液晶屏
1602 液晶显示模块可以和单片机AT89S52 直接接口。

4、蜂鸣器驱动电路
由于蜂鸣器的工作电流一般比较大,以致于单片机的I/O 口是无法直接驱动的,所以要利用放大电路来驱动,一般使用三极管来放大电流就可以了。

当所测的温度低于6 摄氏度时,报警。

5、风扇电路
当所测的温度高于80 摄氏度时,启动风扇电路。

因为工作电流比较大,所以用放大电路来驱动,即用三极管来放大电流就可以了。

当温度高于80℃时,给单片机一个命令,单片机P2.6 引脚输出高电平,三极管导通,风扇电路接通,电风扇开始转动,从而起到降温作用。

四、系统的软件设计
本系统采用AT89S52 作为核心处理器件,把经过DSl8B20 现场实时采集到的温度数据,存入AT89S52 的内部数据存储器,送液晶显示,并与预先设定值进行比较,然后由单片机输出信号去控制风扇电路和报警电路。

多功能温度检测显示系统软件主要包括:函数声明、延迟时间函数、DS18B20 初始化函数、读出DS18B20 当前的温度、温度数据转化成液晶字符显示等程序。

五、小结随着工业的不断发展,对温度测量的要求来越高,而且测量X围也越来越广,因此对温度检测技术的要求也越来越高。

本文介绍了以DSl8B20 新型数字温度传感器、AT89S52 单片机、LCD1602 液
晶显示模块为主体构建的温度检测显示系统。

说明了系统硬件电路、系统主程序与各模块子程序的设计。

本系统采用的是DALLAS 公司推出的数字式温度传感器DS18B20,无需外加A/D 即可输出数字量,把温度信号直接转换成串行数字信号供微机处理。

因此。

该系统具有硬件电路结构简单、转换精度高、显示结果清晰稳定、成本低等显着优点。

在诸如粮库测温、智能建筑、中央空调等多种需要温度检测的场合具有较好的应用前景。

Based on SCM multi-functional temperature testing
system design
1、preface
With the development of society and the technological progress, people pay more and more attention to the importance of temperature detection and display. Temperature detection and status display technology and equipment has been widely applied in industries, products on the market emerge in endlessly. Temperature testing and also gradually adopt the automatic control technology to realize the monitor. This topic is a temperature testing and status of the monitoring system.
2、System solutions
This system USES the monolithic integrated circuit AT89S52 as this system. The whole system, the hardware circuit including power supply circuit, sensor, the temperature display circuit circuit, upper alarm circuit such as shown in figure 1. Figure in the alarming circuit can be measured in upper temperature range, screaming voice alarm. The basic principle for the temperature control DSl8B20: when the temperature signal acquisition to after temperature signal sent to handle, AT89S52 temperature to LCD screen, SCM according to initialize the upper temperature setting, namely, if the
judgement of temperature than the highest temperature cooling fan is started, If the temperature is less than the lowest temperature setting on alarm device. Temperature controller diagram
3、The system hardware design
(1)AT89S52 SCM are introduced
AT89S52 devices is a low power consumption, high CMOS8 bit micro-controller, 8K programmable Flash memory. Use Atmel pany high-density nonvolatile storage technology, and industrial 80C51 product instruction and pin fully patible. The Flash memory chips allows programs in system programming, also suitable for conventional programming. In a single chip, have clever 8 bits CPU and programmable Flash in the system, for many embedded control AT89S52 application system provides a highly flexible, efficient solutions [5]. AT89S52 has the following functions: the standard 256 bytes, 8k byte Flash RAM, 32 I/O port, the watchdog timer, 2 data, three pointer 16 timer/counter, a 6 vector level 2 interrupt structure, full-duplex serial, timely clock circuit within crystals. In addition, 0Hz AT89S52 can drop to the static logic operation, support two software can choose power saving mode. Idle mode, the CPU to stop working, and allows the RAM, timer/counters, serial, continue to work. Protection mode, RAM by MCU, oscillator is frozen, all the work to stop until the next interruption or hardware reset.
(2)The sensor DS18B20
In the traditional analog signal distance temperature measuring system, need good solve lead error pensation, multi-point measurement error and amplifying circuit
switching technologies such as zero drift error problem, can achieve high measuring accuracy. Another general monitoring site of the electromagnetic environment is very bad, all kinds of jamming signal is stronger, the simulated temperature signal interference and vulnerable to produce measurement error and measuring precision [5]. Therefore, in temperature measuring system, the strong anti-jamming capability of the new digital temperature sensor is the most effective to solve these problems, pared with other temperature sensor DSl820 has the following features:
(1) the unique singleline interface way. DSl820 in connection with the microprocessor only need one interface to implement line DSl820 microprocessors and two-way munication. (2) more function simplifies distributed temperature detection application. (3) DSl820 in use without any peripheral devices. (4) power, voltage range data available from 3.0 V to 5.5 V. (5) can measure temperature range from - 55 degrees c + + to 125, incremental value 0. 5 ° c, Fahrenheit temperature range from - 67 to + 257, incremental value 0.9. (6) support multi-point network function. Multiple DS1820 can pick on the same bus and, more temperature measurement. (7) 9 temperature resolution. Measuring results in nine serial transmission way the digital quantity. (8) user can set temperature alarm threshold. (9) have super temperature search function.
①.DSl8B20 principle of work
The internal structure of DS18B20 DSl8B20 temperature measurement principle diagram shown in figure 3.2. Low temperature coefficient graph oscillation frequency vibration product temperature is used to produce with fixed frequency, pulse signal to
counter l. High temperature coefficient crystals temperature-dependent its oscillation frequency change significantly. The signal generated as the counter 2 input pulses. Counter 1, 2 and temperature registers are counter in - 55 degrees preset corresponding a base value. Counter l to low temperature coefficient of the pulse signal generated crystals, when the counter for subtraction counting the preset value reduced to 1, when the temperature counter O value will add l, counter the preset value will be l man again, to counter the l start low temperature coefficient of crystal oscillator pulse signal, so cycle count until the counter 2, stop counting to O accumulative temperature, temperature of the register for the register is measured values. Figure 3.2 accumulative used for the slope pensation and fixed temperature measurement, the output of the process of nonlinear correction is less than the preset value counter l.
②.AT89S52 interface mode and DS18B20
Chip DS18B20 and the connection has two kinds: namely parasitic power and external power supply mode.
Parasitic power way: in the parasitic power supply mode, the signal from the single chip DS18B20 in line drawing energy during the high level in the DQ energy stored in the internal capacitance, low level in signal in the energy consumed during the capacitance on working until high-level ing again to parasitic power (battery). Parasitic power mode has three advantages: 1) distance measuring temperature, without the local power supply. 2) no conventional power in the condition reads the ROM. 3) circuit, with only one more concise root I/O realize temperature measurement. Want to make precise temperature conversion chip DS18B20, I/O line must ensure that the temperature
conversion period, due to provide enough energy conversion in temperature during each DS18B20, when the current 1mA to work a few temperature sensor in the same root hanging on the I/O multi-point temperature measurement, only by 4.7 K and resistance will not be able to provide enough energy, which cannot be switchover temperature or errors.
The external power source supply way: in the external power supply modes, DS18B20 work power by VDD pin, I/O access line does not need strong pull up, there is no shortage of electricity power, can ensure accuracy and conversion in the bus theory can be articulated multiple sensor DS18B20, multipoint temperature measuring system.
This system USES the external power source. Connection method is one foot grounding and DS18B20 2 feet (DQ) and AT89S52 foot an I/O port, 3 feet line up + 5V. A89S52 in the I/O port and + 5V connection between a 4.7 K pull-up resistors, to ensure the normal operation of the data collection. If you want to test system, posed multi-point temperature in the same root chip I/O port in the same line, and the method of connecting the parallel more pieces of DS18B20 chip.
(3)LCD1602 LCD
1602 LCD module can and monolithic integrated circuit AT89S52 directly interface. (4)Buzzer driver circuit
Due to the working current buzzer is pared monly big, so I/O microcontroller is not directly driven by amplifying circuit, so it is generally used to drive, to enlarge current transistor. When the temperature is below six degrees Celsius, alarm.
(5)Fan circuit
When the temperature is higher than 80 ° c, start fan circuit. Because the job is great, so use current amplifier circuit to drive, to enlarge current transistor. When the temperature is above 80 ° c, give a mand, P2.6 single-chip microcontroller foot output level, triode conduction, fans, electric circuit, which began to turn it down.
4、The design of the software system
This system USES AT89S52 devices as the core, with DSl8B20 after the collected data, and the temperature inside the data storage AT89S52 deposit, LCD display, and pared with the prior value, and then the output signal by MCU control circuit and alarm circuit fan. Multi-functional temperature testing system software mainly include: function declarations, time delay function and DS18B20 initialization function, read the temperature, temperature DS18B20 data into a liquid crystal display characters such programs.
5、Summary
With the continuous development of industry of temperature measurement, the higher requirement, and more and more wide measuring range, so are the requirements for temperature detection technology more and more is also high.
DSl8B20 introduced new digital temperature sensor and AT89S52 SCM, LCD1602 LCD module for constructing the temperature testing system. The hardware circuit and main program and system design of each module subroutines. This system USES the DALLAS is the digital temperature sensor DS18B20, plus A/D can output the digital quantity, the temperature signal directly convert serial digital signal processing for microputer. Accordingly. This system has the hardware circuit structure is simple, high
precision, and shows the result conversion clear stability, low cost and significant advantages. In temperature measurement, such as grain of intelligent building, central air conditioning of the occasion to temperature testing has good application prospects.。

相关文档
最新文档