//功能:1.可轮流检测6个区域的温度,实现5秒钟自动切换功能,和手动切换
// 2.可显示时间及调节时间
// 3.温度高于上限或低于上限报警
// 4.可调整温度上限及下限,并且带掉电保护
// 5.可对-20摄氏度——60摄氏度温度测量,温度过高或者过低显示error
所谓多点温度巡检仪主要针对环境和设备内温度的集中检测和管理,可以无人值守24小时不间断检测温度,可实现高低温报警和自动切换显示区域。克服了管理人员手动测量和手工计算温度的误差,又提高了检测速度和精度,省了大量的人力和物力。
自行设计并制作多点温度巡检仪 (以下简称巡检仪 )。巡检仪可以对6个以上的监测点的温度进行轮流检测,检测周期不能超过0.3分钟。检测温度范围-200C--600C,检测的误差不能超过0.3%。
二、要求巡检仪可以对6个以上的监测点的温度进行轮流检测,检测周期不能超过0.3分钟。检测温度范围-200C--600C,检测的误差不能超过0.3%。
1. 基本要求 第(1)项 分别轮流检测6个点的温度,并显示出来; 第(2)项 每5秒钟自动切换一个温度点,同时显示日期和时间; 第(3)项 要求能通过按键切换当前显示的温度点;
2. 发挥部分 (1)温度高于上限则报警,温度低于下限则报警 ;计分5 (2)可以设置上限温度的报警值和下限温度的报警值,计分10;。 (3)系统关闭电源,报警的设定值不会丢失 , 计分15 。
三、说明
1. 显示部分可以用液晶,也可以用数码管显示
2. 可用键盘设置目标报警点和时间日期调整
3. 测试要求与说明 - 温度显示
- 当前时间显示
- 温度显示的手动切换
- 报警设置测试
- 报警输出测试`
2. 方案选择:根据设计任务要求,并且根据我们自己的需要而附加的功能,该电路的总体框图可分为几个基本的模块,框图如图所示: 2.1时钟模块: 2.2 报警装置:2.3 温度传感器:
2.4 LCD1602显示装置:2.5 LED指示灯:2.6 按键模块:3. 程序框图:单片机主程序框图、速度感应程序框图和铁片感应程序框图分别如图所示。 4.系统的具体设计与实现:4.1时钟模块:精准显示年,月,日,时,分,秒,自带备用电源,能掉电自动走时,功耗低,避免了每一次上电手动校时。 4.2 报警装置:当温度超过设定上限/下限,警报系统就会发出报警信号,让人们知道哪个区域温度高于或低于设置的温度上限/下限
4.3 温度传感器:六个温度传感器采用的是18B20,可以并联,并且六个温度传感器只占用一个I/O口,既节省成本,也节省不必要的能耗 4.4 LCD1602显示装置:采用LCD1602显示装置,功耗低,显示清晰 4.5 LED指示灯:调整日期和时间的提示,D1亮调分D2亮调时D3亮调日D4调月D5亮调年 4.6 按键模块:七个按键调时间和报警温度,既省节省成本也 方便操作
5.最小系统图: 该系统主要用到的是单片机,所以主要的部分是最小系统图,该最小系统图如所示:
//作者: 王
//单位:单片机协会
//版本号:1.0
#include <REG52.H>
#include "lcd_1602.h"
#include "ds18b20.h"
#include "DS1302.h"
#define uchar unsigned char
#define uint unsigned int
unsigned char code table[]="0123456789+-.";
unsigned char code table1[]="eroABCDEF";//error
unsigned char table3[16]="00:00:00a 00000";
unsigned char table4[16]="11-11-111+11100";
//sbit SCLK = P1^1; // DS1302时钟信号7脚
//sbit DIO= P1^2; // DS1302数据信号6脚
//sbit CE = P1^0; // DS1302片选5脚
sbit LED1=P1^3;
sbit LED2=P1^4;
sbit LED3=P1^5;
sbit LED4=P1^6;
sbit LED5=P1^7;
//sbit RW_LCD=P2^1;
//sbit RS_LCD=P2^0;
//sbit E_LCD=P2^2;
sbit TM_BUT1=P2^3;
sbit TM_BUT2=P2^4;
sbit TM_BUT3=P2^5;
sbit bee=P2^6;
//sbit DS18B20_DQ=P3^0;
sbit TEMP_BUT1=P3^2;
sbit TEMP_BUT2=P3^3;
sbit TEMP_BUT3=P3^4;
sbit TEMP_BUT4=P3^5;
sbit TEMP_BUT5=P3^6;
void xianshi_ds18b20_lcd1602()//温度显示
{
uint ee;
DS18B20_init();
R_temp_DS18B20();
ee=R_temp_DS18B20();
table3[8]=table1[DS18b20_cs+3];
ee=ee*6.25;
if(fu_flag==1)
{
if(ee>2000)
{
table3[10]=table1[0];
table3[11]=table1[1];
table3[12]=table1[1];
table3[13]=table1[2];
table3[14]=table1[1];
table3[15]=1;
}
else
{
table3[10]=table[11];
table3[11]=table[ee/1000];
table3[12]=table[ee/100%10];
table3[13]=table[12];
table3[14]=table[ee/10%10];
table3[15]=3;
}
}
if(fu_flag==0)
{
if(ee>6000)
{
table3[10]=table1[0];
table3[11]=table1[1];
table3[12]=table1[1];
table3[13]=table1[2];
table3[14]=table1[1];
table3[15]=2;
}
else
{
table3[10]=table[10];
table3[11]=table[ee/1000];
table3[12]=table[ee/100%10];
table3[13]=table[12];
table3[14]=table[ee/10%10];
table3[15]=3;
}
}
}
void t0_init()//初始化定时器t0
{
TMOD=0X01;
TH0 = 0x3C;
TL0 = 0x0B0;
EA=1;
ET0=1;
TR0=1;
}
void ds18b20_qiehuan()//按键切换区域温度
{
if(TEMP_BUT1==0)
{
delay_ms(20);
if(TEMP_BUT1==0)
{
DS18b20_cs++;
}
while(TEMP_BUT1!=1);
}
}
void xianshi_DS1302_lcd1602()//用1602显示时间
{
freshtime();
table3[0]=table[hour_1];
table3[1]=table[hour_0];
table3[3]=table[minute_1];
table3[4]=table[miunte_0];
table3[6]=table[second_1];
table3[7]=table[second_0];
table4[0]=table[year_1];
table4[1]=table[year_0];
table4[3]=table[month_1];
table4[4]=table[month_0];
table4[6]=table[date_1];
table4[7]=table[date_0];
table4[8]=2;
table4[12]=1;
}
void BUT_ds1302()//ds1302按键调时间
{
uchar temp,mun;
freshtime();
if(TM_BUT1==0)
{
delay_ms(10);
if(TM_BUT1==0)
{
temp++;
}
while(TM_BUT1!=1);
}
switch(temp)
{
case 1: LED1=0;LED2=1;LED3=1;LED4=1;LED5=1;
if(TM_BUT2==0){delay_ms(10);if(TM_BUT2==0){
mun=tab[0];mun++;
if((mun&0x0f)>9)mun+=6;
if(mun>0x59){mun=0;}Write1302 (WRITE_MINUTE,mun);while(TM_BUT2!=1);
}}
if(TM_BUT3==0){delay_ms(10);if(TM_BUT3==0){
mun=tab[0];mun--;
if((mun&0x0f)>9)mun-=6;
if(mun>0x59){mun=0x59;}Write1302 (WRITE_MINUTE,mun);while(TM_BUT3!=1);
}}break;
case 2: LED1=1;LED2=0;LED3=1;LED4=1;LED5=1;
if(TM_BUT2==0){delay_ms(10);if(TM_BUT2==0){
mun=tab[1];mun++;
if((mun&0x0f)>9)mun+=6;
if(mun>0x23){mun=0;}Write1302 (WRITE_HOUR,mun);while(TM_BUT2!=1);
}}
if(TM_BUT3==0){delay_ms(10);if(TM_BUT3==0){
mun=tab[1];mun--;
if((mun&0x0f)>9)mun-=6;
if(mun>0x23){mun=0x23;}Write1302 (WRITE_HOUR,mun);while(TM_BUT3!=1);
}}break;
case 3: LED1=1;LED2=1;LED3=0;LED4=1;LED5=1;
if(TM_BUT2==0){delay_ms(10);if(TM_BUT2==0){
mun=tab[2];mun++;
if((mun&0x0f)>9)mun+=6;
if(mun>0x31){mun=1;}Write1302 (WRITE_DATE,mun);while(TM_BUT2!=1);
}}
if(TM_BUT3==0){delay_ms(10);if(TM_BUT3==0){
mun=tab[2];mun--;
if((mun&0x0f)>9)mun-=6;
if(mun<0x01){mun=0x31;}Write1302 (WRITE_DATE,mun);while(TM_BUT3!=1);
}}break;
case 4: LED1=1;LED2=1;LED3=1;LED4=0;LED5=1;
if(TM_BUT2==0){delay_ms(10);if(TM_BUT2==0){
mun=tab[3];mun++;
if((mun&0x0f)>9)mun+=6;
if(mun>0x12){mun=1;}Write1302 (WRITE_MONTH,mun);while(TM_BUT2!=1);
}}
if(TM_BUT3==0){delay_ms(10);if(TM_BUT3==0){
mun=tab[3];mun--;
if((mun&0x0f)>9)mun-=6;
if(mun<0x01){mun=0x12;}Write1302 (WRITE_MONTH,mun);while(TM_BUT3!=1);
}}break;
case 5: LED1=1;LED2=1;LED3=1;LED4=1;LED5=0;
if(TM_BUT2==0){delay_ms(10);if(TM_BUT2==0){
mun=tab[4];mun++;
if((mun&0x0f)>9)mun+=6;
if(mun>0x99){mun=0;}Write1302 (WRITE_YEAR,mun);while(TM_BUT2!=1);
}}
if(TM_BUT3==0){delay_ms(10);if(TM_BUT3==0){
mun=tab[4];mun--;
if((mun&0x0f)>9)mun-=6;
if(mun>0x99){mun=0x99;}Write1302 (WRITE_YEAR,mun);while(TM_BUT3!=1);
}}break;
case 6: temp=0;LED1=1;LED2=1;LED3=1;LED4=1;LED5=1;break;
}
}
void ds18b20_baojing()//温度上下限报警
{
if(DS18b20_dat[2]>DS18b20_dat[0]|DS18b20_dat[2]<DS18b20_dat[1])
{
bee=0;
}
else bee=1;
}
void ds18b20_display_hl()//显示上下限报警温度
{
table4[10]=table[DS18b20_dat[0]/10];
table4[11]=table[DS18b20_dat[0]%10];
if((DS18b20_dat[1]&0x80)==0x80)
{
table4[13]=table[11];
table4[14]=table[(~DS18b20_dat[1]+1)/10];
table4[15]=table[(~DS18b20_dat[1]+1)%10];
}
else
{
table4[13]=table[10];
table4[14]=table[DS18b20_dat[1]/10];
table4[15]=table[DS18b20_dat[1]%10];
}
}
void ds18b20_but_hl()//设置报警上下限
{
char temp;
if(TEMP_BUT2==0)
{
delay_ms(10);
if(TEMP_BUT2==0)
{
temp=DS18b20_dat[0];
temp++;
if(temp>0x3c)temp=0;
DS18b20_dat[0]=temp;
}
while(TEMP_BUT2!=1);
}
if(TEMP_BUT3==0){delay_ms(10);if(TEMP_BUT3==0){
temp=DS18b20_dat[0];temp--;if((temp&0x80)==0x80)temp=60;DS18b20_dat[0]=temp;}
while(TEMP_BUT3!=1);}
if(TEMP_BUT4==0)
{
delay_ms(10);
if(TEMP_BUT4==0)
{
temp=DS18b20_dat[1];
temp++;
DS18b20_dat[1]=temp;
}
while(TEMP_BUT4!=1);
}
if(TEMP_BUT5==0){delay_ms(10);if(TEMP_BUT5==0){
temp=DS18b20_dat[1];temp--;if(temp<-20)temp=0;DS18b20_dat[1]=temp;}
while(TEMP_BUT5!=1);}
}
void main()
{
LCD_1602_init();
DS1302_init();
t0_init();
read_t();
while(1)
{
xianshi_DS1302_lcd1602();
ds18b20_display_hl();
xianshi_ds18b20_lcd1602();
printf(table3,1,1);
printf(table4,1,2);
store_t();
}
}
void t1zd()interrupt 1
{
uchar i;
TH0 = 0x3C;
TL0 = 0x0B0;
i++;
BUT_ds1302();
ds18b20_qiehuan();
ds18b20_baojing();
ds18b20_but_hl();
if(i==90)
{
DS18b20_cs++;
i=0;
}
if(DS18b20_cs>=6)
{
DS18b20_cs=0;
}
}
全部资料51hei下载地址:
电子大赛测试1题.7z
(383.63 KB, 下载次数: 88)
|