毕业设计-小型孵化箱的温湿度控制系统_第1页
毕业设计-小型孵化箱的温湿度控制系统_第2页
毕业设计-小型孵化箱的温湿度控制系统_第3页
毕业设计-小型孵化箱的温湿度控制系统_第4页
毕业设计-小型孵化箱的温湿度控制系统_第5页
已阅读5页,还剩103页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、山东科技大学学士学位论文 摘要摘要 孵化设备是养禽业的重要设备。它是根据仿生学原理人工模拟禽类孵化条件的一种设备。在众多孵化条件中,温度与湿度十分重要。本设计主要是对小型孵化机的温度湿度控制进行研究。 本论文首先介绍了孵化所需温湿度条件以及国内外孵化温湿度控制系统的现状及发展方向。参考孵化行业的技术标准确定了本系统的设计指标。本设计以AT89C51为控制核心,温度采集传感器选用数字式单总线温度传感器DS18B20;湿度采集传感器采用HS1101型电容式传感器,利用其搭建频率电路检测孵化箱内的湿度;利用以T6963为主控芯片的12864液晶屏实时显示孵化箱内现场状态;利用日历芯片DS1320准确

2、记录孵化时间;利用E2PROM芯片AT24C02来存储设定温度湿度的改变,进行掉电保护等。利用Keil uVision4软件编译了驱动单片机运行的C语言程序,并与Proteus软件进行联调仿真,验证设计的可行性。 关键词:单片机,孵化机,温湿度控制 山东科技大学学士学位论文 摘要 ABSTRACT The incubation equipment is an important device in thepoultryindustry. It is a bionic device that creates the environment about hatching where manual

3、control is desired. The temperature and humidity control is particularly important in the numerous incubation conditions. Therefore, amajortheme inresearchhere isthat control of temperature and humidity about small incubator.This article describes the knowledge of the incubator, the situation and de

4、velopment direction of the incubation equipment at home and abroad, and the hatch principles and conditions, and with reference to the incubation industry technical standards to determine the design of the system indicators. The intelligent control system is mainly composed of single-chip AT89C51, D

5、S18B20 digital temperature sensor, which is through single bus. The humidity sensor is the relative humidity sensor HS1101, it is used to build frequency circuits for measuring the precise humidity values in time.LCD12864 using T6963 as main control chip is used for the actual state monitor and diag

6、nosis. In order to recording the time, this article uses the DS1302 trickle charge time keeping chip. The difference in humidity and temperature are stored in AT24C02, protected in the case of electricity loss. For proving the feasibility, C language SCM process is wrote by the Keil uVision4 softwar

7、e and the simulation and analysis tools that Proteus software is used.Keywords: Microcontroller, Incubator, Temperature and humidity control山东科技大学学士学位论文 目录附录附录1:主电路图PCB板 附录2:电路图附录3:仿真电路图附录4:主程序/*作品:小型孵化机的温度湿度控制系统 * 功能描述:单片机驱动12864进行温度湿度的显示 (主程序)* 输入: * 液晶:Proteus元件库PG12864(T6963C驱动) * 输出: * 全局变量:* 调

8、用模块: * 作者: 魏世琳* 日期: 15.4.15备注:从现在开始对项目进行模块化,第n次改程序希望一切顺利!*/#include#include12864.c#includeds18b20.c#includeat24c02.c#includeds1302.c#define uchar unsigned char#define uint unsigned int /宏义sbit key1=P25;sbit key2=P26;sbit key3=P27;sbit key4=P33;sbit key5=P32;sbit buzzer=P36;sbit led_red=P37;sbit moto

9、r0=P34; sbit motor1=P14;sbit fengji1=P30;bit flag5=0; /flag5是外部中断1的标志位uchar two=0;uchar first=0; uint dat; bit one=0;uchar key1n=0;uchar key2n=0;uchar da8;uchar tem0=0 , tem1=0; uchar temp0=0 , temp1=0,temp2=0,temp3=0; uint f=0; /初值 uchar cp=0;long shidu;uchar bao=0;extern uchar wendu4;extern uchar

10、fg1;extern uchar Data50;extern uchar temperature2;extern unsigned char second,minute,hour,day;/秒、分、时 、日/* 函数名称: void INT_1() interrupt 2* 功能描述: 开始确认暂停键的判断 * 输入: * 输出: /*/ void INT_1() interrupt 2 if(!flag5) if(key4=0) /2为加键 delaynms(10);/延时,消抖动if(key4=0) two=1; flag5=1;P1=0X7F; else if(key4=0) /2为加键

11、 delaynms(10);/延时,消抖动if(key4=0) two=1;fengji1=1;led_red=1;buzzer=1; motor1=1;motor0=1; flag5=0;P1=0XFF; /* 函数名称: void INT_0() interrupt 0* 功能描述: 确定键 * 输入: * 输出: /*/ void INT_0() interrupt 0 if(flag5=1) if(key5=0) /2为加键 delaynms(20);/延时,消抖动if(key5=0) key1n=0; key2n=0; one=0; F12864_clear(); /* * 名称:

12、timer0() * 功能: 定时器1,每50000us中断一次。 * 入口参数: */ void timer0() interrupt 1 EA =0; TR0=0; TH0=(65536-46080)/256;/ 由于晶振为11.0592,故所记次数应为46080,计时器每隔50000微秒发起一次中断。TL0=(65536-46080)%256;/46080的来历,为50000*11.0592/12cp+;if(cp=20) TR1=0; cp=0; tem0 = TL1; /读数 tem1 = TH1; f=1; /作标注位 TL1=0 x00; /定时器1清零 TH1=0 x00; T

13、R1=1; TR0=1; EA=1; elseTR0=1; EA=1; /* * 名称: timer1() * 功能: 计数器,用于计数将555输出的频率,以计数相对湿度。 * 入口参数: * void timer1() interrupt 3 /T1中断,表示计数的频率溢出,超出了可测量的频率范围,显然在这里不可能。所以重新启动。 EA =0; TR0=0; TR1=0;TH0=(65536-46080)/256;/ 由于晶振为11.0592,故所记次数应为46080,计时器每隔50000微秒发起一次中断。TL0=(65536-46080)%256;/46080的来历,为50000*11.0

14、592/12 TL1=0 x00; /定时器1清零 TH1=0 x00;TR0=1; TR1=1; EA=1; /* * 名称:void tran() * 功能:湿度转换* 入口参数: */ void tran() f = tem1; f = ( f8 ) | tem0; if( 365= f)&( f=445) )/相对湿度在有效范围内(0100%) shidu=-1.2621*f+562.71; /线性转换 temp3 = (shidu*10)%10; temp2 = shidu%10;temp1 = shidu/10;temp0 = shidu/100; /十六进制转十进制 else t

15、emp0 = 0; temp1 = 0; temp2=0;temp3=0; void shiliuzshi(uchar tep) da1=tep/16;da0=tep%16;/* 函数名称: void Tiaojie()* 功能描述: 系统调节 * 输入: * 输出: */void Tiaojie() uint data1,data2,data3,temperture; uint data4,data5,data6,tem; delaynms(2); DuquData(11); delaynms(2); DuquData(12);/读取AT24C02中的设定值 data1=(Data118)|

16、Data12;/十六进制 data2=data1-4;/低温调节值设定温度减0.4 data3=data1+1;/高温设定温度家0.1 temperture=(temperature18)|temperature0; if(temperturedata3) motor0=1; delaynms(2); DuquData(9); delaynms(2); DuquData(10); data4=(Data98)|Data10; data5=data4-4;/高于湿度设定值5% data6=data4+7;/低于湿度设定值10% tem=(tem1data6) motor1=0; if(temDa

17、ta1) buzzer=0;/蜂鸣器响 led_red=0;else if(Data1=temperature1) delaynms(2); DuquData(2); if(temperature0Data2) buzzer=0;/蜂鸣器响 led_red=0; delaynms(10); else buzzer=1;/蜂鸣器不响 led_red=1; else buzzer=1;/蜂鸣器不响 led_red=1; void Alarm_shidu2() delaynms(2); DuquData(6); if(tem0Data6) buzzer=0;/蜂鸣器响 led_red=0; dela

18、ynms(20); else buzzer=1;/蜂鸣器不响 led_red=1; delaynms(20); void Alarm() Alarm_shidu2(); Alarm_wendu1();/* 函数名称: void Display_temperture(void)* 功能描述: 温湿度在液晶上显示 * 输入: wendu4 * 输出: */void Display_temperture(void) uchar i; wenshiduxianshi();Read_Temp();display(); if(fg1=1)dprintf_shuzi_string_1(GB_8,7,0,14

19、,13);fg1=0;else dprintf_shuzi_string_1(GB_8,7,0,1+wendu0,0+wendu0); for(i=1;i3;i+) dprintf_shuzi_string_1(GB_8,7+i,0,1+wendui,0+wendui); display_string(10,1,.); dprintf_shuzi_string_1(GB_8,11,0,1+wendu3,0+wendu3);delaynms(2); tran();dprintf_shuzi_string_1(GB_8,7,16,1+temp0,0+temp0);dprintf_shuzi_str

20、ing_1(GB_8,8,16,1+temp1,0+temp1);dprintf_shuzi_string_1(GB_8,9,16,1+temp2,0+temp2);display_string(10,3,.);dprintf_shuzi_string_1(GB_8,11,16,1+temp3,0+temp3);read_time();shiliuzshi(day);dprintf_shuzi_string_1(GB_8,0,48,1+da1,0+da1); dprintf_shuzi_string_1(GB_8,1,48,1+da0,0+da0);shiliuzshi(hour);dprin

21、tf_shuzi_string_1(GB_8,4,48,1+da1,0+da1);dprintf_shuzi_string_1(GB_8,5,48,1+da0,0+da0); shiliuzshi(minute);dprintf_shuzi_string_1(GB_8,8,48,1+da1,0+da1);dprintf_shuzi_string_1(GB_8,9,48,1+da0,0+da0);shiliuzshi(second);dprintf_shuzi_string_1(GB_8,12,48,1+da1,0+da1);dprintf_shuzi_string_1(GB_8,13,48,1

22、+da0,0+da0); /* 函数名称: void Regulation_temperture(void)* 功能描述: 显示温湿度报警值 * 输入: * 输出: */void Regulation_temperture(void)dprintf_hanzi_string_2(GB_16,5,0,47,44); /报警值dprintf_hanzi_string_2(GB_16,2,32,32,30); /温度display_string(6,5,:);delaynms(2);DuquData(1); temperature1=Data1;delaynms(2);DuquData(2);tem

23、perature0=Data2; delaynms(2);display();dprintf_shuzi_string_1(GB_8,7,32,1+wendu1,0+wendu1);dprintf_shuzi_string_1(GB_8,8,32,1+wendu2,0+wendu2);display_string(9,5,.);dprintf_shuzi_string_1(GB_8,10,32,1+wendu3,0+wendu3);dprintf_hanzi_string_2(GB_16,12,32,30,29);dprintf_hanzi_string_2(GB_16,2,48,38,36)

24、; /湿度display_string(6,7,:); delaynms(2); DuquData(5); tem1=Data5; delaynms(2); DuquData(6); tem0=Data6; delaynms(2); tran();dprintf_shuzi_string_1(GB_8,7,48,1+temp1,0+temp1);dprintf_shuzi_string_1(GB_8,8,48,1+temp2,0+temp2); dprintf_shuzi_string_1(GB_8,10,48,13,12);dprintf_shuzi_string_1(GB_8,11,48,

25、11,10); dprintf_shuzi_string_1(GB_8,12,48,12,11); /* 函数名称: void baojings(void)* 功能描述:报警值 * 输入: * 输出: */void baojings(void) uint baojing1,baoj1,baoj11;uchar baojing2,baojing3,baojing4,baojing5,baoj2,baoj3,baoj4,baoj5; delaynms(2); DuquData(11); delaynms(2); DuquData(12);baojing1=Data12|(Data118)&0 xf

26、f; CunchuData(1,baojing3);baojing4=(baojing1-0 x18)&0 xff; CunchuData(4,baojing4);baojing5=(baojing1-0 x18)8)&0 xff; CunchuData(3,baojing5); delaynms(2); DuquData(9); delaynms(2); DuquData(10); delaynms(2); baoj11=baoj1=Data10|(Data98)&0 xff; CunchuData(5,baoj3); delaynms(2); baoj4=(baoj11+12)&0 xff

27、; CunchuData(8,baoj4); baoj5=(baoj11+12)8)&0 xff; CunchuData(7,baoj5); /* 函数名称: void Best_tempandhum(void)* 功能描述: 选择最佳温度,湿度 * 输入: * 输出: */void fanyejianwen() delaynms(2); DuquData(11); temperature1=Data11; delaynms(2); DuquData(12); temperature0=Data12;display(); delaynms(2); dprintf_hanzi_string_2(

28、GB_16,4,0,51,49); /设定 dprintf_hanzi_string_2(GB_16,8,0,32,30); /温度 display_string(9,1,:);display_string(7,5,.);dprintf_hanzi_string_2(GB_16,10,32,30,29);dprintf_shuzi_string_1(GB_8,5,32,1+wendu1,0+wendu1);dprintf_shuzi_string_1(GB_8,6,32,1+wendu2,0+wendu2); dprintf_shuzi_string_1(GB_8,8,32,1+wendu3,

29、0+wendu3);void fanyejianshi() delaynms(2); DuquData(9); tem1=Data9; delaynms(2); DuquData(10); tem0=Data10; delaynms(2); tran(); dprintf_hanzi_string_2(GB_16,4,0,51,49); /设定 dprintf_hanzi_string_2(GB_16,8,0,38,36); /湿度 display_string(9,1,:); display_string(7,5,.); dprintf_shuzi_string_1(GB_8,10,32,1

30、3,12); dprintf_shuzi_string_1(GB_8,11,32,11,10); dprintf_shuzi_string_1(GB_8,12,32,12,11); dprintf_shuzi_string_1(GB_8,5,32,1+temp1,0+temp1); dprintf_shuzi_string_1(GB_8,6,32,1+temp2,0+temp2); dprintf_shuzi_string_1(GB_8,8,32,1+temp3,0+temp3); /* 函数名称: void Tiaojie_Best(void)* 功能描述: 调节最佳温度,湿度 * 输入:

31、* 输出: */void Tiaojie_Best(void) if(key1n=1) dprintf_hanzi_string_2(GB_16,4,0,51,49); /设定 dprintf_hanzi_string_2(GB_16,8,0,32,30); /温度 display_string(9,1,:);display_string(7,5,.);dprintf_hanzi_string_2(GB_16,10,32,30,29); switch(key2n)case 1:FBshuzi_string_1(GB_8,5,32,1+wendu1,0+wendu1);dprintf_shuzi

32、_string_1(GB_8,6,32,1+wendu2,0+wendu2); dprintf_shuzi_string_1(GB_8,8,32,1+wendu3,0+wendu3); break;case 2:dprintf_shuzi_string_1(GB_8,5,32,1+wendu1,0+wendu1);dprintf_shuzi_string_1(GB_8,8,32,1+wendu3,0+wendu3);FBshuzi_string_1(GB_8,6,32,1+wendu2,0+wendu2);break;case 3:dprintf_shuzi_string_1(GB_8,5,3

33、2,1+wendu1,0+wendu1);dprintf_shuzi_string_1(GB_8,6,32,1+wendu2,0+wendu2); FBshuzi_string_1(GB_8,8,32,1+wendu3,0+wendu3);break; default:break; if(key1n=2) dprintf_hanzi_string_2(GB_16,4,0,51,49); /设定 dprintf_hanzi_string_2(GB_16,8,0,38,36); /湿度 display_string(9,1,:); display_string(7,5,.); dprintf_sh

34、uzi_string_1(GB_8,10,32,13,12); dprintf_shuzi_string_1(GB_8,11,32,11,10); dprintf_shuzi_string_1(GB_8,12,32,12,11); switch(key2n) case 1: FBshuzi_string_1(GB_8,5,32,1+temp1,0+temp1); dprintf_shuzi_string_1(GB_8,6,32,1+temp2,0+temp2); dprintf_shuzi_string_1(GB_8,8,32,1+temp3,0+temp3); break; case 2:

35、dprintf_shuzi_string_1(GB_8,5,32,1+temp1,0+temp1); FBshuzi_string_1(GB_8,6,32,1+temp2,0+temp2); dprintf_shuzi_string_1(GB_8,8,32,1+temp3,0+temp3); break; default:break; /* 函数名称: void Tiaojie_wendu(void)* 功能描述: 调节报警值温湿度 * 输入: * 输出: */void Tiaojie_wendu1(void) if(bao=0) baojings();/若不调用本函数,报警值默认为设定温度值

36、加1.5,湿度值加 15%RH if(bao=5) bao=1; if(key1n=3) bao+; /调用本函数,报警值设定将改变 dprintf_hanzi_string_2(GB_16,5,0,47,44); /报警值dprintf_hanzi_string_2(GB_16,2,32,32,30); /温度 display_string(6,5,:); delaynms(2); DuquData(1); temperature1=Data1; delaynms(2); DuquData(2); temperature0=Data2; delaynms(2); display(); /十六

37、进制转十进制 display_string(9,5,.);dprintf_hanzi_string_2(GB_16,12,32,30,29);dprintf_hanzi_string_2(GB_16,2,48,38,36); /湿度display_string(6,7,:);delaynms(2); DuquData(5); tem1=Data5; delaynms(2); DuquData(6); tem0=Data6; delaynms(2); tran(); dprintf_shuzi_string_1(GB_8,10,48,13,12); dprintf_shuzi_string_1(

38、GB_8,11,48,11,10); dprintf_shuzi_string_1(GB_8,12,48,12,11);switch(key2n)case 1:FBshuzi_string_1(GB_8,7,32,1+wendu1,0+wendu1);dprintf_shuzi_string_1(GB_8,8,32,1+wendu2,0+wendu2); dprintf_shuzi_string_1(GB_8,10,32,1+wendu3,0+wendu3);dprintf_shuzi_string_1(GB_8,7,48,1+temp1,0+temp1); dprintf_shuzi_str

39、ing_1(GB_8,8,48,1+temp2,0+temp2); break;case 2:dprintf_shuzi_string_1(GB_8,7,32,1+wendu1,0+wendu1);dprintf_shuzi_string_1(GB_8,10,32,1+wendu3,0+wendu3);FBshuzi_string_1(GB_8,8,32,1+wendu2,0+wendu2);dprintf_shuzi_string_1(GB_8,7,48,1+temp1,0+temp1); dprintf_shuzi_string_1(GB_8,8,48,1+temp2,0+temp2);b

40、reak;case 3:dprintf_shuzi_string_1(GB_8,7,32,1+wendu1,0+wendu1);dprintf_shuzi_string_1(GB_8,8,32,1+wendu2,0+wendu2); FBshuzi_string_1(GB_8,10,32,1+wendu3,0+wendu3); dprintf_shuzi_string_1(GB_8,7,48,1+temp1,0+temp1); dprintf_shuzi_string_1(GB_8,8,48,1+temp2,0+temp2);break;case 4:FBshuzi_string_1(GB_8

41、,7,48,1+temp1,0+temp1); dprintf_shuzi_string_1(GB_8,8,48,1+temp2,0+temp2); dprintf_shuzi_string_1(GB_8,7,32,1+wendu1,0+wendu1); dprintf_shuzi_string_1(GB_8,8,32,1+wendu2,0+wendu2); dprintf_shuzi_string_1(GB_8,10,32,1+wendu3,0+wendu3);break;case 5:dprintf_shuzi_string_1(GB_8,7,48,1+temp1,0+temp1); FB

42、shuzi_string_1(GB_8,8,48,1+temp2,0+temp2); dprintf_shuzi_string_1(GB_8,7,32,1+wendu1,0+wendu1); dprintf_shuzi_string_1(GB_8,8,32,1+wendu2,0+wendu2); dprintf_shuzi_string_1(GB_8,10,32,1+wendu3,0+wendu3);break; /* 函数名称: void Add_wendu()* 功能描述: 温度加减 * 输入: * 输出: */void Add_wendu1(uchar i,uchar j) delayn

43、ms(30);wendu1+;if(wendu1=10)wendu1=0; FBshuzi_string_1(GB_8,i,j,wendu1+1,wendu1);/对温度十位进行加操作void Add_wendu2(uchar i,uchar j) delaynms(30); wendu2+ ; if(wendu2=10)wendu2=0; FBshuzi_string_1(GB_8,i,j,1+wendu2,0+wendu2);/对温度个位进行加操作void Add_wendu3(uchar i,uchar j) delaynms(30); wendu3+; if(wendu3=10)wen

44、du3=0; FBshuzi_string_1(GB_8,i,j,1+wendu3,0+wendu3);/对温度小数位进行加操作/* 函数名称: voidQueding1(uchar j)* 功能描述: 按下确定键后,将十进制温度值存入AT24C02中 * 输入: */void Queding1(uchar j) dat=(wendu1*100+wendu2*10+wendu3)/0.625;/温度值十进制转十六进制 Dataj+1=(dat&0 xff);/取十六进制低八位 delaynms(2); CunchuData(j+1,Dataj+1); Dataj=(dat8)&0 xff);/

45、取十六进制高八位 delaynms(2); CunchuData(j,Dataj); /* 函数名称: void Add_shidu()* 功能描述: 湿度加减 * 输入: * 输出: */void Add_shidu1(uchar i , uchar j) delaynms(30); temp1+;if(temp1=10)temp1=0; FBshuzi_string_1(GB_8,i,j,1+temp1,0+temp1);/对湿度值十位加一void Add_shidu2(uchar i,uchar j) delaynms(30); temp2+;if(temp2=10)temp2=0; F

46、Bshuzi_string_1(GB_8,i,j,1+temp2,0+temp2);/对湿度值个位进行加一操作/* 函数名称: void Queding2(uchar j)* 功能描述: 按下确定键后对十进制数湿度值进行的操作 * 输入: * 输出: */void Queding2(uchar j) uint shi; shi=(562.71-temp1*10-temp2)/(1.2621);/十进制转换为十六进制 Dataj+1=(shi&0 xff);/取十六进制低位数 delaynms(2); CunchuData(j+1,Dataj+1);/存入AT24C02 中 Dataj=(shi

47、8)&0 xff); /取十六进制高八位 delaynms(2);CunchuData(j,Dataj);/* 函数名称: void Keyscan(void)* 功能描述: 键盘扫描程序 * 输入: * 输出: */void Keysan(void) if(flag5=0) if(two=1) F12864_clear();two=0; kaijixianshi(); fengji1=1; else if(two=1) F12864_clear();two=0; if(key1=0) /1为功能键设置键 delaynms(1);/延时,消抖动if(key1=0)/延时后再次确认按键按下 F1

48、2864_clear(); while(!key1); key1n+; if(key1n=5) key1n=1; switch(key1n) /选屏 case 1:fanyejianwen();one=1;key2n=0;break; case 2:fanyejianshi();one=1;key2n=0;break; case 3:Regulation_temperture();one=1;key2n=0;break; case 4:Display_temperture();one=0;key2n=0;break; if(one=0)if(bao=0) baojings(); Display

49、_temperture(); Tiaojie(); Alarm();fengji1=0; if(key1n!=0) if(key2=0) /2为加键 delaynms(20);/延时,消抖动if(key2=0)/延时后再次确认按键按下 while(!key2); if(key1n=1) key2n+; if(key2n=4) key2n=1; switch(key2n) /对设定温度值的位进行选择 case 1:Tiaojie_Best();first=1;break;case 2:Tiaojie_Best();first=1;break;case 3:Tiaojie_Best();first

50、=1;break;default:key2n=0;first=0;break; if(key1n=2) key2n+; if(key2n=3) key2n=1; switch(key2n)/对设定湿度值的位进行选择 case 1:Tiaojie_Best();first=1;break;case 2:Tiaojie_Best();first=1;break;default:key2n=0;first=0;break; if(key1n=3) key2n+; if(key2n=6) key2n=1;first=1; switch(key2n) /对报警值需要改变的位进行选择 case 1:Tia

51、ojie_wendu1();first=1;break;case 2:Tiaojie_wendu1();first=1;break;case 3:Tiaojie_wendu1();first=1;break;case 4:Tiaojie_wendu1();first=2;break;case 5:Tiaojie_wendu1();first=2;break;default:key2n=0;first=0;break; if(key1n!=0) if(first=1) if(key3=0)/3为加键 delaynms(30);/延时,消抖动 if(key3=0)/延时后再次确认按键按下 if(k

52、ey1n=1) /改变温度设定值 switch(key2n) case 1:Add_wendu1(5,32); Queding1(11);break;case 2:Add_wendu2(6,32); Queding1(11);break;case 3:Add_wendu3(8,32); Queding1(11);break;default:key2n=0;break; if(key1n=2) /改变湿度报警值 switch(key2n) case 1:Add_shidu1(5,32);Queding2(9);break;case 2:Add_shidu2(6,32);Queding2(9);b

53、reak;default:key2n=0;break; if(key1n=3) /改变温度报警值 switch(key2n) case 1:Add_wendu1(7,32);Queding1(1);break;case 2:Add_wendu2(8,32);Queding1(1);break;case 3:Add_wendu3(10,32);Queding1(1);break; if(first=2) /改变报警值湿度值 if(key3=0)/3为加键 delaynms(30);/延时,消抖动 if(key3=0)/延时后再次确认按键按下 if(key1n=3) switch(key2n) c

54、ase 4:Add_shidu1(7,48);Queding2(5);break;case 5:Add_shidu2(8,48);Queding2(5);break; /加键加一 /* 函数名称: void main()* 功能描述: 主程序 * 输入: * 输出: */ void main() TMOD=0 x51; /0101 0001 定时器0在模式1下工作16位定时器,定时方式 定时器1在模式1下工作16位计数器,T1负跳变加1 TH0=(65536-46080)/256;/ 由于晶振为11.0592,故所记次数应为46080,计时器每隔50000微秒发起一次中断。 TL0=(6553

55、6-46080)%256;/46080的来历,为50000*11.0592/12 TL1=0 x00; /计时器1清零 TH1=0 x00; ET0=1; /使能定时器0中断 ET1=1; /使能定时器1中断 EA=1; /使能总中断 TR0=1; /开始计时 TR1=1; /定时器1开始计数 EX0=1; /使能外部中断0 EX1=1; /使能外部中断1 IT1=0; /边沿触发方式 IT0=0; /边沿触发 F12864_init(); /LCD12864初始化 F12864_clear(); /LCD12864清屏程序 shujuku(); /加载AT24C02数据库 initial_d

56、s1302(); /DS1302初始化 while(1) Keysan(); /调用键盘扫描程序 附录5:英文文献1英文部分FEATURESUnique 1-Wireinterface requires only one port pin for communication Each device has a unique 64-bit serial code stored in an onboard ROMMulti-drop capability simplifies distributed temperature sensing applications Requires no exte

57、rnal components Can be powered from data line, Power supply range is 3.0V to 5.5V Measures temperatures from 55C to +125C (67F to +257F) 0.5C accuracy from 10C to +85C Thermometer resolution is user-selectable from 9 to 12 bits Converts temperature to 12-bit digital word in 750ms (max.) User-definab

58、le nonvolatile (NV) alarm settings Alarm search command identifies and addresses devices whose temperature is outside of programmed limits (temperature alarm condition) Available in 8-pin SO (150mil), 8-pin SOP, and 3-pin TO-92 packages Software compatible with the DS1822 Applications include thermo

59、static controls, industrial systems, consumer products, thermometers, or any thermally sensitiveDESCRIPTION The DS18B20 Digital Thermometer provides 9 to 12bit centigrade temperature measurements and has an alarm function with nonvolatile user -programmable upper and lower trigger points. The DS18B2

60、0 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor. It has an operating temperature range of 55C to +125C and is accurate to 0.5 over the range of 10C to +85C. In addition, the DS18B20 can derive power directly

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论