Proteus simulation design of smoke and fire alarm based on 51 single chip microcomputer

Proteus simulation design of smoke and fire alarm based on 51 single chip microcomputer

1 Development environment

Simulation diagram: proteus8.9 or above

Program code: KEIL4/KEIL5

Schematic: AD

Design number: A0004

Code explanation + simulation explanation + simulation demonstration + schematic diagram explanation

Operation video:

Simulation design of smoke and fire alarm system based on 51 single chip microcomputer

2 Function Description Introduction

Combined with the actual situation, a smoke alarm is designed based on 51 single-chip microcomputer. The functional requirements that the system should meet are:

MQ-2 smoke sensor, ADC0832 analog-to-digital conversion chip, DS18B20 temperature sensor, digital tube display, independent buttons, sound and light alarm module.

Specific functions:

1. The digital tube monitors and displays the temperature value and smoke concentration in real time;

2. The smoke alarm value and temperature alarm value can be set by pressing the button;

3. It can realize manual emergency alarm and manual cancel alarm function;

4. When the temperature exceeds the set threshold, the buzzer sounds and the yellow light flashes; when the smoke exceeds the set threshold, the buzzer sounds and the red light flashes;

5. Ranging range: smoke concentration: 0-9 level; temperature range: 0-99 degrees.

3 Simulation diagram

img

img

4 programs

The project file is opened with Keil4/keil5

the code

img

main function

/***************主函数*****************/

void main()

{

​	beep = 0;				  //开机蜂鸣器叫一声

​	delay_1ms(200);

​	P0 = P1 = P2 = P3 = 0xff;  //初始化IO口为高电平

​	temperature = read_temp();  //读取温度值

​	init_eeprom();  //开始初始化保存的数据

​	delay_1ms(650);				

​	temperature = read_temp();  //读取温度值

​	time_init(); //初始化定时器 		

​	while(1)  

​	{


​		key();					//独立按键程序

​		if(key_can < 10)

​		{

​			key_with();			//按键按下要执行的程序

​		}

​		if(flag_300ms == 1)

​		{		

​			flag_300ms = 0;

​			clock_h_l();

​			dengji = ad0832read(0);	

​			if(dengji>248)dengji=248;

​			dengji = dengji * 10 / 250;

​			temperature = read_temp();  //读取温度值

 

​			if(menu_1 == 0)

​			{

​				if(temperature >= 99)

​					temperature = 99;

​				dis_smg[3]=smg_du[dengji];	  //显示烟物报警等级

​				dis_smg[2]= 0x80;	      // -		

​				dis_smg[1]=smg_du[temperature/10%10];	//十位

​				dis_smg[0]=smg_du[temperature%10];	  //个位	ADC0832为8位ADC,数值为0~255,我们将其分开放入l_tmpdate数组中显示

//			dis_smg[3] = smg_du[dengji/100];	//十位

//			dis_smg[2] = smg_du[dengji/10%10];	//十位

//			dis_smg[1] = smg_du[dengji%10];	//个位

 

​			}

​		} 

​		delay_1ms(1);

​	}

}

 

/*************定时器0中断服务程序***************/

void time0_int() interrupt 1

{	

​	static uchar value;

​	TH0 = 0xf8;

​	TL0 = 0x30;   // 2ms

​	value ++;	 

​	display();	 //数码管显示函数

​	if(value % 150 == 0)

​	{

​		flag_300ms = 1;	  //300ms

​		value = 0;

​	}

}

 

First of all, it is necessary to preheat the sensor, because after the MQ.2 semiconductor resistive smoke sensor is stored without power for a period of time, when it is powered on again, the sensor cannot immediately collect smoke information normally, and it needs a period of time to warm up. After the program initialization is completed, the system enters the monitoring state. The flow chart of the main program is shown in the figure below.

img

​ During the entire alarm system work, after the smoke concentration information is converted and processed by ADC0832, it is analyzed and processed by the single-chip microcomputer to determine whether the system activates the alarm. The main program also includes LED eight-segment digital tube concentration character display function, manual alarm function, alarm concentration setting function, interrupt subroutine, etc., which make the alarm function more perfect and more convenient.

​ After warming up, the program starts to execute the initialization subroutine. The functions of initialization are I/O port input and output state setting, register initialization, interrupt function, etc. First, set the initial value of timing to 50ms, and use IAP to write into EEPROM as the value interval. Then, set timer 0 and select mode 1. In the mode 1 state, the working registers TH1 and TL1 of the timer are all 16 bits involved in the operation. Next, set the enable bit of timer 0 interrupt to 1, turn on timer 0, turn off the buzzer, turn on the green light, and set the initial value of the alarm limit.

5 Schematic

​ The schematic diagram is drawn by AD, and there is a difference between the schematic diagram and the simulation diagram. The schematic diagram requires a power supply and a power switch module. The design information is detailed, the hardware manual information and pictures are detailed, and I am not responsible for hardware debugging, and some basic skills are required to make the real thing.

The principle of the intelligent fire alarm system is based on the fact that when the smoke concentration or temperature reaches the set value, the signal sensed by the smoke sensor and temperature sensor is processed by the ADC0832 for analog-to-digital conversion and then processed by the single-chip microcomputer, and the horn sends out an alarm sound. The system is divided into control circuit, detection circuit, display and alarm circuit.

img

6 Components list

img

7 list

img

See the video at the beginning of the article for the download link of this material

Guess you like

Origin blog.csdn.net/Jack_0220/article/details/128370406