1、智能温度报警系统 摘要:摘要:随着时代的进步和发展,单片机技术已经普及到我们生活,工作,科研, 各个领域,已经成为一种比较成熟的技术,本文将介绍一种基于单片机控制的数 字温度计,本温度计属于多功能温度计,可以设置上下报警温度,当温度不在设 置范围内时,可以报警。 关键词:关键词:单片机,数字控制,温度计, DS18B20,AT89S51 ABSTRACT Along with the progress and developments of the ages, a machine technique has already make widely available we are living
2、, work, the research, each realm, has already become a kind of to compare the mature technique, this text will introduce a kind of numerical thermometer that controls according to a machine, this thermometer belongs to the multi-function thermometer, can establish the top and bottom to report to the
3、 police the temperature, being the temperature not within the scope of establish, can report to the police. Key Word: numeral control, thermometer,DS18B20,AT89S52 引言引言 随着人们生活水平的不断提高,单片机控制无疑是人们追求的目标之一,它 所给人带来的方便也是不可否定的,其中数字温度计就是一个典型的例子,但人 们对它的要求越来越高,要为现代人工作、科研、生活、提供更好的更方便的设 施就需要从数单片机技术入手,一切向着数字化控制,智能
4、化控制方向发展。 本设计所介绍的数字温度计与传统的温度计相比,具有读数方便,测温范围 广,测温准确,其输出温度采用数字显示,主要用于对测温比较准确的场所,或 科研实验室使用, 该设计控制器使用单片机AT89S51, 测温传感器使用DS18B20, 用 3 位共阳极 LED 数码管以串口传送数据,实现温度显示,能准确达到以上要求。 智能温度报警系统: 主要参数主要参数 序号 参数 数值 备注 1 工作电压 4V6V 直流 2 功率 1); return (dat); void tmwbyte (unsigned char dat) /写一个字节写一个字节 unsigned char j,i; b
5、it testb; for (j=1;j 1; if (testb) TMDAT = 0; /写写 0 i+; i+; TMDAT = 1; for(i=0;i8;i+); else TMDAT = 0; /写写 0 for(i=0;i0x7f) /最高位为最高位为 1 时温度是负时温度是负 a=a; b=b+1; /补码转换,取反加一补码转换,取反加一 fg=0; /读取温度为负时读取温度为负时 fg=0 sdata = a/16+b*16; /整数部分整数部分 xiaoshu1 = (a /小数第一位小数第一位 xiaoshu2 = (a/小数小数 xiaoshu=xiaoshu1*10+
6、xiaoshu2; /小数小数 void DS18B20PRO(void) tmstart(); /yanshi(5); /如果是不断地读取的话可以不延如果是不断地读取的话可以不延 tmrtemp(); /读取温度读取温度,执行完毕温度将存于执行完毕温度将存于 void Led() if(fg=1) /温度为正时显示的数据温度为正时显示的数据 P2=P2 P0=seg7codesdata/10; /输输 Delay(2); P2=P2|0xf0; P2=P2 P0=seg7codesdata%10|0x80; /输出个输出个 Delay(2); P2=P2|0xf0; P2=P2 P0=seg7codexiaoshu1; /输出小数点输出小数点 Delay(2); P2=P2|0xf0; P2=P2 P0=seg7codexiaoshu2; /输出小输出小 Delay(1); P2=P2|0xf0; Delay(2); P2=P2|0xf0;P2=P2 P0=