【毕业设计】41-基于单片机列车烟雾浓度报警/烟雾/甲烷报警装置设计(原理图+仿真工程+源代码+答辩论文+答辩PPT)
资料要求
资料包含:毕业设计全套资料(精品)
原理图工程文件
原理图截图
仿真模型工程文件
仿真截图
答辩论文低重复率文档,20487字
英文文献及翻译
答辩PPT
详情请私信!
任务书
研究列车车厢内烟雾报警器控制与设计系统的现状,学习烟雾报警器原理、烟雾报警浓度区间的基本技术和调试方法,设计列车车厢内烟雾报警器的控制与设计系统,最终实现列车车厢烟雾浓度在一定标准时实现报警就的控制与设计系统的数据实时采集、传输、存储、显示等功能。 1.研究本课题设计系统相关技术,提出本课题设计系统的整体设计方案; 2.对本课题设计系统进行具体的软、硬件设计(或仿真)和实现; 3.通过调试验证本课题设计系统的功能实现。
设计说明书
摘要
本文通过使用烟雾报警器来对动车车厢实时监控。使用51系列单片机作为系统主控制器,烟雾报警器通过AD0832作为模数转换器,将数据传输到单片机处理,通过LCD1602显示数据。蜂鸣器LED作为报警设备。在系统的硬件部分以模块化方式设计,在后期可以对系统进行增加功能。软件设计同样使用模块化设计来对各个子驱动调用。最后使用仿真软件Proteuus来实现系统的整体仿真完成系统的功能,最终达到了对动车烟雾浓度的实时监控,并且可以通过按键实现。阈值调节完成本次系统设计。
设计框架架构
设计说明书及设计文件
v
源码展示
/*此处的蜂鸣器是NPN型的*/
#include "reg52.H"
#include "1602.h"
#include "ADC0832.h"
#define uchar unsigned char
#define uint unsigned int
//#include "eeprom52.h"
//声明常量
#define ALCH 80 //报警值
//K_MG_MV和K_ZERO为传感器校准系数,要根据每个MQ-3模块校准
#define K_MG_MV 80/160 //传感器灵敏度系数
#define K_ZERO 20 //传感器零点漂移
//定义按键
sbit Key_Up = P3^6;
sbit Key_Down = P3^7;
//定义LED报警灯
sbit Led_Warn1 = P3^4;
sbit Led_Warn2 = P3^5;
sbit beep=P1^4; //蜂鸣器IO口
//定义标识
volatile bit FlagStartAL = 0; //开始转换标志
volatile bit FlagKeyPress = 0; //有键弹起标志
//全局变量定义
uchar Threshold; //烟雾浓度上限报警值
uint ALCounter; //烟雾转换计时器
long ALValue; //烟雾测量值
float ALtemp; //计算临时变量
uchar n;
uint keyvalue, keyUp, keyDown; //键值
char * pSave; //EEPROM存盘用指针
//函数声明
void Data_Init();
void Timer0_Init();
void Port_Init();
void ADC_Init();
uchar GetADVal();
void KeyProcess(uint );
void DELAY(unsigned int t)
{
while(t!=0)
t--;
}
//数据初始化
void Data_Init()
{
ALCounter = 30;
ALValue = 0;
Led_Warn1 = 1;
Led_Warn2 = 2;
keyvalue = 0;
keyUp = 1;
keyDown = 1;
}
void di()
{
beep = 0;
DELAY(500);
beep = 1;
}
void Timer0_Init()
{
ET0 = 1; //允许定时器0中断
TMOD = 0x01; //定时器工作方式选择
TL0 = (65536-2000)%256;
TH0 = (65536-2000)/256; //定时器赋予初值
TR0 = 1; //启动定时器
}
//定时器0中断
void Timer0_ISR (void) interrupt 1 using 0
{
TL0 = (65536-2000)%256;
TH0 = (65536-2000)/256; //定时器赋予初值
//每1秒钟启动一次AD转换
ALCounter ++;
if (ALCounter >= 500)
{
FlagStartAL = 1;
ALCounter = 0;
}
}
//按键处理程序,参数为键值,1为Up键,2为Down键
void KeyProcess(uint num) //设置按键 调节报警浓度
{
switch (num)
{
case 1:
if (Threshold<255) Threshold++;
break;
case 2:
if (Threshold>1) Threshold--;
break;
default:
break;
}
if ((Threshold>=255)||(Threshold<0)) Threshold = 80;
LCD1602_write(0,0xc6);
if(Threshold>9)
LCD1602_write(1,0x30+Threshold/10%10);
else
LCD1602_writebyte(" ");
LCD1602_write(0,0xc7);
LCD1602_write(1,0x30+Threshold%10);
// L1602_int(2,5,Threshold);
}
void main()
{
Threshold = 15; /*此处是事先设定的浓度,这个值程序可以改*/
LCD1602_cls();
// L1602_init();
EA = 0;
Data_Init(); //数据初始化
Timer0_Init(); //定时器0初始化
EA = 1; //打开中断
LCD1602_write(0,0x80);
LCD1602_writebyte("Al: mg/100ml");
LCD1602_write(0,0xc0);
LCD1602_writebyte("Th: mg/100ml");
// L1602_string(1,1,"Al: mg/100ml"); //显示当前浓度值
// L1602_string(2,1,"Th: mg/100ml"); //显示报警浓度值
LCD1602_write(0,0xc6);
if(Threshold>9)
LCD1602_write(1,0x30+Threshold/10%10);
else
LCD1602_writebyte(" ");
LCD1602_write(0,0xc7);
LCD1602_write(1,0x30+Threshold%10);
// L1602_int(2,5,Threshold);
while(1)
{
// if(n<40)
// n++;
// else
// n=0;
//如果FlagStartAL标志置位,则进行AD转换
if (FlagStartAL == 1)
{
ALValue = (long)500 * A_D(0) / 256; //8位ADC,首先得到电压值,单位10毫伏
ALValue = ALValue - K_ZERO; //首先减去零点漂移
if (ALValue < 0) ALValue = 0;
ALValue = ALValue * K_MG_MV; //将mV转变成mg/100L,K_MG_MV系数需要校准
LCD1602_write(0,0x85);
if(ALValue>99)
LCD1602_write(1,0x30+ALValue/100%10);
else
LCD1602_writebyte(" ");
LCD1602_write(0,0x86);
if(ALValue>9)
LCD1602_write(1,0x30+ALValue/10%10);
else
LCD1602_writebyte(" ");
LCD1602_write(0,0x87);
LCD1602_write(1,0x30+ALValue%10);
// L1602_int(1,5,(int)ALValue);
FlagStartAL = 0;
}
if (ALValue > Threshold)
{
Led_Warn2 = 1;
if(n<20)
{
di();
Led_Warn1 = 0;
}
else
{
beep = 0;
Led_Warn1 = 1;
}
} //超过阈值,则 Led_Warn1灯报警,否则报警灯灭。
else
{
Led_Warn1 = 1;
Led_Warn2 = 0;
beep=0;
}
//键盘查询,在弹起时响应
if ((Key_Up)&&(keyUp==0)) {FlagKeyPress = 1; keyvalue = 1;}
else if ((Key_Down)&&(keyDown==0)) {FlagKeyPress = 1; keyvalue = 2;}
if (FlagKeyPress == 1)
{
KeyProcess(keyvalue);
FlagKeyPress = 0;
}
if (!Key_Up) keyUp = 0;
else keyUp = 1;
if (!Key_Down) keyDown = 0;
else keyDown = 1;
DELAY(100);
}
}