基于单片机设计的8路温度巡检报警系统_第1页
基于单片机设计的8路温度巡检报警系统_第2页
基于单片机设计的8路温度巡检报警系统_第3页
基于单片机设计的8路温度巡检报警系统_第4页
基于单片机设计的8路温度巡检报警系统_第5页
已阅读5页,还剩27页未读 继续免费阅读

下载本文档

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

文档简介

/******************把数据保存到单片机内部eepom中******************/voidwrite_eepom12(){SectorErase(0x2000);byte_write(0x2000,t1_high%256);byte_write(0x2001,t1_high/256);byte_write(0x2002,t1_low%256);byte_write(0x2003,t1_low/256);byte_write(0x2004,t2_high%256);byte_write(0x2005,t2_high/256);byte_write(0x2006,t2_low%256);byte_write(0x2007,t2_low/256);byte_write(0x2055,a_a);}voidwrite_eepom34(){SectorErase(0x2200);byte_write(0x2200,t3_high%256);byte_write(0x2201,t3_high/256);byte_write(0x2202,t3_low%256);byte_write(0x2203,t3_low/256);byte_write(0x2204,t4_high%256);byte_write(0x2205,t4_high/256);byte_write(0x2206,t4_low%256);byte_write(0x2207,t4_low/256);byte_write(0x2255,a_a);}voidwrite_eepom56(){SectorErase(0x2400);byte_write(0x2400,t5_high%256);byte_write(0x2401,t5_high/256);byte_write(0x2402,t5_low%256);byte_write(0x2403,t5_low/256);byte_write(0x2404,t6_high%256);byte_write(0x2405,t6_high/256);byte_write(0x2406,t6_low%256);byte_write(0x2407,t6_low/256);byte_write(0x2455,a_a);}voidwrite_eepom78(){SectorErase(0x2600);byte_write(0x2600,t7_high%256);byte_write(0x2601,t7_high/256);byte_write(0x2602,t7_low%256);byte_write(0x2603,t7_low/256);byte_write(0x2604,t8_high%256);byte_write(0x2605,t8_high/256);byte_write(0x2606,t8_low%256);byte_write(0x2607,t8_low/256);byte_write(0x2655,a_a);}/******************把数据从单片机内部eepom中读出来*****************/voidread_eepom12(){t1_high=byte_read(0x2001);t1_high<<=8;t1_high|=byte_read(0x2000);t1_low=byte_read(0x2003);t1_low<<=8;t1_low|=byte_read(0x2002);t2_high=byte_read(0x2005);t2_high<<=8;t2_high|=byte_read(0x2004);t2_low=byte_read(0x2007);t2_low<<=8;t2_low|=byte_read(0x2006);a_a=byte_read(0x2055);}voidread_eepom34(){t3_high=byte_read(0x2201);t3_high<<=8;t3_high|=byte_read(0x2200);t3_low=byte_read(0x2203);t3_low<<=8;t3_low|=byte_read(0x2202);t4_high=byte_read(0x2205);t4_high<<=8;t4_high|=byte_read(0x2204);t4_low=byte_read(0x2207);t4_low<<=8;t4_low|=byte_read(0x2206);a_a=byte_read(0x2255);}voidread_eepom56(){t5_high=byte_read(0x2401);t5_high<<=8;t5_high|=byte_read(0x2400);t5_low=byte_read(0x2403);t5_low<<=8;t5_low|=byte_read(0x2402);t6_high=byte_read(0x2405);t6_high<<=8;t6_high|=byte_read(0x2404);t6_low=byte_read(0x2407);t6_low<<=8;t6_low|=byte_read(0x2406);a_a=byte_read(0x2455);}voidread_eepom78(){t7_high=byte_read(0x2601);t7_high<<=8;t7_high|=byte_read(0x2600);t7_low=byte_read(0x2603);t7_low<<=8;t7_low|=byte_read(0x2602);t8_high=byte_read(0x2605);t8_high<<=8;t8_high|=byte_read(0x2604);t8_low=byte_read(0x2607);t8_low<<=8;t8_low|=byte_read(0x2606);a_a=byte_read(0x2655);}#include"menu.h"/*************定时器0初始化程序***************/voidtime_init(){EA=1;//开总中断TMOD=0X01;//定时器0、定时器1工作方式1ET0=1;//开定时器0中断TR0=1;//允许定时器0定时}/****************独立按键处理函数************************/voidkey(){staticucharkey_new=0,key_old=0,key_value=0;if(key_new==0){//按键松开的时候做松手检测if((P2&0x0f)==0x0f)key_value++;elsekey_value=0;if(key_value>=15){key_value=0;key_new=1;flag_lj_en=0;//关闭连加使能flag_lj_3_en=0;//关闭3秒后使能flag_value=0;//清零key_time=0;}}else{if((P2&0x0f)!=0x0f)key_value++;//按键按下的时候elsekey_value=0;if(key_value>=10){key_value=0;key_new=0;flag_lj_en=//1;连加使能zd_break_en=1;//自动退出设置界使能zd_break_value=0;//自动退出设置界变量清零}}key_can=20;if(key_500ms==1){key_500ms=0;key_new=0;key_old=1;zd_break_value=0;}if((key_new==0)&&(key_old==1)){switch(P2&0x0f){case0x0e:key_can=4;break;//得到k1键值case0x0d:key_can=3;break;//得到k2键值case0x0b:key_can=2;break;//得到k3键值case0x07:key_can=1;break;//得到k4键值}//write_sfm2(1,14,key_can);}key_old=key_new;}/****************报警函数***************/voidclock_h_l(){if((temperature1<=t1_low)||(temperature1>=t1_high))t1=1;//温度1报警标志位elset1=0;if((temperature2<=t2_low)||(temperature2>=t2_high))t2=1;//温度2报警标志位elset2=0;if((temperature3<=t3_low)||(temperature3>=t3_high))t3=1;//温度3报警标志位elset3=0;if((temperature4<=t4_low)||(temperature4>=t4_high))t4=1;//温度4报警标志位elset4=0;if((temperature5<=t5_low)||(temperature5>=t5_high))t5=1;//温度5报警标志位elset5=0;if((temperature6<=t6_low)||(temperature6>=t6_high))t6=1;//温度6报警标志位elset6=0;if((temperature7<=t7_low)||(temperature7>=t7_high))t7=1;//温度7报警标志位elset7=0;if((temperature8<=t8_low)||(temperature8>=t8_high))t8=1;//温度8报警标志位elset8=0;t_zong=t1+t2+t3+t4+t5+t6//+t7+t8;算出一共有多少个报警}/****************8个18b20显示***************/voiddis_8_18b20(){staticucharvalue;if(flag_2s==1){temperature5=read5_temp();//先读出温度的值temperature6=read6_temp();//先读出温度的值temperature7=read7_temp();//先读出温度的值temperature8=read8_temp();//先读出温度的值if(value==1)init_1602_dis_csf1();value=0;write_sfm3_18B20(1,3,temperature5);write_sfm3_18B20(1,11,temperature6);write_sfm3_18B20(2,3,temperature7);write_sfm3_18B20(2,11,temperature8);}else{temperature1=read1_temp();//先读出温度的值temperature2=read2_temp();//先读出温度的值temperature3=read3_temp();//先读出温度的值temperature4=read4_temp();//先读出温度的值if(value==0)init_1602_dis_csf();value=1;write_sfm3_18B20(1,3,temperature1);write_sfm3_18B20(1,11,temperature2);write_sfm3_18B20(2,3,temperature3);write_sfm3_18B20(2,11,temperature4);}}/********************菜单对应的处理函数***********************/voidmenu_dispaly(){if(menu_1==0)//正常退出菜单后的显示8个温度{dis_8_18b20();}if((menu_1==1)&&(menu_2!=0))//显示的设置温度1{temperature1=read1_temp();//先读出温度的值write_sfm3_18B20(1,8,temperature1);}if((menu_1==2)&&(menu_2!=0))//显示的设置温度2{temperature2=read2_temp();//先读出温度的值write_sfm3_18B20(1,8,temperature2);}if((menu_1==3)&&(menu_2!=0))//显示的设置温度3{temperature3=read3_temp();//先读出温度的值write_sfm3_18B20(1,8,temperature3);}if((menu_1==4)&&(menu_2!=0))//显示的设置温度4{temperature4=read4_temp();//先读出温度的值write_sfm3_18B20(1,8,temperature4);}if((menu_1==5)&&(menu_2!=0))//显示的设置温度5{temperature5=read5_temp();//先读出温度的值write_sfm3_18B20(1,8,temperature5);}if((menu_1==6)&&(menu_2!=0))//显示的设置温度6{temperature6=read6_temp();//先读出温度的值write_sfm3_18B20(1,8,temperature6);}if((menu_1==7)&&(menu_2!=0))//显示的设置温度7{temperature7=read7_temp();//先读出温度的值write_sfm3_18B20(1,8,temperature7);}if((menu_1==8)&&(menu_2!=0))//显示的设置温度8{temperature8=read8_temp();//先读出温度的值write_sfm3_18B20(1,8,temperature8);}if(((menu_1>0)&&(menu_1<9))&&(menu_2==1))//对光标不处理,要不然光标不会显示在正确的位置{write_com(0x80+0x43);//将光标移动到write_com(0x0f);//显示光标并且闪烁}elseif(((menu_1>0)&&(menu_1<9))&&(menu_2==2)){write_com(0x80+0x4b);//将光标移动到write_com(0x0f);//显示光标并且闪烁}if((menu_1==9)&&(menu_2!=0)){//write_sfm2(1,8,t_zong);}}/**************开机自检eepom初始化*****************/voidinit_eepom(){read_eepom12();read_eepom34();read_eepom56();read_eepom78();if(a_a==0xff)//新的单片机初始单片机内问EEPOM{t1_high=301,t1_low=101;t2_high=302,t2_low=102;t3_high=303,t3_low=103;t4_high=304,t4_low=104;t5_high=305,t5_low=105;t6_high=306,t6_low=106;t7_high=307,t7_low=107;t8_high=308,t8_low=108;a_a=1;write_eepom12();write_eepom34();write_eepom56();write_eepom78();}}voidmain(){init_1602();init_1602_dis_csf();init_menu();temperature1=read1_temp();//先读出温度的值temperature2=read2_temp();//先读出温度的值temperature3=read3_temp();//先读出温度的值temperature4=read4_temp();//先读出温度的值temperature5=read5_temp();//先读出温度的值temperature6=read6_temp();//先读出温度的值temperature7=read7_temp();//先读出温度的值temperature8=read8_temp();//先读出温度的值time_init();//初始化定时器//write_sfm3_18B20(2,2,t_high);//write_sfm3_18B20(2,10,t_low);init_eepom();delay_1ms(650);temperature1=read1_temp();//先读出温度的值temperature2=read2_temp();//先读出温度的值temperature3=read3_temp();//先读出温度的值temperature4=read4_temp();//先读出温度的值temperature5=read5_temp();//先读出温度的值temperature6=read6_temp();//先读出温度的值temperature7=read7_temp();//先读出温度的值temperature8=read8_temp();//先读出温度的值while(1){if(flag_300ms==1)//300ms处理一次温度程序{}clock_h_l();//报警函数

温馨提示

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

评论

0/150

提交评论