基于单片机的多功能温度检测系统的设计翻译
- 格式:doc
- 大小:48.00 KB
- 文档页数:7
基于单片机的多功能温度检测系统的设计一、引言随着社会的发展和技术的进步,人们越来越注重温度检测与显示的重要性。
温度检测与状态显示技术与设备已经普遍应用于各行各业,市场上的产品层出不穷。
温度检测及显示也逐渐采用自动化控制技术来实现监控。
本课题就是一个温度检测及状态显示的监控系统。
二、系统方案本系统采用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 内容被保存,振荡器被冻结,单片机一切工作停止,直到下一个中断或硬件复位为止。
安徽建筑工业学院毕业设计 (论文)专业电气工程及其自动化班级 07电气(1)课题基于单片机的实时温度监控系统设计基于单片机的实时温度监控系统设计摘要本文所介绍的是一种采用单总线数字式的温度传感器DS18B20与AT89S52单片机组成的新型温度测量系统,并使用LED数码管显示器将所测温度显示出来。
该系统以 AT89S52单片机为控制核心,利用新型一线制温度传感器 DS18B20测量温度值,实现环境温度的检测和报警。
系统测温范围为-40℃—+85℃,测量精度为 0.5℃。
用户可以自定义报警上、下限,一旦温度超过极限值,单片机便启动声光报警系统。
该系统精度高、测温范围广、报警及时,可广泛应用于基于单片机的温报警场合。
关键词:AT89S52单片机;温度测量;DS18B20;声光报警;数码管显示Design of Real-time Temperature Monitoring System Based on Single Chip MicrocomputerAbstractDescribed in this paper is a single-bus digital temperature sensor DS18B20 AT89S52 single chip with a new temperature measuring system,and use the LED digital display will display the measured temperature. The AT89S52 microcontroller for the control system to the core,Temperature sensor system using a new first-line temperature measurement DS18B20,achieve environmental temperature detection and alarm. Temperature measurement range is -40 ℃ - +85 ℃, measurement ac curacy of 0.5 ℃. Users can customize the alarm, the lower limit,Once the temperature exceeds the limit, the microcontroller will start the sound and light alarm system. The system of high precision, wide temperature range, the alarm in time, can be widely used in microcontroller-based temperature alarm occasions.Key words: AT89S52 microcontroller; temperature measurement; DS18B20; sound and light alarms; digital display目录摘要 (2)Abstract (3)目录 (4)第一章前言 (5)第二章监控系统主要元器件简介 (6)2.1 AT89S52单片机的组成结构及功能 (6)2.1 .1 AT89S52单片机的主要功能 (6)2.1.2 AT89S5单片机的封装及其引脚功能说明 (7)2.1.3外接晶振或外部振荡器引脚 (9)2.1.4 AT89S52复位 (9)2.2温度测量传感器DS18B20介绍 (10)2.2.1 DS18B20简介 (10)2.2.2 DS18B20的引脚、封装和结构 (10)2.2.3 寄生电源 (12)2.2.4 温度测量原理 (12)2.3 四位连体数码管SM410564 (13)第三章系统硬件电路设计 (15)3.1 单片机最小系统 (15)3.2 温度检测模块 (17)3.3 温度显示模块电路 (17)3.4报警电路模块 (17)3.5 基于AT89S52单片机的温度测量系统总电路 (18)3.6 温度测量系统的实物图 (19)第四章控制系统软件设计 (21)4.1 主程序 (21)4.2 子程序 (22)4.2.1读出温度子程序 (22)4.2.2温度转换命令子程序 (22)4.2.3计算温度子程序 (23)4.2.4显示数据刷新子程序 (24)第五章结论 (25)参考文献 (26)致谢 (27)附录一英文文献 (28)附录二中文翻译 (37)第一章前言温度是一种最基本的环境参数,对于我们来说,不仅仅是一个量的反映,更能直接影响作用到我们的生活中,人民的生活与环境的温度息息相关,在工业生产过程中需要实时测量温度,在农业生产中也离不开温度的测量。
VTP ,所有的检测放大器晶体管(M1,M2,M3和M4)都偏向于饱和模式。
M1和M3(M2和M4)的栅源电压几乎是相同的,因为相同的电流流过每一个分支。
当PASE 变低时,左右位线具有相同的电位,21V V +。
由于位线电压相同,位线负载(CELL L I I +)和电容(BL I )的电流也相等。
由于存储单元细胞获取电流{CELL I ),成数量的电流(CELL I )在右边流动,以保持位线电压是相等的。
因此,目前DL 和DL 线之间出现了差异。
位线负载电容的传感速度几乎是独立的,因为BL 和BL 没有电容放电操作。
因此,BL 和BL 不需要预充电和均衡操作,从而导致速度和周期时间的损失。
图10.39所示电路的开环增益表示为 )2(*)1()4(*)3(m gm m gm m gm m gm Gain loop open =-gm(m1),gm(m2),gm(m3)和gm(m4)是M1,M2,M3和M4,分别。
电流检测放大器的一个缺点是大于电压检测放大器的功耗。
“这些放大器通常用于在高速SRAM 和高密度比如由于数据线的大负载电容256 MB DRAM (IO BL _和IOB BL _如图.10.15)。
14.4 非易失性存储器如DRAM 和SRAM 的MOS 内存结构的缺点是,在没有电源的情况下导致的数据丢失。
为了克服这个问题,各种非易失性和可编程(除掩模ROM )内存已提出。
最近,快闪记忆体的基础上浮动门的概念已成为最流行的非易失性存储器,由于其小单元尺寸和更好的功能。
因此,我们将详细描述的基本结构和操作掩模ROM 和在本节中的快闪记忆体。
只读存储器阵列,也可以被看作是一个简单的组合的布尔网络为每个输入组合,即产生一个指定的输出值,每个地址。
因此,存储在一个特定的地址位置的二进制信息可实现了从选定行(字线)选定的列(位线),这是等价的存在或缺乏设备在特定的位置。
在下面,我们将研究两个不同实现的MOS ROM 的阵列。
毕业设计 (论文)专业电气工程及其自动化班级 07电气(1)基于单片机的实时温度监控系统设计摘要本文所介绍的是一种采用单总线数字式的温度传感器DS18B20与AT89S52单片机组成的新型温度测量系统,并使用LED数码管显示器将所测温度显示出来。
该系统以AT89S52单片机为控制核心,利用新型一线制温度传感器DS18B20测量温度值,实现环境温度的检测和报警。
系统测温范围为-40℃—+85℃,测量精度为0.5℃。
用户可以自定义报警上、下限,一旦温度超过极限值,单片机便启动声光报警系统。
该系统精度高、测温范围广、报警及时,可广泛应用于基于单片机的温报警场合。
关键词:AT89S52单片机;温度测量;DS18B20;声光报警;数码管显示Design of Real-time Temperature Monitoring System Based on Single Chip MicrocomputerAbstractDescribed in this paper is a single-bus digital temperature sensor DS18B20 AT89S52 single chip with a new temperature measuring system,and use the LED digital display will display the measured temperature. The AT89S52 microcontroller for the control system to the core,Temperature sensor system using a new first-line temperature measurement DS18B20,achieve environmental temperature detection and alarm. Temperature measurement range is -40 ℃- +85 ℃, measurement accuracy of 0.5 ℃. Users can customize the alarm, the lower limit,Once the temperature exceeds the limit, the microcontroller will start the sound and light alarm system. The system of high precision, wide temperature range, the alarm in time, can be widely used in microcontroller-based temperature alarm occasions.Key words: AT89S52 microcontroller; temperature measurement; DS18B20; sound and light alarms; digital display目录摘要 (2)Abstract (3)目录 (4)第一章前言 (5)第二章监控系统主要元器件简介 (6)2.1 AT89S52单片机的组成结构及功能 (6)2.1 .1 AT89S52单片机的主要功能 (6)2.1.2 AT89S5单片机的封装及其引脚功能说明 (7)2.1.3外接晶振或外部振荡器引脚 (9)2.1.4 AT89S52复位 (9)2.2温度测量传感器DS18B20介绍 (10)2.2.1 DS18B20简介 (10)2.2.2 DS18B20的引脚、封装和结构 (10)2.2.3 寄生电源 (12)2.2.4 温度测量原理 (12)2.3四位连体数码管SM410564 (13)第三章系统硬件电路设计 (15)3.1 单片机最小系统 (15)3.2 温度检测模块 (17)3.3 温度显示模块电路 (17)3.4报警电路模块 (17)3.5 基于AT89S52单片机的温度测量系统总电路 (18)3.6 温度测量系统的实物图 (19)第四章控制系统软件设计 (21)4.1 主程序 (21)4.2 子程序 (22)4.2.1读出温度子程序 (22)4.2.2温度转换命令子程序 (22)4.2.3计算温度子程序 (23)4.2.4显示数据刷新子程序 (24)第五章结论 (25)参考文献 (26)致谢 (27)附录一英文文献 (28)附录二中文翻译 (37)第一章前言温度是一种最基本的环境参数,对于我们来说,不仅仅是一个量的反映,更能直接影响作用到我们的生活中,人民的生活与环境的温度息息相关,在工业生产过程中需要实时测量温度,在农业生产中也离不开温度的测量。
中文4243字英文原文DescriptionThe at89s52 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash Programmable and Erasable Read Only Memory (PEROM) and 128 bytes RAM. The device is manufactured using Atmel’s high density nonvolatile me mory technology and is compatible with the industry standard MCS-51™ instruction set and pinout. The chip combines a versatile 8-bit CPU with Flash on a monolithic chip, the Atmelat89s52 is a powerful microcomputer which provides a highly flexible and cost effective solution to many embedded control applications.Features:• Compatible with MCS-51™ Products• 4K Bytes of In-System Reprogrammable Flash Memory• Endurance: 1,000 Write/Erase Cycles• Fully Static Operation: 0 Hz to 24 MHz• Three-Level Program Memory Lock• 128 x 8-Bit Internal RAM• 32 Programmable I/O Lines• Two 16-Bit Timer/Counters• Six Interrupt Sources• Programmable Serial Channel• Low Power Idle and Power Down ModesThe at89s52 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, a five vectortwo-level interrupt architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition, the at89s52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Power Down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset.Pin Description:VCC Supply voltage.GND Ground.Port 0Port 0 is an 8-bit open drain bidirectional I/O port. As an output port each pin can sink eight TTL inputs. When is are written to port 0 pins, the pins can be used as high impedance inputs.Port 0 may also be configured to be the multiplexed loworderaddress/data bus during accesses to external program and data memory. In this mode P0 has internal pullups.Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pullups are required during program verification.Port 1Port 1 is an 8-bit bidirectional I/O port with internal pullups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pullups.Port 1 also receives the low-order address bytes during Flash programming and verification.Port 2Port 2 is an 8-bit bidirectional I/O port with internal pullups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups.Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application it uses strong internalpull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register.Port 2 also receives the high-order address bits and some control signals during Flash programming and verification.Port 3Port 3 is an 8-bit bidirectional I/O port with internal pullups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups.Port 3 also serves the functions of various special features of theat89s52 as listed below:Port 3 also receives some control signals for Flash programming andverification.RSTReset input. A high on this pin for two machine cycles while theoscillator is running resets the device.ALE/PROGAddress Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming.In normal operation ALE is emitted at a constant rate of 1/6 theoscillator frequency, and may be used for external timing or clockingpurposes. Note, however, that one ALE pulse is skipped during each access to external Data Memory.If desired, ALE operation can be disabled by setting bit 0 of SFRlocation 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.PSENProgram Store Enable is the read strobe to external program memory. When the at89s52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.EA/VPPExternal Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. Port pinalternate functions P3.0rxd (serial input port) P3.1txd (serial output port) P3.2^int0 (external interrupt0) P3.3^int1 (external interrupt1) P3.4t0 (timer0 external input) P3.5t1 (timer1 external input) P3.6^WR (external data memory write strobe) P3.7 ^rd (external data memory read strobe)EA should be strapped to VCC for internal program executions.This pin also receives the 12-volt programming enable voltage(VPP) during Flash programming, for parts that require 12-volt VPP.XTAL1Input to the inverting oscillator amplifier and input to the internal clock operating circuit.XTAL2Output from the inverting oscillator amplifier.Oscillator CharacteristicsXTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 2. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.Idle ModeIn idle mode, the CPU puts itself to sleep while all the onchip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset.It should be noted that when idle is terminated by a hard ware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory.Status of External Pins During Idle and Power Down Modesmode Program memory ALE ^psen Port0 Port1Port2Port3idle internal 1 1 data data data Data Idle External 1 1 float Data data Data Power down Internal 0 0 Data Data Data Data Power down External 0 0 float data Data data Power Down ModeIn the power down mode the oscillator is stopped, and the instructionthat invokes power down is the last instruction executed. The on-chip RAMand Special Function Registers retain their values until the power down modeis terminated. The only exit from power down is a hardware reset. Resetredefines the SFRs but does not change the on-chip RAM. The reset shouldnot be activated before VCC is restored to its normal operating level andmust be held active long enough to allow the oscillator to restart andstabilize.Program Memory Lock BitsOn the chip are three lock bits which can be left unprogrammed (U) orcan be programmed (P) to obtain the additional features listed in the tablebelow:Lock Bit Protection ModesWhen lock bit 1 is programmed, the logic level at the EA pin issampled and latched during reset. If the device is powered up without a reset,the latch initializes to a random value, and holds that value until reset isactivated. It is necessary that the latched value of EA be in agreement with the current logic level at that pin in order for the device to function properly. Programming the Flash:The at89s52 is normally shipped with the on-chip Flash memory array in the erased state (that is, contents = FFH) and ready to be programmed.The programming interface accepts either a high-voltage (12-volt) or alow-voltage (VCC) program enable signal.The low voltage programming mode provides a convenient way to program the at89s52 inside the user’s system, while the high-voltage programming mode is compatible with conventional third party Flash or EPROM programmers.The at89s52 is shipped with either the high-voltage or low-voltage programming mode enabled. The respective top-side marking and device signature codes are listed in the following table.Vpp=12v Vpp=5vTop-side mark at89s52xxxxyywwat89s52xxxx-5yywwsignature (030H)=1EH(031H)=51H(032H)=FFH (030H)=1EH (031H)=51H (032H)=05HThe at89s52 code memory array is programmed byte-bybyte in either programming mode. To program any nonblank byte in the on-chip Flash Programmable and Erasable Read Only Memory, the entire memory must be erased using the Chip Erase Mode.Programming Algorithm:Before programming the at89s52, the address, data and control signals should be set up according to the Flash programming mode table and Figures 3 and 4. To program the at89s52, take the following steps.1. Input the desired memory location on the address lines.2. Input the appropriate data byte on the data lines.3. Activate the correct combination of control signals.4. Raise EA/VPP to 12V for the high-voltage programming mode.5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached.Data Polling: The at89s52 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written datum on PO.7. Once the write cycle has been completed, true data are valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated.Ready/Busy: The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY.Program Verify: If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that their features are enabled.Chip Erase: T he entire Flash Programmable and Erasable Read Only Memory array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all “1”s. The chip erase operation must be executed before the code memory can be re-programmed.Reading the Signature Bytes: The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned are as follows.(030H) = 1EH indicates manufactured by Atmel(031H) = 51H indicates 89C51(032H) = FFH indicates 12V programming(032H) = 05H indicates 5V programmingProgramming InterfaceEvery code byte in the Flash array can be written and the entire array can be erased by using the appropriate combination of control signals. The write operation cycle is selftimed and once initiated, will automatically time itself to completion.中文翻译描述at89s52是美国ATMEL公司生产的低电压,高性能CMOS8位单片机,片内含4Kbytes的快速可擦写的只读程序存储器(PEROM)和128 bytes 的随机存取数据存储器(RAM),器件采用ATMEL公司的高密度、非易失性存储技术生产,兼容标准MCS-51产品指令系统,片内置通用8位中央处理器(CPU)和flish存储单元,功能强大at89s52单片机可为您提供许多高性价比的应用场合,可灵活应用于各种控制领域。
Design of the Temperature Control System Based on AT89C51ABSTRACTThe principle and functions of the temperature control system based on micro controller AT89C51 are studied, and the temperature measurement unit consists of the 1-Wire bus digital temperature sensor DS18B20。
The system can be expected to detect the preset temperature,display time and save monitoring data. An alarm will be given by system if the temperature exceeds the upper and lower limit value of the temperature which can be set discretionarily and then automatic control is achieved, thus the temperature is achieved monitoring intelligently within a certain range。
Basing on principle of the system, it is easy to make a variety of other non-linear control systems so long as the software design is reasonably changed。
The system has been proved to be accurate,reliable and satisfied through field practice. KEYWORDS: AT89C51; micro controller; DS18B20;temperature1 INTRODUCTIONTemperature is a very important parameter in human life。
中英文对照翻译附件1:外文资料翻译译文一种基于DS18B20的温度探测系统摘要所有的DS18B20传感器,用于多点温度测试,IO总线与MCU连接,温度数据的轮流收集。
如果系统有大量的传感器,MCU的时间用在处理温度数据明显延长,因此周期替代测试变得更长。
在本文中,一种新的方法,DS18B20的合理组合和一些在软件上采取的措施,替代试验进展速度明显。
关键词:DS18B20的集团,温度测试,轮流测试所花费的时间。
引言由于结构简单,安装方便,低损失和广泛的用途的温度测试,DS18B20温度测试传感器应用领域,需要多点温度测试,如化学工业,粮食,环境监督管理等。
因为通过一个DS18B20的多点温度测试系统总线,所有DS18B20是挂在一条总线上,然后每个温度测试点的值转换轮流读。
作为转换后读值必须阅读8次引脚的状态,移动时间,位置和存储数据,所以时间多花费在阅读每一个点的数据系统时间。
如果温度测试系统是大型系统由它造成的损失是相当多的,然后交替测试系统的运行速度明显降低,从而影响多点温度测试系统的效率。
在本文中,DS18B20的一些I / O总线上都挂着分组DS18B20的均匀,温度转换获取数据读取DS18B20的状态,系统损耗减少和替代测试速度增加显然,这将不会影响精度和转换的可靠性。
一套点对多点温度,在此实现人工环境实验室测试,这增加了测试效率。
作者对DS18B20的认识DS18B20是单总线数字温度传感器来自美国达拉斯公司。
DS18B20是由64数字光盘刻激光,温度敏感性组成部分,非易失性温度报警触发器(设备TH和TL)。
DS18B20的通信微处理器单总线端口和测试范围DS18B20是从-55摄氏度到+125摄氏度,增量值是0.5摄氏度。
温度可在720ms的数字改为每个DS18B20具有唯一的64数字序号。
图1揭示的具体内容:两个8的数字储量(0号和1号),用于存储在DS18B20的温度值。
0号存储存储器温度值,补充和一号存储器温度值的符号。
Design of the Temperature Control System Based on AT89C51ABSTRACTThe principle and functions of the temperature control system based on micro controller AT89C51 are studied, and the temperature measurement unit consists of the 1-Wire bus digital temperature sensor DS18B20. The system can be expected to detect the preset temperature,display time and save monitoring data. An alarm will be given by system if the temperature exceeds the upper and lower limit value of the temperature which can be set discretionarily and then automatic control is achieved, thus the temperature is achieved monitoring intelligently within a certain range. Basing on principle of the system, it is easy to make a variety of other non—linear control systems so long as the software design is reasonably changed。
The system has been proved to be accurate, reliable and satisfied through field practice. KEYWORDS: AT89C51; micro controller; DS18B20;temperature1 INTRODUCTIONTemperature is a very important parameter in human life. In the modern society, temperature control (TC) is not only used in industrial production, but also widely used in other fields. With the improvement of the life quality,we can find the TC appliance in hotels, factories and home as well. And the trend that TC will better serve the whole society,so it is of great significance to measure and control the temperature。
外文翻译--基于51单片机温度报警器的设计(适用于毕业论文外文翻译+中英文对照)XXX: Design of a Temperature Alarm Based on 51 MCUDepartment: n EngineeringMajor: Measurement and Control Technology and nClass:Student ID:Name:Supervisor:Date:A microcontroller。
also known as a single-chip computer system。
XXX its ns being integrated on a small chip。
it has most of the components needed for a complete computer system。
such as CPU。
memory。
internal and external bus systems。
and mostof them also have external storage。
At the same time。
it integrates XXX interfaces。
timers。
real-time clocks。
etc。
The most XXX integrate sound。
image。
ork。
and complex input-output systems on a single chip.XXX used in the industrial control field。
Microcontrollers XXX CPUs inside the chip。
The original design concept was to integrate a large number of peripheral devices and CPUs on a chip to make the computer system XXX's Z80 was the first processor designed according to this concept。
New Environment Parameters Monitoring And Control System For Greenhouse Based OnMaster-slave DistributedAbstract--According to the actual need of monitoring and control of greenhouse environment parameters in rural areas, a master-slave distributed measurement and control system is designed ,in which PC is taken as the host. The system consists of PC , soil moisture measurement and control module, temperature and humidity, and CO2 monitoring and control module. In the system, PC has large amount of data storage which is easy to make use of fuzzy control expert system, configuration software-King View is used to develop software for PC, by which the development cycle is shorten and a friendly human-computer interaction is provided. Each monitoring and control module consists of STC12 series of microcontrollers, sensors, relays etc. Different modules are select based on the need if system to achieve control greenhouse in partition and block.I. INTRODUCTIONTo modern indoor agriculture, the automatic measurement and control of environment parameters is the key to achieve crop yield and quality of greenhouse. In recent years, facilities agriculture develops vigorously in our country, matched with it, the monitoring and control instrument of greenhouse have also made certain development. After nearly 10 years of unremitting hard work, our research team of measurement and control system of agriculture environment parameters, designed an intelligent measurement and control system of distribution combined of greenhouse which can be popularized in the vast rural areas. This system is mainly control of temperature ,humidity, CO2 concentration, soil moisture and illumination of greenhouse. OF SCM, as the data storage is small, display interface is single ,amount of information is limited ,but its capability price ratio is high, so it is used as a front unit of data acquisition and control; and of PC, it has a large amount of data storage, rich software, convenient human-computer interaction, and so on..If we use outdated and low-priced PC, taking the PC as the upper machine ,taking the different function control modules composed of multiple microcomputers as the lower machines ,then a master-slave distributed and intelligent control system bases on microcomputer is made up, by which both better monitoring and control, display and data collection or management are achieved ,but also lower cost of system is get according to the actual need.II SYSTEM STRUCTURE AND PRINCIPLEThe most marked feature of the distribution combined and intelligent control system greenhouse is that of incorporating with data acquisition, control and management as a whole, module combination, simple structure, convenient human-computer interaction, and using technology of intelligent expert fuzzy control, which can adapt to a variety of crop management control in greenhouse. The structure of the distributed system is composed of two layers: the upper and lower .In the top-price PC is taken as the host to make system management and experts fuzzy operation in intelligent, and to provide a friendly human-computer interface, and to realize the united monitoring and management of greenhouse; the lower is composed of a series of modules of different function ,and in each module, a single chip of AT89C is adopted as the lower machine,RS485 is used to communicate PC with all AT89C,and then the collection, processing and control of the greenhouse parameters is achieved. Each function module is completely isolated in electrical, any failure on the nodule does not produce any effect on other modules. The system collects separately ways of environment information through each monitoring and control module,and sends it to host PC through the RS485 interface. And in the PC configuration control system, the acquired parameters are compared with the values of setting, then according to a variety of expert intelligent fuzzy control system of crops at different growth stages, the fuzzy control instructions on the environment temperature,humidity,CO2 concentration, soil water content and the corresponding operation instructions or alarm are given.The system is applied in rural greenhouses in Qinhuangdao. Usually at 1/4 near East and West end in a greenhouse, and at the height of 1.5m from the ground in the middle in the northern half (near the wet curtain) and the southern half (near the fan ),a module of air temperature and humidity ,CO2 concentration and a module of soil moisture content are set; a module of soil moisture content will be added in the middle of the greenhouse according to the actual condition; at the height of 1.5m in the main entrance, a water tank is set, of which the solenoid of drip tube should be set based on the need and controlled by module of soil moisture content; and the PC is placed in the main entrance to the greenhouse.III . HARDW ARE DESIGNA.The CP and communication systemIn the distributed system of data acquisition and control, as the micro control unit is limited in data storage and slow in calculating of complex functions, so PC is used and the master-slave module is adopted in the system, that is a system of, taking PC as the host and taking the SCM systems located in the scene as slave.In this distributed system, communication is the key to it. Generally, the serial port of PC is standard RS232,of which transmission distance is shorter. But in agriculture control system. its communication distance is of tens of meters or several kilometers, so RS232/RS485 converter is used to achieve communication between the PC and SCM. To reduce investment, both considering the user convenience and friendly human-computer interaction, low-price PC of above 486 and below PIV is adopted; and considering the operation of configuration software, it is required that memory is 64M or above and hard disk is 10Gb or above.B. The control modules of temperature and humidity, luminance and CO2 concentrationEach control unit consists of SCM, sensors, signal processing circuit,RS485 interface and output circuit. The hardware structure of module of temperature and humidity,CO2 concentration is shown in Fig.2.CO2 concentration is measured by sensor based on NDIR technology, measurement is of 0~2×103mol.Through the sensor, control system, by software of digital filter, linear interpolation and temperature compensation, the CO2 concentration is output as digital adhered to UART protocol, and then is input directly to the SCM.The new intelligent sensor of SHT11 based on Chosen’s technology is chosen in the measurement of temperature and humidity. In SHT11,the temperature and humidity sensors, signal amplification, A/D,I2C bus are all integrated in a chip; it has full-scale calibration, second-line digital output, and humidity measuring range of 0~100% RH, temperature measurement range of -40℃~+123.8℃,humidity measurement accuracy of ±3.0% RH, temperature measurement accuracy of ±0.4℃,the response time of <4s.The luminance sensor of JY1-TBQ-6 of silicon photovoltaic detection is used Light measuring. Its measurement range is 0~200,000 Lox; spectral range is 400~700(nm) visible light; measurement error is less than 2%; output is 4~20mA or 0~20mV;output signal can be directly send to the A/D of the SCM after being amplified to 0~4V.Modules accept the instructions form the the Upper, and output via the output circuit .The output circuit consists of optical isolation, the signal driver and the output relays.C. The measurement and control modules of soil moistureWater is a polar medium, the dielectric constant of the soil containing water is mainly determined by the water, when water content is different, the wave impedance is different. The soil moisture is measured by standing wave radio method in this system.Based on the theory of Engineering Electromagnetic Field ,for flossy medium, the electromagnetic wave impedance as follows:Z0=√μ/ε(1+jλ/(ωε))Where μis medium permeability, and μof soil is μ≈μ0 is the vacuum permeability;εis medium dielectric constant;λis medium conductivity;ωis electromagnetic wave frequency.In the very low audio(<2000Hz),the loss tangent of dry soil dielectric is λ/ωε≈0.07,if you choose the frequency of the signal source at above 20MHz.then,ε≈ε∞,the imaginary part of the soil wave impedance is neglect, only the real part, which amounts to a pure resistance.Soil moisture sensor consists of 100MHz signal source, a coaxial transmission line and a 4-pin stainless probe. The electromagnetic waves of signal transmit to the probe along the lines. As the probe impedance and line impedance are different ,the superimposition of incident waves and reflected waves forms a standing waves.Taking the coaxial transmission line as a lossless uniform line, wave impedance is Z0,Z l is the load impedance.Then the reflected coefficient of voltage wave at the probe is:Γ=(Z L-Z0)/(Z L+Z0)Choosing the length of transmission line is l=λ/4,the maximum and minimum of both ends of the line are U max and U min, Then the standing wave radio in the line can be expressed as: S=U max /U min =(1-|Γ|)/(1+|Γ|)In the way, the soil moisture radio can be measured by measuring the standing wave rate of transmission line.As shown in Fig.3.,soil moisture module consists of sensors and controllers, the sensors are subordinated to controllers, controllers can be omitted without the need of irrigation in greenhouse.To simplify the control, irrigation technology of node-type in partition is adopted in the control soil moisture in this system. To a certain extent, the parameters of upper and lower the ground can be decoupled by adopting this technology.IV CONTROL SYSTEM PROGRAMMINGThe software of PC is developed by King View 6.51 of Beijing-controlled Asia. This configuration software has high reliability, shorter development cycle, perfect capability of graphical interface generation, and friendly human-computer interaction; and can create dynamic images and charts in accordance with the layout of equipment in the scene; can visually display the changes of parameters, control status, and can give an alarm when over-limited; and can achieve fuzzy control of greenhouse parameters by using the history curve of environment parameters stored in the specific database and adopting the agricultural expert system.The software of SCM of the slave is developed by Keil C51 to achieve real-time collecting, processing, uploading of the parameters and accept the fuzzy control instructions from the hostcomputer and complete local control of the device.A.Program design of the control moduleThe software of the sub-slave machine of soil moisture module, that include the main function, subroutines of data acquisition and processing, interrupt handling and communicating etc, read the value of standing wave voltage through the parallel data port and obtained the value of soil moisture content by function calculating.The software of the slave machine of monitoring and control of soil moisture mainly complete data communication with the sub-slave machine, uploading measurement data and current control state to the host computer, accepting the fuzzy control instructions from the host computer and output the implementation instructions.The software of the slave machine of temperature and humidity ,and CO2 mainly complete reading data of CO2 concentrations and temperature and humidity through the I2C concentration, uploading measurement data and current control state to the host computer ,accepting the fuzzy control instructions from the host computer and output the implementation instructions. The structure of the main program and interrupt subroutine of temperature and humidity module are shown in Fig.4.The serial interrupt mode 3 is adopted by all slaves to communicate with the host, transmit the digital collecting and receive instructions.B. Program design of PC and fuzzy control system1)The communication settings of King View 6.51:In order to ensure the correctness of communication, the upper and lower must follow the same communication protocol, set the communication parameters. Usually in communication ,master-slave mode is adopted in style and responder is adopted in the process. That is ,the master sent a command to the slave first, then et slave give an answer after receiving the command, thus once communication is completed.In King View ,a scheduled polling method is adopted to do reading and writing between the lower machine by PC. In the project browser of King View, first, click device →COM1;in the wizard of device configuration, select intelligent modules→SCM→current SCM of HEX→serial port, and then ser parameters for the host computer’s communication.2)The connection of King View 6.51 and database: Database is the core of the software ,that not only contains the definition of variables, real-time parameters and the historical parameters ,but also is needed by parameters alarming, fuzzy calculating, reporting ,and displaying.Access2003 desktop database is used as records database of the system, and by using SQL, it is operated by King View via ODBC. The procedure is :to create data variables in King View to create a body of records to establish a data source of ODBC to create query screens and make the screen connection. To connected with Microsoft Access2003,the functions of SQLConnect(),SQLSelect(),SQLLast(),SQLNext(),SQLFist(),SQLPrew(),SQLInsrt(),and so on, should be implemented in the command language, and then real-time storage and inquiry of data are completed.3)Software design of PC :For the control system of greenhouse, data storage capacity of the PC is unlimited, so if the existing mature software modules are include into the system, it both be relaxed and can improve the system reliability. The software of software consists of control module and management module.Software of the system consists of the main control interface, auxiliary, databases, etc. A typical main interface of monitoring and control of PC is shown in Fig.5.V. CONCLUSIONAccording to the economic bearing capacity of farmer in Qinhuangdao ,with the existing technology of monitoring and control of environment parameters of greenhouse, a master-slave distributed automatic control system of greenhouse environment in which PC is taken as the host computer is developed. The system has following characteristics:1)With the large amount of data storage of PC, fuzzy control expert system is easy of data storage, modification and system upgrading.2)By using King View to develop software of PC, the system reliability is improved, and the development cycle is shorten, and a friendly human-computer interface is get.3)A distributed and modular structure is used in the system, it makes the system maintenance easier and adapts to production needs more. The monitoring and control modules of the slave are connected to the host through the RS485 bus based on needs, then the control of greenhouse in partition or block can be achieved.基于主从分布式新的温室环境参数监测和控制系统根据实际在农村地区的温室环境参数的监测和控制,主从分布式测量和控制系统的设计需要,以其中一台计算机作为主机,该系统由PC、土壤水分测量和控制模块,温度、湿度和控制模块组成。
Design of the Temperature Control System Based on AT89C51ABSTRACTThe principle and functions of the temperature control system based on micro controller AT89C51 are studied, and the temperature measurement unit consists of the 1-Wire bus digital temperature sensor DS18B20. The system can be expected to detect the preset temperature, display time and save monitoring data. An alarm will be given by system if the temperature exceeds the upper and lower limit value of the temperature which can be set discretionarily and then automatic control is achieved, thus the temperature is achieved monitoring intelligently within a certain range. Basing on principle of the system, it is easy to make a variety of other non-linear control systems so long as the software design is reasonably changed. The system has been proved to be accurate, reliable and satisfied through field practice.KEYWORDS: AT89C51; micro controller; DS18B20; temperature1 INTRODUCTIONTemperature is a very important parameter in human life. In the modern society, temperature control (TC) is not only used in industrial production, but also widely used in other fields. With the improvement of the life quality, we can find the TC appliance in hotels, factories and home as well. And the trend that TC will better serve the whole society, so it is of great significance to measure and control the temperature. Based on the AT89C51 and temperature sensor DS18B20, this system controls the condition temperature intelligently. The temperature can be set discretionarily within a certain range. The system can show the time on LCD, and save monitoring data; and automatically control the temperature when the conditiontemperature exceeds the upper and lower limit value. By doing so it is to keep the temperature unchanged. The system is of high anti-jamming, high control precision and flexible design; it also fits the rugged environment. It is mainly used in people's life to improve the quality of the work and life. It is also versatile, so that it can be convenient to extend the use of the system. So the design is of profound importance. The general design, hardware design and software design of the system are covered.1.1 IntroductionThe 8-bit AT89C51 CHMOS microcontrollers are designed to handle high-speed calculations and fast input/output operations. MCS 51 microcontrollers are typically used for high-speed event control systems. Commercial applications include modems, motor-control systems, printers, photocopiers, air conditioner control systems, disk drives, and medical instruments. The automotive industry use MCS 51 microcontrollers in engine-control systems, airbags, suspension systems, and antilock braking systems (ABS). The AT89C51 is especially well suited to applications that benefit from its processing speed and enhanced on-chip peripheral functions set, such as automotive power-train control, vehicle dynamic suspension, antilock braking, and stability control applications. Because of these critical applications, the market requires a reliable cost-effective controller with a low interrupt latency response, ability to service the high number of time and event driven integrated peripherals needed in real time applications, and a CPU with above average processing power in a single package. The financial and legal risk of having devices that operate unpredictably is very high. Once in the market, particularly in mission critical applications such as an autopilot or anti-lock braking system, mistakes are financially prohibitive. Redesign costs can run as high as a $500K, much more if the fix means 2 back annotating it across a product family that share the same core and/or peripheral design flaw. In addition, field replacements ofcomponents is extremely expensive, as the devices are typically sealed in modules with a total value several times that of the component. To mitigate these problems, it is essential that comprehensive testing of the controllers be carried out at both the component level and system level under worst case environmental and voltage conditions. This complete and thorough validation necessitates not only a well-defined process but also a proper environment and tools to facilitate and execute the mission successfully. Intel Chandler Platform Engineering group provides post silicon system validation (SV) of various micro-controllers and processors. The system validation process can be broken into three major parts. The type of the device and its application requirements determine which types of testing are performed on the device.1.2 The AT89C51 provides the following standard features4Kbytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bittimer/counters, a five vector two-level interrupt architecture, a full duple ser-ial port, on-chip oscillator and clock circuitry. In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt sys -tem to continue functioning. The Power-down Mode saves the RAM contents but freezes the oscil–lator disabling all other chip functions until the next hardware reset.1.3Pin DescriptionVCC Supply voltage.GND Ground.Port 0:Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, thepins can be used as high impedance inputs. Port 0 may also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory. In this mode P0 has internal pull ups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pull ups are required during program verification.Port 1:Port 1 is an 8-bit bi-directional I/O port with internal pull ups. The Port 1 output buffers can sink/so -urce four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pull ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 1 also receives the low-order address bytes during Flash programming and verification.Port 2:Port 2 is an 8-bit bi-directional I/O port with internal pull ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal pull ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX@DPTR). In this application, it uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals durin Flash programming and verification.Port 3:Port 3 is an 8-bit bi-directional I/O port with internal pull ups. The Port 3 output buffers can sink/sou -rce four TTL inputs. When 1s are written toPort 3 pins they are pulled high by the internal pull ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull ups.Port 3 also serves the functions of various special features of the AT89C51 as listed below:RST:Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.ALE/PROG:Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped duri-ng each access to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.PSEN:Program Store Enable is the read strobe to external program memory. When theAT89C51 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.EA/VPP:External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin alsreceives the 12-volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP.XTAL1:Input to the inverting oscillator amplifier and input to the internal clock operating circuit.XTAL2 :Output from the inverting oscillator amplifier. Oscillator CharacteristicsXTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 2.There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed. Idle Mode In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. It should be noted that when idle is terminated by a hard ware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory.Power-down ModeIn the power-down mode, the oscillator is stopped, and the instruction that invokes power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power-down mode is terminated. The only exit from power-down is a hardware reset. Reset redefines the SFRS butdoes not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize. The AT89C51 code memory array is programmed byte-by byte in either programming mode. To program any nonblank byte in the on-chip Flash Memory, the entire memory must be erased using the Chip Erase Mode.2 Programming AlgorithmBefore programming the AT89C51, the address, data and control signals should be set up according to the Flash programming mode table and Figure 3 and Figure 4. To program the AT89C51, take the following steps.1. Input the desired memory location on the address lines.2. Input the appropriate data byte on the data lines.3. Activate the correct combination of control signals.4. Raise EA/VPP to 12V for the high-voltage programming mode.5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached. Data Polling: The AT89C51 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written datum on PO.7. Once the write cycle has been completed, true data are valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated.2.1Ready/Busy:The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY.Program Verify:If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that their features are enabled.2.2 Chip Erase:The entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all “1”s. The chip erase operation must be executed before the code memory can be re-programmed.2.3 Reading the Signature Bytes:The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned areas follows.(030H) = 1EH indicates manufactured by Atmel(031H) = 51H indicates 89C51(032H) = FFH indicates 12V programming(032H) = 05H indicates 5V programming2.4 Programming InterfaceEvery code byte in the Flash array can be written and the entire array can be erased by using the appropriate combination of control signals. The write operation cycle is self timed and once initiated, will automatically time itself to completion.A microcomputer interface converts information between two forms. Outside themicrocomputer the information handled by an electronic system exists as a physical signal, but within the program, it is represented numerically. The function of any interface can be broken down into a number of operations which modify the data in some way, so that the process of conversion between the external and internal forms is carried out in a number of steps. An analog-to-digital converter(ADC) is used to convert a continuously variable signal to a corresponding digital form which can take any one of a fixed number of possible binary values. If the output of the transducer does not vary continuously, no ADC is necessary. In this case the signal conditioning section must convert the incoming signal to a form which can be connected directly to the next part of the interface, the input/output section of the microcomputer itself. Output interfaces take a similar form, the obvious difference being that here the flow of information is in the opposite direction; it is passed from the program to the outside world. In this case the program may call an output subroutine which supervises the operation of the interface and performs the scaling numbers which may be needed for digital-to-analog converter(DAC). This subroutine passes information in turn to an output device which produces a corresponding electrical signal, which could be converted into analog form using a DAC. Finally the signal is conditioned(usually amplified) to a form suitable for operating an actuator. The signals used within microcomputer circuits are almost always too small to be connected directly to the outside world”and some kind of interface must be used to translate them to a more appropriate form. The design of section of interface circuits is one of the most important tasks facing the engineer wishing to apply microcomputers. We have seen that in microcomputers information is represented as discrete patterns of bits; this digital form is most useful when the microcomputer is to be connected to equipment which can only be switched on or off, where each bit might represent the state of a switch or actuator. To solve real-world problems, a microcontroller must have more than just a CPU, a program, and a data memory. In addition, it must contain hardware allowing the CPU to access information from the outside world. Once theCPU gathers information and processes the data, it must also be able to effect change on some portion of the outside world. These hardware devices, called peripherals, are the CPU’s window to the outside.The most basic form of peripheral available on microcontrollers is the general purpose I70 port. Each of the I/O pins can be used as either an input or an output. The function of each pin is determined by setting or clearing corresponding bits in a corresponding data direction register during the initialization stage of a program. Each output pin may be driven to either a logic one or a logic zero by using CPU instructions to pin may be viewed (or read.) by the CPU using program instructions. Some type of serial unit is included on microcontrollers to allow the CPU to communicate bit-serially with external devices. Using a bit serial format instead of bit-parallel format requires fewer I/O pins to perform the communication function, which makes it less expensive, but slower. Serial transmissions are performed either synchronously or asynchronously.3 SYSTEM GENERAL DESIGNThe hardware block diagram of the TC is shown in Fig. 1. The system hardware includes the micro controller, temperature detection circuit, keyboard control circuit, clock circuit, Display, alarm, drive circuit and external RAM. Based on the AT89C51, the DS18B20 will transfer the temperature signal detected to digital signal. And the signal is sent to the micro controller for processing. At last the temperature value is showed on the LCD 12232F. These steps are used to achieve the temperature detection. Using the keyboard interface chip HD7279 to set the temperature value, using the micro controller to keep a certain temperature, and using the LCD to show the preset value for controlling the temperature. In addition, the clock chip DS1302 is used to show time and the external RAM 6264 is used to save the monitoring data. An alarm will be given by buzzer in time if the temperature exceeds the upper and lower limit value of the temperature.3.1 HARDWARE DESIGNA. Micro controllerThe AT89C51 is a low-power, high-performance CMOS 8-bit micro controller with 4K bytes of in-system programmable Flash memory. The device is manufactured using At mel’s high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the At mel AT89C51 is a powerful micro controller which provides a highly-flexible and cost-effective solution to many embedded control applications. Minimum system of the micro controller is shown in Fig. 2. In order to save monitoring data, the 6264 is used as an external RAM. It is a static RAM chip, low-power with 8K bytes memory.B. Temperature Detection CircuitThe temperature sensor is the key part in the system. The Dallas DS18B20 is used, which supports the 1-Wire bus interface, and the ON-BOARD Patented is used internally. All the sensor parts and the converting circuit are integrated in integrated circuit like a transistor [1]. Its measure range is -55℃~125 ℃, and the precision between -10℃~85℃is ±0.5℃[2 ,3]. The temperature collected by the DS18B20 is transmitted in the 1-Wire bus way, and this highly raises the system anti-jamming and makes it fit in situ temperature measurement of the rugged environment [4]. There are two power supply ways for the DS18B20. The first is external power supply: the first pin of the DS18B20 is connected to the ground; the second pin serves as signal wire and the third is connected to the power. The second way is parasite power supply [5]. As the parasite power supply will lead to the complexity of the hardware circuit, the difficulty of the software controland the performance degradation of the chip, etc. But the DS18B20(s) can be connected to the I/O port of the micro controller in the external power supply way and it is more popular. Therefore the external power supply is used and the second pin is connected to the pin P1.3 of the AT89S51. Actually, if there are multipoint to be detected, the DS18B20(s) can be connected to the 1-Wire bus. But when the number is over 8, there is a concern to the driving and the more complex software design as well as the length of the 1-Wire bus. Normally it is no more than 50m. To achieve distant control, the system can be designed in to a wireless one to breakthe length limit of the 1-Wire bus [6].C. LCD CircuitThe LCD 12232F is used, which can be used to show characters, temperature value and time, and supply a friendly display interface. The 12232F is a LCD with 8192 128×32 pixels Chinese character database and 128 16×8 pixels A SCII character set graphics. It mainly consists of row drive/column drive and 128×32 full lattice LCD with the function of displaying graphics as well as 7.5×2 Chinese characters. It is in a parallel or serial mode to connect to external CPU [7]. In order to economize the hardware resource, the 12232F should be connected to the AT89S51 in serial mode with only 4 output ports used. The LCD grayscale can be changed by adjusting the variable resistor connected the pin Vlcd of the LCD. CLK is used to transmit serial communication clock. SID is used to transmit serial data. CS is used to enable control the LCD. L+ is used to control the LCD backlight power.D. Clock CircuitThe Dallas DS18B20 is used, which is a high performance, low-power and real-time clock chip with RAM. The DS18B20 serves in the system with calendar clock and is used to monitor the time. The time data is read and processed by the AT89C51 and then displayed by the LCD. Also the time can be adjusted by the keyboard. TheDS18B20 crystal oscillator is set at 32768Hz, and the recommended compensation capacitance is 6pF. The oscillator frequency is lower, so it might be possible not to connect the capacitor, and this would not make a big difference to the time precision. The backup power supply can be connected to a 3.6V rechargeable battery.E. Keyboard Control CircuitThe keyboard interface in the system is driven by the HD7279A which has a +5V single power supply and which is connected to the keyboard and display without using any active-device. According to the basic requirements and functions of the system, only 6 buttons are needed. The system's functions are set by the AT89C51 receiving the entered data. In order to save the external resistor, the 1×6 keyboard is used, and the keyboard codes are defined as: 07H, 0FH, 17H, 1FH, 27H, 2FH. The order can be read out by reading the code instruction. HD7279A is connected to the AT89S51 in serial mode and only 4 ports are need. As shown in Fig. 6, DIG0~DIG5 and DP are respectively the column lines and row line ports of the six keys which achieve keyboard monitoring, decoding and key codes identification.F. Alarm CircuitIn order to simplify the circuit and convenient debugging, a 5V automatic buzzer is used in the alarm circuit [8]. And this make the software programming simplified. As shown in Fig. 7, it is controlled by the PNP transistor 9012 whose base is connected to the pin P2.5 of the AT89C51. When the temperature exceeds the upper and lower limit value, the P2.5 output low level which makes the transistor be on and then an alarm is given by the buzzer.G. Drive CircuitA step motor is used as the drive device to control the temperature. The four-phase and eight-beat pulse distribution mode is used to drive motor and thesimple delay program is used to handle the time interval between the pulses to obtain different rotational speed. There are two output states for the step motor. One: when the temperature is over the upper value, the motor rotates reversely (to low the temperature), while when lower than the lower limit value, the motor rotates normally (to raise the temperature); besides not equals the preset value. Two: when the temperature is at somewhere between the two ends and equals the preset value, the motor stops. These steps are used to achieve the temperature control. In addition, the motor speed can also be adjusted by relative buttons. As shown in Fig. 8, the code data is input through ports A11~A8 (be P2.3~P2.0) of the AT89C51 and inverted output by the inverter 74LS04. Finally it is amplified by the power amplifier 2803A to power the motor.3.2 SOFTWARE DESIGNAccording to the general design requirement and hardware circuit principle of the system, as well as the improvement of the program readability, transferability and the convenient debugging, the software design is modularized. The system flow mainly includes the following 8 steps: POST (Power-on self-test), system initiation, temperature detection, alarm handling, temperature control, clock chip DS18B20 operation, LCD and keyboard operation. The main program flow is shown in Fig. 9. Give a little analysis to the above 8 tasks, it is easy to find out that the last five tasks require the real time operation. But to the temperature detection it can be achieved with timer0 timing 1 second, that is to say temperature detection occurs per second. The system initiation includes global variable definition, RAM initiation, special function register initiation and peripheral equipment initiation. Global variable definition mainly finishes the interface definition of external interface chip connected to the AT89C51, and special definition of some memory units. RAM initiation mainly refers to RAM processing. For example when the system is electrified the time code will be stored in theinternal unit address or the scintillation flag will be cleared. The special function register initiation includes loading the initial value of timer and opening the interrupt. For example, when the system is electrified the timer is initialized. The peripheral equipment initiation refers to set the initial value of peripheral equipment. For example, when the system is electrified, the LCD should be initialized, the start-up display should be called, the temperature conversion command should be issued firstly and the clock chip DS18B20 should also be initialized. The alarm handling is mainly the lowering and the raising of temperature to make the temperature remain with the preset range. When the temperature is between the upper and the lower limit value, it goes to temperature control handling, that is to say the temperature need to be raised or lowered according to the preset value. By doing so make the condition temperature equal to the preset value and hence to reach the temperature target.4 CONCLUSIONThe temperature control system has the advantages of friendly human-computer interaction interface, simple hardware, low cost, high temperature control precision (error in the range of ±1 ℃), convenience and versatility, etc. It c an be widely used in the occasions with -55℃to 125℃range, and there is a certain practical value.温度控制系统的设计摘要研究了基于AT89C51单片机温度控制系统的原理和功能,温度测量单元由单总线数字温度传感器DS18B20构成。
大学毕业论文(设计)外文文献翻译申请学位:工学学士学位院系:学院专业:电子信息工程姓名:学号:指导教师:201x年5月28日大学DS18B20 Digital ThermometerDESCRIPTIONThe DS18B20 Digital Thermometer provides 9 to 12-bit (configurable) temperature readings which indicate the temperature of the device.Information is sent to/from the DS18B20 over a 1-Wire interface, so that only one wire (and ground) needs to be connected from a central microprocessor to a DS18B20. Power for reading, writing, and performing temperature conversions can be derived from the data line itself with no need for an external power source.Because each DS18B20 contains a unique silicon serial number, multiple DS18B20s can exist on the same 1-Wire bus. This allows for placing temperature sensors in many different places. Applications where this feature is useful include HV AC environmental controls, sensing temperatures inside buildings, equipment or machinery, and process monitoring and control.FEATURESUnique 1-Wire interface requires only one port pin for communicationMultidrop capability simplifies distributed temperature sensing applicationsRequires no external componentsCan be powered from data line. Power supply range is 3.0V to 5.5VZero standby power requiredMeasures temperatures from -55°C to+125°C. Fahrenheit equivalent is -67°F to +257°FThermometer resolution is programmable from 9 to 12 bitsConverts 12-bit temperature to digital word in 750 ms (max.)User-definable, nonvolatile temperature alarm settingsAlarm search command identifies and addresses devices whose temperature is outside of programmed limits (temperature alarm condition)Applications include thermostatic controls, industrial systems, consumer products,thermometers, or any thermally sensitivesystem.PIN ASSIGNMENTPIN DESCRIPTIONGND - GroundDQ - Data In/OutVDD - Power Supply V oltageNC - No ConnectDETAILED PIN DESCRIPTIONOVERVIEWThe block diagram of Figure 1 shows the major components of the DS18B20. The DS18B20 has four main data components: 1) 64-bit lasered ROM, 2) temperature sensor, 3) nonvolatile temperature alarm triggers TH and TL. The device derives its power from the 1-Wire communication line by storing energy on an internal capacitor during periods of time when the signal line is high and continues to operate off this power source during the low times of the 1-Wire line until it returns high to replenish the parasite (capacitor) supply. As an alternative, the DS18B20 may also be powered from an external 3 volt - 5.5 volt supply.DS18B20 BLOCK DIAGRAM Figure 1Communication to the DS18B20 is via a 1-Wire port. With the 1-Wire port, the memory and control functions will not be available before the ROM function protocol has been established. The master must first provide one of five ROM function commands: 1) Read ROM, 2) Match ROM, 3) Search ROM, 4) Skip ROM, or 5) Alarm Search. These commands operate on the 64-bit lasered ROM portion of eachdevice and can single out a specific device if many are present on the 1-Wire line as well as indicate to the bus master how many and what types of devices are present. After a ROM function sequence has been successfully executed, the memory and control functions are accessible and the master may then provide any one of the six memory and control function commands.One control function command instructs the DS18B20 to perform a temperature measurement. The result of this measurement will be placed in the DS18B20’s scratch-pad memory, and may be read by issuing a memory function command which reads the contents of the scratchpad memory. The temperature alarm triggers TH and TL consist of 1 byte EEPROM each. If the alarm search command is not applied to the DS18B20, these registers may be used as general purpose user memory. The scratchpad also contains a configuration byte to set the desired resolution of the temperature to digital conversion. Writing TH, TL, and the configuration byte is done using a memory function command. Read access to these registers is through the scratchpad. All data is read and written least significant bit first.1-WIRE BUS SYSTEMThe 1-Wire bus is a system which has a single bus master and one or more slaves. The DS18B20 behaves as a slave. The discussion of this bus system is broken down into three topics: hardware configuration, transaction sequence, and 1-Wire signaling (signal types and timing).HARDWARE CONFIGURATIONThe 1-Wire bus has only a single line by definition; it is important that each device on the bus be able to drive it at the appropriate time. To facilitate this, each device attached to the 1-Wire bus must have open drain or 3-state outputs. The 1-Wire port of the DS18B20 (DQ pin) is open drain with an internal circuit equivalent to that shown in Figure 9. A multidrop bus consists of a 1-Wire bus with multiple slaves attached. The 1-Wire bus requires a pullup resistor ofThe idle state for the 1-Wire bus is high. If for any reason a transaction needs to be suspended, the bus MUST be left in the idle state if the transaction is to resume. Infinite recovery time can occur between bits so long as the 1-Wire bus is in the inactive (high) state during the recovery period. If this does not occur and the bus is left low for more than 480 s, all components on the bus will be reset.HARDWARE CONFIGURATIONTRANSACTION SEQUENCEThe protocol for accessing the DS18B20 via the 1-Wire port is as follows:_ Initialization_ ROM Function Command_ Memory Function Command_ Transaction/DataINITIALIZATIONAll transactions on the 1-Wire bus begin with an initialization sequence. The initialization sequence consists of a reset pulse transmitted by the bus master followed by presence pulse(s) transmitted by the slave(s). The presence pulse lets the bus master know that the DS18B20 is on the bus and is rea dy to operate. For more details, see the “1-Wire Signaling” section.ROM FUNCTION COMMANDSOnce the bus master has detected a presence, it can issue one of the five ROM function commands. All ROM function commands are 8 bits long. A list of these commands follows (refer to flowchart in Figure 5)Read ROM [33h]This command allows the bus master to read the DS18B20’s 8-bit family code, unique 48-bit serial number, and 8-bit CRC. This command can only be used if there is a single DS18B20 on the bus. If more than one slave is present on the bus, a data collision will occur when all slaves try to transmit at the same time (open drain will produce a wired AND result).Match ROM [55h]The match ROM command, followed by a 64-bit ROM sequence, allows the bus master to address a specific DS18B20 on a multidrop bus. Only the DS18B20 that exactly matches the 64-bit ROM sequence will respond to the following memory function command. All slaves that do not match the 64-bit ROM sequence will wait for a reset pulse. This command can be used with a single or multiple devices on the bus.Skip ROM [CCh]This command can save time in a single drop bus system by allowing the bus master to access the memory functions without providing the 64-bit ROM code. If more than one slave is present on the bus and a Read command is issued following the Skip ROM command, data collision will occur on the bus as multiple slaves transmit simultaneously (open drain pulldowns will produce a wired AND result).Search ROM [F0h]When a system is initially brought up, the bus master might not know the number of devices on the 1-Wire bus or their 64-bit ROM codes. The search ROM command allows the bus master to use a process of elimination to identify the 64-bit ROM codes of all slave devices on the bus.Alarm Search [ECh]The flowchart of this command is identical to the Search ROM command. However, the DS18B20 will respond to this command only if an alarm condition has been encountered at the last temperature measurement. An alarm condition is defined as a temperature higher than TH or lower than TL. The alarm condition remains set as long as the DS18B20 is powered up, or until another temperature measurement reveals a non-alarming value. For alarming, the trigger values stored in EEPROM are taken into account. If an alarm condition exists and the TH or TL settings are changed, another temperature conversion should be done to validate any alarm conditions.Example of a ROM SearchThe ROM search process is the repetition of a simple three-step routine: read a bit, read the complement of the bit, then write the desired value of that bit. The bus master performs this simple, three-step routine on each bit of the ROM. After one complete pass, the bus master knows the contents of the ROM in one device. The remaining number of devices and their ROM codes may be identified by additional passes.The following example of the ROM search process assumes four different devices are connected to the same 1-Wire bus. The ROM data of the four devices is as shown:ROM1 00110101...ROM2 10101010...ROM3 11110101...ROM4 00010001...The search process is as follows:1. The bus master begins the initialization sequence by issuing a reset pulse. The slave devices respond by issuing simultaneous presence pulses.2. The bus master will then issue the Search ROM command on the 1-Wire bus.3. The bus master reads a bit from the 1-Wire bus. Each device will respond by placing the value of the first bit of their respective ROM data onto the 1-Wire bus. ROM1 and ROM4 will place a 0 onto the 1-Wire bus, i.e., pull it low. ROM2 and ROM3 will place a 1 onto the 1-Wire bus by allowing the line to stay high. The result is the logical AND of all devices on the line, therefore the bus master sees a 0. The bus master reads another bit. Since the Search ROM data command is being executed,all of the devices on the 1-Wire bus respond to this second read by placing the complement of the first bit of their respective ROM data onto the 1-Wire bus. ROM1 and ROM4 will place a 1 onto the 1-Wire, allowing the line to stay high. ROM2 and ROM3 will place a 0 onto the 1-Wire, thus it will be pulled low. The bus master again observes a 0 for the complement of the first ROM data bit. The bus master has determined that there are some devices on the 1-Wire bus that have a 0 in the first position and others that have a 1. The data obtained from the two reads of the three-step routine have the following interpretations:4. The bus master writes a 0. This deselects ROM2 and ROM3 for the remainder of this search pass,leaving only ROM1 and ROM4 connected to the 1-Wire bus.5. The bus master performs two more reads and receives a 0-bit followed by a 1-bit. Thisindicates that all devices still coupled to the bus have 0s as their second ROM data bit.6. The bus master then writes a 0 to keep both ROM1 and ROM4 coupled.7. The bus master executes two reads and receives two 0-bits. This indicates that both 1-bits and 0-bits exist as the 3rd bit of the ROM data of the attached devices.8. The bus master writes a 0-bit. This deselects ROM1, leaving ROM4 as the only device stillconnected.9. The bus master reads the remainder of the ROM bits for ROM4 and continues to access the part ifdesired. This completes the first pass and uniquely identifies one part on the 1-Wire bus.10. The bus master starts a new ROM search sequence by repeating steps 1 through 7.11. The bus master writes a 1-bit. This decouples ROM4, leaving only ROM1 still coupled.12. The bus master reads the remainder of the ROM bits for ROM1 and communicates to the underlying logic if desired. This completes the second ROM search pass, in which another of the ROMs was found.13. The bus master starts a new ROM search by repeating steps 1 through 3.NOTE:The bus master learns the unique ID number (ROM data pattern) of one 1-Wire device on each ROMSearch operation. The time required to derive the part’s unique ROM code is:The bus master is therefore capable of identifying 75 different 1-Wire devices per second. Single chip brief introduction:The monolithic integrated circuit said that the monolithic micro controller, it is not completes some logical function the chip, but integrates a computer system to a chip on. Summary speaking: A chip has become a computer. Its volume is small, the quality is light, and the price cheap, for the study, the application and the development has provided the convenient condition. At the same time, the study use monolithic integrated circuit is understands the computer principle and the structure best choice.The monolithic integrated circuit interior also uses with the computer function similarmodule, for instance CPU, memory, parallel main line, but also has with the hard disk behave identically the memory component7 what is different is its these part performance is opposite our home-use computer weak many, but the price is also low, generally does not surpass 10 Yuan then Made some control electric appliance one kind with it is not the 'very complex work foot, We use now the completely automatic drum washer, the platoon petti-coat pipe: VCD and so on Inside the electrical appliances may see its form! It is mainly takes the control section the core part.It is one kind of online -like real-time control computer, online -like is the scene control, needs to have the strong antijamming ability, the low cost, this is also and the off-line type computer (for instance home use PC,) main differenceThe monolithic integrated circuit is depending on the procedure, and may revise. Realizes the different function through the different procedure, particularly special unique some functions, this is other component needs to take the very big effort to be able to achieve, some are the flowered big strength is also very difficult to achieve. One is not the very complex function, if develops in the 50s with the US 74 series, or the 60s's CD4000 series these pure hardware do decides, the electric circuit certainly arc a big PCB board ! But if, if succeeded in the 70s with the US puts in the market the series monolithic integrated circuit, the result will have the huge difference. Because only the monolithic integrated circuit compiles through you the procedure may realize the high intelligence, high efficiency, as well as redundant reliabilityThe CPU is the key component of a digital computer. Its purpose is to decode instruction received from memory and perform transfers, arithmetic, logic, and control operations with data stored in internal registers, memory, or I/O interface units. Externally, the CPU provides one or more buses for transferring instructions, data, and control information to and from components connected to it. A microcontroller is present in the keyboard and in the monitor in the generic computer; thus these components are also shaded. In such microcontrollers, the CPU may be quite different from those discussed in this chapter. The word lengths may be short, the number of registers small, and the instruction sets limited. Performance, relatively speaking, is poor, but adequate for the task. Most important, the cost of these microcontrollers is very low, making their use cost effective.Because the monolithic integrated circuit to the cost is sensitive, therefore present occupies the dominant status the software is the most preliminary assembly language7 it was except the binary machine code above the most preliminary language, since why were such preliminary must use?Why high-level did the language already achieve the visualization programming level not to use? The reason is very simple, is the monolithic integrated circuit docs not have home computersuch CPU, and also has not looked like the hard disk such mass memory equipment. Inside even if a visualization higher order language compilation script only then a button, also will achieve several dozens K the sizes! Does not speak anything regarding the home use PC hard disk, but says regarding the monolithic integrated circuit cannot accept. The monolithic integrated circuit in the hardware source aspect's use factor must very Gao Caixing, therefore assembly, although primitive actually massively is using, Same truth, if attains supercomputer's on operating system and the application software home use PC to come up the movement, home use PC could also not withstand.It can be said that the 20th century surmounted three "the electricity" the time, namely the electrical time, the Electronic Age and already entered computer time. However, this kind of computer, usually refers to the personal computer, is called PC machine. It by the main engine, the keyboard, the monitor and so on is composed. Also has a kind of computer, most people actually not how familiar. This kind of computer is entrusts with the intelligence each kind of mechanical monolithic integrated circuit (also to call micro controller). , This kind of computer's smallest system only has used as the name suggests a piece of integrated circuit, then carries on the simple operation and the control. Because its volume is small, usually hides in is accused the machinery "the belly". It in the entire installment, plays is having like the human brains role, it went wrong, the entire installment paralyzed. Now, this kind of monolithic integrated circuit's use domain already very widespread, like the intelligent measuring appliance, the solid work paid by time control, the communication equipment, the guidance system, the domestic electric appliances and so on, Once each product used the monolithic integrated circuit, could get up causes the effect which the product turned to a new generation, often before product range crown by adjective---- ‘intelligence’, like intelligence washer and so on. Now some factory's technical personnel or other extra-curricular electronic exploiter do certain products, are not the electric circuit are too complex, is the function is too simple, and is imitated extremely easily. Investigates its reason, possibly on card, in the product has not used on the monolithic integrated circuit or other programmable logical component.DS18B20 数字温度计描述DS18B20 数字温度计提供9至12位温度读数,指示器件的温度。
Design of the Temperature Control System Based on AT89C51ABSTRACTThe principle and functions of the temperature control system based on micro controller AT89C51 are studied, and the temperature measurement unit consists of the 1-Wire bus digital temperature sensor DS18B20. The system can be expected to detect the preset temperature, display time and save monitoring data. An alarm will be given by system if the temperature exceeds the upper and lower limit value of the temperature which can be set discretionarily and then automatic control is achieved, thus the temperature is achieved monitoring intelligently within a certain range. Basing on principle of the system, it is easy to make a variety of other non-linear control systems so long as the software design is reasonably changed. The system has been proved to be accurate, reliable and satisfied through field practice. KEYWORDS: AT89C51; micro controller; DS18B20; temperature1 INTRODUCTIONTemperature is a very important parameter in human life. In the modern society, temperature control (TC) is not only used in industrial production, but also widely used in other fields. With the improvement of the life quality, we can find the TC appliance in hotels, factories and home as well. And the trend that TC will better serve the whole society, so it is of great significance to measure and control the temperature. Based on the AT89C51 and temperature sensor DS18B20, this system controls the condition temperature intelligently. The temperature can be set discretionarily within a certain range. The system can show the time on LCD, and save monitoring data; and automatically control the temperature when the condition temperature exceeds the upper and lower limit value. By doing so it is to keep the temperature unchanged. The system is of high anti-jamming, high control precision and flexible design; it also fits the rugged environment. It is mainly used in people's life to improve the quality of the work and life. It is also versatile, so that it can be convenient to extend the use of the system. So the design is of profound importance. The general design, hardware design and software design of the system are covered.1.1 IntroductionThe 8-bit AT89C51 CHMOS microcontrollers are designed to handle high-speed calculations and fast input/output operations. MCS 51 microcontrollers are typicallyused for high-speed event control systems. Commercial applications include modems, motor-control systems, printers, photocopiers, air conditioner control systems, disk drives, and medical instruments. The automotive industry use MCS 51 microcontrollers in engine-control systems, airbags, suspension systems, and antilock braking systems (ABS). The AT89C51 is especially well suited to applications that benefit from its processing speed and enhanced on-chip peripheral functions set, such as automotive power-train control, vehicle dynamic suspension, antilock braking, and stability control applications. Because of these critical applications, the market requires a reliable cost-effective controller with a low interrupt latency response, ability to service the high number of time and event driven integrated peripherals needed in real time applications, and a CPU with above average processing power in a single package. The financial and legal risk of having devices that operate unpredictably is very high. Once in the market, particularly in mission critical applications such as an autopilot or anti-lock braking system, mistakes are financially prohibitive. Redesign costs can run as high as a $500K, much more if the fix means 2 back annotating it across a product family that share the same core and/or peripheral design flaw. In addition, field replacements of components is extremely expensive, as the devices are typically sealed in modules with a total value several times that of the component. To mitigate these problems, it is essential that comprehensive testing of the controllers be carried out at both the component level and system level under worst case environmental and voltage conditions. This complete and thorough validation necessitates not only a well-defined process but also a proper environment and tools to facilitate and execute the mission successfully. Intel Chandler Platform Engineering group provides post silicon system validation (SV) of various micro-controllers and processors. The system validation process can be broken into three major parts. The type of the device and its application requirements determine which types of testing are performed on the device.1.2 The AT89C51 provides the following standard features4Kbytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bittimer/counters, a five vector two-level interrupt architecture, a full duple ser-ial port, on-chip oscillator and clock circuitry. In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt sys -tem to continue functioning. The Power-down Mode saves theRAM contents but freezes the oscil–lator disabling all other chip functions until the next hardware reset.1.3Pin DescriptionVCC Supply voltage.GND Ground.Port 0:Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0 may also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory. In this mode P0 has internal pull ups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pull ups are required during program verification.Port 1:Port 1 is an 8-bit bi-directional I/O port with internal pull ups. The Port 1 output buffers can sink/so -urce four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pull ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 1 also receives the low-order address bytes during Flash programming and verification.Port 2:Port 2 is an 8-bit bi-directional I/O port with internal pull ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal pull ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX@DPTR). In this application, it uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals durin Flash programming and verification.Port 3:Port 3 is an 8-bit bi-directional I/O port with internal pull ups. The Port 3 output buffers can sink/sou -rce four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pull ups and can be used as inputs. As inputs, Port3 pins that are externally being pulled low will source current (IIL) because of the pull ups.Port 3 also serves the functions of various special features of the AT89C51 as listed below:RST:Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.ALE/PROG:Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped duri-ng each access to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.PSEN:Program Store Enable is the read strobe to external program memory. When theAT89C51 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.EA/VPP:External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin alsreceives the 12-volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP.XTAL1:Input to the inverting oscillator amplifier and input to the internal clock operating circuit.XTAL2 :Output from the inverting oscillator amplifier. Oscillator CharacteristicsXTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 2.There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through adivide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed. Idle Mode In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. It should be noted that when idle is terminated by a hard ware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory.Power-down ModeIn the power-down mode, the oscillator is stopped, and the instruction that invokes power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power-down mode is terminated. The only exit from power-down is a hardware reset. Reset redefines the SFRS but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize. The AT89C51 code memory array is programmed byte-by byte in either programming mode. To program any nonblank byte in the on-chip Flash Memory, the entire memory must be erased using the Chip Erase Mode.2 Programming AlgorithmBefore programming the AT89C51, the address, data and control signals should be set up according to the Flash programming mode table and Figure 3 and Figure 4. To program the AT89C51, take the following steps.1. Input the desired memory location on the address lines.2. Input the appropriate data byte on the data lines. 3. Activate the correct combination of control signals. 4. Raise EA/VPP to 12V for the high-voltage programming mode. 5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached. Data Polling: The AT89C51 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the writtendatum on PO.7. Once the write cycle has been completed, true data are valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated.2.1Ready/Busy:The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY.Program Verify:If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that their features are enabled.2.2 Chip Erase:The entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all “1”s. The chip erase operation must be executed before the code memory can be re-programmed.2.3 Reading the Signature Bytes:The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned areas follows.(030H) = 1EH indicates manufactured by Atmel(031H) = 51H indicates 89C51(032H) = FFH indicates 12V programming(032H) = 05H indicates 5V programming2.4 Programming InterfaceEvery code byte in the Flash array can be written and the entire array can be erased by using the appropriate combination of control signals. The write operation cycle is self timed and once initiated, will automatically time itself to completion. A microcomputer interface converts information between two forms. Outside the microcomputer the information handled by an electronic system exists as a physical signal, but within the program, it is represented numerically. The function of anyinterface can be broken down into a number of operations which modify the data in some way, so that the process of conversion between the external and internal forms is carried out in a number of steps. An analog-to-digital converter(ADC) is used to convert a continuously variable signal to a corresponding digital form which can take any one of a fixed number of possible binary values. If the output of the transducer does not vary continuously, no ADC is necessary. In this case the signal conditioning section must convert the incoming signal to a form which can be connected directly to the next part of the interface, the input/output section of the microcomputer itself. Output interfaces take a similar form, the obvious difference being that here the flow of information is in the opposite direction; it is passed from the program to the outside world. In this case the program may call an output subroutine which supervises the operation of the interface and performs the scaling numbers which may be needed for digital-to-analog converter(DAC). This subroutine passes information in turn to an output device which produces a corresponding electrical signal, which could be converted into analog form using a DAC. Finally the signal is conditioned(usually amplified) to a form suitable for operating an actuator. The signals used within microcomputer circuits are almost always too small to be connected directly to the outside world”and some kind of interface must be used to translate them to a more appropriate form. The design of section of interface circuits is one of the most important tasks facing the engineer wishing to apply microcomputers. We have seen that in microcomputers information is represented as discrete patterns of bits; this digital form is most useful when the microcomputer is to be connected to equipment which can only be switched on or off, where each bit might represent the state of a switch or actuator. To solve real-world problems, a microcontroller must have more than just a CPU, a program, and a data memory. In addition, it must contain hardware allowing the CPU to access information from the outside world. Once the CPU gathers information and processes the data, it must also be able to effect change on some portion of the outside world. These hardware devices, called peripherals, are the CPU’s window to the outside.The most basic form of peripheral available on microcontrollers is the general purpose I70 port. Each of the I/O pins can be used as either an input or an output. The function of each pin is determined by setting or clearing corresponding bits in a corresponding data direction register during the initialization stage of a program. Each output pin may be driven to either a logic one or a logic zero by using CPUinstructions to pin may be viewed (or read.) by the CPU using program instructions. Some type of serial unit is included on microcontrollers to allow the CPU to communicate bit-serially with external devices. Using a bit serial format instead of bit-parallel format requires fewer I/O pins to perform the communication function, which makes it less expensive, but slower. Serial transmissions are performed either synchronously or asynchronously.3 SYSTEM GENERAL DESIGNThe hardware block diagram of the TC is shown in Fig. 1. The system hardware includes the micro controller, temperature detection circuit, keyboard control circuit, clock circuit, Display, alarm, drive circuit and external RAM. Based on the AT89C51, the DS18B20 will transfer the temperature signal detected to digital signal. And the signal is sent to the micro controller for processing. At last the temperature value is showed on the LCD 12232F. These steps are used to achieve the temperature detection. Using the keyboard interface chip HD7279 to set the temperature value, using the micro controller to keep a certain temperature, and using the LCD to show the preset value for controlling the temperature. In addition, the clock chip DS1302 is used to show time and the external RAM 6264 is used to save the monitoring data. An alarm will be given by buzzer in time if the temperature exceeds the upper and lower limit value of the temperature.3.1 HARDWARE DESIGNA. Micro controllerThe AT89C51 is a low-power, high-performance CMOS 8-bit micro controller with 4K bytes of in-system programmable Flash memory. The device is manufactured using At mel’s high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the At mel AT89C51 is a powerful micro controller which provides a highly-flexible and cost-effective solution to many embedded control applications. Minimum system of the micro controller is shown in Fig. 2. In order to save monitoring data, the 6264 is used as an external RAM. It is a static RAM chip, low-power with 8K bytes memory.B. Temperature Detection CircuitThe temperature sensor is the key part in the system. The Dallas DS18B20 is used, which supports the 1-Wire bus interface, and the ON-BOARD Patented is used internally. All the sensor parts and the converting circuit are integrated in integrated circuit like a transistor [1]. Its measure range is -55℃~125 ℃, and the precision between -10℃~85℃is ±0.5℃[2 ,3]. The temperature collected by the DS18B20 is transmitted in the 1-Wire bus way, and this highly raises the system anti-jamming and makes it fit in situ temperature measurement of the rugged environment [4]. There are two power supply ways for the DS18B20. The first is external power supply: the first pin of the DS18B20 is connected to the ground; the second pin serves as signal wire and the third is connected to the power. The second way is parasite power supply [5]. As the parasite power supply will lead to the complexity of the hardware circuit, the difficulty of the software control and the performance degradation of the chip, etc. But the DS18B20(s) can be connected to the I/O port of the micro controller in the external power supply way and it is more popular. Therefore the external power supply is used and the second pin is connected to the pin P1.3 of the AT89S51. Actually, if there are multipoint to be detected, the DS18B20(s) can be connected to the 1-Wire bus. But when the number is over 8, there is a concern to the driving and the more complex software design as well as the length of the 1-Wire bus. Normally it is no more than 50m. To achieve distant control, the system can be designed in to a wireless one to breakthe length limit of the 1-Wire bus [6].C. LCD CircuitThe LCD 12232F is used, which can be used to show characters, temperature value and time, and supply a friendly display interface. The 12232F is a LCD with 8192 128×32 pixels Chinese character database and 128 16×8 pixels ASCII character set graphics. It mainly consists of row drive/column drive and 128×32 full lattice LCD with the function of displaying graphics as well as 7.5×2 Chinese characters. It is in a parallel or serial mode to connect to external CPU [7]. In order to economize the hardware resource, the 12232F should be connected to the AT89S51 in serial mode with only 4 output ports used. The LCD grayscale can be changed by adjusting the variable resistor connected the pin Vlcd of the LCD. CLK is used to transmit serial communication clock. SID is used to transmit serial data. CS is used to enable control the LCD. L+ is used to control the LCD backlight power.D. Clock CircuitThe Dallas DS18B20 is used, which is a high performance, low-power and real-time clock chip with RAM. The DS18B20 serves in the system with calendar clock and is used to monitor the time. The time data is read and processed by the AT89C51 and then displayed by the LCD. Also the time can be adjusted by the keyboard. The DS18B20 crystal oscillator is set at 32768Hz, and the recommended compensation capacitance is 6pF. The oscillator frequency is lower, so it might be possible not to connect the capacitor, and this would not make a big difference to the time precision. The backup power supply can be connected to a 3.6V rechargeable battery.E. Keyboard Control CircuitThe keyboard interface in the system is driven by the HD7279A which has a +5V single power supply and which is connected to the keyboard and display without using any active-device. According to the basic requirements and functions of the system, only 6 buttons are needed. The system's functions are set by the AT89C51 receiving the entered data. In order to save the external resistor, the 1×6 keyboard is used, and the keyboard codes are defined as: 07H, 0FH, 17H, 1FH, 27H, 2FH. The order can be read out by reading the code instruction. HD7279A is connected to the AT89S51 in serial mode and only 4 ports are need. As shown in Fig. 6, DIG0~DIG5 and DP are respectively the column lines and row line ports of the six keys which achieve keyboard monitoring, decoding and key codes identification.F. Alarm CircuitIn order to simplify the circuit and convenient debugging, a 5V automatic buzzer is used in the alarm circuit [8]. And this make the software programming simplified. As shown in Fig. 7, it is controlled by the PNP transistor 9012 whose base is connected to the pin P2.5 of the AT89C51. When the temperature exceeds the upper and lower limit value, the P2.5 output low level which makes the transistor be on and then an alarm is given by the buzzer.G. Drive CircuitA step motor is used as the drive device to control the temperature. The four-phase and eight-beat pulse distribution mode is used to drive motor and the simple delay program is used to handle the time interval between the pulses to obtain different rotational speed. There are two output states for the step motor. One: when the temperature is over the upper value, the motor rotates reversely (to low the temperature), while when lower than the lower limit value, the motor rotates normally(to raise the temperature); besides not equals the preset value. Two: when the temperature is at somewhere between the two ends and equals the preset value, the motor stops. These steps are used to achieve the temperature control. In addition, the motor speed can also be adjusted by relative buttons. As shown in Fig. 8, the code data is input through ports A11~A8 (be P2.3~P2.0) of the AT89C51 and inverted output by the inverter 74LS04. Finally it is amplified by the power amplifier 2803A to power the motor.3.2 SOFTW ARE DESIGNAccording to the general design requirement and hardware circuit principle of the system, as well as the improvement of the program readability, transferability and the convenient debugging, the software design is modularized. The system flow mainly includes the following 8 steps: POST (Power-on self-test), system initiation, temperature detection, alarm handling, temperature control, clock chip DS18B20 operation, LCD and keyboard operation. The main program flow is shown in Fig. 9. Give a little analysis to the above 8 tasks, it is easy to find out that the last five tasks require the real time operation. But to the temperature detection it can be achieved with timer0 timing 1 second, that is to say temperature detection occurs per second. The system initiation includes global variable definition, RAM initiation, special function register initiation and peripheral equipment initiation. Global variable definition mainly finishes the interface definition of external interface chip connected to the AT89C51, and special definition of some memory units. RAM initiation mainly refers to RAM processing. For example when the system is electrified the time code will be stored in the internal unit address or the scintillation flag will be cleared. The special function register initiation includes loading the initial value of timer and opening the interrupt. For example, when the system is electrified the timer is initialized. The peripheral equipment initiation refers to set the initial value of peripheral equipment. For example, when the system is electrified, the LCD should be initialized, the start-up display should be called, the temperature conversion command should be issued firstly and the clock chip DS18B20 should also be initialized. The alarm handling is mainly the lowering and the raising of temperature to make the temperature remain with the preset range. When the temperature is between the upper and the lower limit value, it goes to temperature control handling, that is to say the temperature need to be raised or lowered according to the preset value. By doing so make the condition temperature equal to the preset value and hence to reach thetemperature target.4 CONCLUSIONThe temperature control system has the advantages of friendly human-computer interaction interface, simple hardware, low cost, high temperature control precision (error in the range of ±1 ℃), convenience and versatility, etc. It can be widely used in the occasions with -55℃to 125℃range, and there is a certain practical value.。
基于单片机的多功能温度检测系统的设计一、引言随着社会的发展和技术的进步,人们越来越注重温度检测与显示的重要性。
温度检测与状态显示技术与设备已经普遍应用于各行各业,市场上的产品层出不穷。
温度检测及显示也逐渐采用自动化控制技术来实现监控。
本课题就是一个温度检测及状态显示的监控系统。
二、系统方案本系统采用 AT89S52 作为该系统的单片机。
系统整体硬件电路包括,电源电路,传感器电路,温度显示电路,上下限报警电路等如图1 所示。
图中报警电路可以在被测温度不在上下限范围内时,发出报警鸣叫声音。
温度控制的基本原理为:当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)可用数据线供电,电压范围从3.0V 到5.5V。
(5)可测量的温度范围从-55℃到+125℃,增量值0. 5℃;华氏温度范围从-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 当前的温度、温度数据转化成液晶字符显示等程序。
五、小结随着工业的不断发展,对温度测量的要求来越高,而且测量范围也越来越广,因此对温度检测技术的要求也越来越高。
本文介绍了以DSl8B20 新型数字温度传感器、AT89S52 单片机、LCD1602 液晶显示模块为主体构建的温度检测显示系统。
说明了系统硬件电路、系统主程序与各模块子程序的设计。
本系统采用的是DALLAS 公司推出的数字式温度传感器DS18B20,无需外加A/D 即可输出数字量,把温度信号直接转换成串行数字信号供微机处理。
因此。
该系统具有硬件电路结构简单、转换精度高、显示结果清晰稳定、成本低等显着优点。
在诸如粮库测温、智能建筑、中央空调等多种需要温度检测的场合具有较好的应用前景。
Based on SCM multi-functional temperature testingsystem design1、prefaceWith 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 solutionsThis 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 diagram3、The system hardware design(1)AT89S52 SCM are introducedAT89S52 devices is a low power consumption, high CMOS8 bit micro-controller, 8K programmable Flash memory. Use Atmel company high-density nonvolatile storage technology, and industrial 80C51 product instruction and pin fully compatible. 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 candrop 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 DS18B20In the traditional analog signal distance temperature measuring system, need good solve lead error compensation, 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, compared 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 communication. (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 workThe 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 compensation and fixed temperature measurement, the output of the process of nonlinear correction is less than the preset value counter l.②.AT89S52 interface mode and DS18B20Chip 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 coming 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, composed 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 LCD1602 LCD module can and monolithic integrated circuit AT89S52 directly interface.(4)Buzzer driver circuitDue to the working current buzzer is compared commonly 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 circuitWhen 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 command, 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 systemThis 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 compared 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、SummaryWith 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 microcomputer. 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.。