Pages

Saturday, April 25, 2020

Smoke detection using AT89C51


Hello guys, hope you are here because you want to make something or gain some electronics knowledge so let’s start DIY-
In this DIY session, we will discuss about the smoke detector using one of the simplest microcontrollers, 8051 which is made by Atmel Company. In this DIY project you need the following things –
  • 16X2 LCD Display
  • 10K pot
  • 10k Resistor
  • 8.2k resistor
  • Push-button
  • Buzzer
  • 11.0592 MHz Crystal Oscillator
  • 22pf capacitor – 2
  • 5v power supply
1. AT89CXX:

This is one of the simplest microcontrollers which can be used for small projects. 8051 series microcontrollers came into existence early 90s and first was made by the Intel Company. It has various functions like, it has built-in UART for serial communication, two types of interrupt hardware and software, RAM, ROM, an oscillator circuit, 16-bit timer, etc. This microcontroller has four 8bit general-purpose I/O port.



2. MQ5:

MQ5 is a smoke detector sensor which can be used for smoke, carbon monoxide as well as flammable gas detection. There are various types of sensors available in this “MQ” series and they have different sensing and functionality. You can buy an MQ5 module for this project because it gives calibration facility as well as 2 types of output digital and analog output. Digital output is simply used for the detection purpose whereas analog output used for detection as well as monitoring the level of smoke. Here we are going to use simple digital output because we are not going to measure the level of smoke density. For better understanding find the below image. In the below image, you can see the blue colour variable resistor which is used for the calibration process and you can simply adjust this according to your need like you want to detect very rare or denser smoke. And don’t increase sensitivity too much because it can give our circuit a false trigger.


3. 16X2 LCD:

16X2 is an alphanumeric LCD display which is widely used in embedded systems because it is very easy to interface with any microcontrollers. 16X2 LCD has 2 rows and 16 columns so that you can display 32 characters on display at a time. This display provides various other functionalities like you can on or off the cursor, you can choose cursor type, you can address DDRAM, custom character, read or write, backlight brightness control, etc. In this project, we will use a 10k pot for display backlight control. We will discuss the complete procedure of LCD interfacing in a different tutorial.


4. Power supply:

For 8051 we have to use 5v power supply and if you don’t have then simply connect the 9v battery using voltage regulator ic7805. The circuitry for 7805 is given below. If you are going to use power supply then check its output before connecting to the circuit because high voltage can damage our controller and here we are not going to use any type of high voltage protection.



5. Working:

The working of project and circuit is very simple when the MQ5 sensor detects any smoke or flammable gas it instantly gives a low output at the DO pin. This output is detected by the I/O pin of the microcontroller and then it is processed for further work and manipulation. Remember for mounting the sensor with microcontroller use pull-up resistor for preventing false detection. Here we will show the status of the smoke sensor on the LCD so microcontroller read the status and write its status on LCD. If the status is normal then LCD shows smoke absent and when detected then write smoke detected and turn on the buzzer. Here in the circuit design we used a button (Highlighted in red circle) in the place of the sensor so replace it with the MQ5 sensor. Circuit is shown below.



6. Code:

Here we are using assembly language to code the microcontroller and code is so simple. We continuously monitor the pin P3.7 which is connected to the smoke sensor and gives the low-level output after detecting the smoke. When microcontroller detects the low level on the pin it starts writing a status on the LCD and set 0 the buzzer pin so that buzzer starts beeping. For detecting a single pin status we are going do logical OR operation with port data to 01111111 binary data which gives the two possible outcomes 11111111 or 01111111 and we compare this data to predefined data for the port when we detect smoke or in a simple word we masked the whole bit expect P3.7.  After detecting smoke you have to reset the microcontroller for stopping buzzer and restart the program. The code is given below.


#############################################################################################################################
$mod51
org 00h
MOV P2,#38H
ACALL CMD 
MOV P2,#06H
ACALL CMD
MOV P2,#01H
ACALL CMD
MOV P2,#00FH
ACALL CMD 
ACALL delay
mov P2,#'S'
Acall dat
mov P2,#'M'
Acall dat
mov P2,#'O'
Acall dat
mov P2,#'K'
Acall dat
mov P2,#'E'
Acall dat
mov P2,#' '
Acall dat
mov P2,#'A'
Acall dat
mov P2,#'B'
Acall dat
mov P2,#'S'
Acall dat
mov P2,#'E'
Acall dat
mov P2,#'N'
Acall dat
mov P2,#'T'
Acall dat
loop:
CLR A
MOV A, P3
ORL A, #01111111B
CJNE A, #11111111B, DET
SJMP loop
DET:
MOV P2,#01H
ACALL CMD
mov P2,#'S'
Acall dat
mov P2,#'M'
Acall dat
mov P2,#'O'
Acall dat
mov P2,#'K'
Acall dat
mov P2,#'E'
Acall dat
mov P2,#' '
Acall dat
mov P2,#'D'
Acall dat
mov P2,#'E'
Acall dat
mov P2,#'T'
Acall dat
mov P2,#'E'
Acall dat
mov P2,#'C'
Acall dat
mov P2,#'T'
Acall dat
mov P2,#'E'
Acall dat
mov P2,#'D'
Acall dat
mov P2,#'!'
Acall dat
CLR P3.6
EMR: SJMP EMR
CMD:
CLR P3.0
CLR P3.1
SETB P3.2
ACALL DELAY
CLR P3.2
RET
dat:
SETB P3.0
CLR P3.1
SETB P3.2
ACALL DELAY
CLR P3.2
RET
delay:mov r0,#10
h0:mov r1,#20
h1:mov r2,#20
h2:djnz r2,h2
djnz r1,h1
djnz r0,h0
ret
end

#############################################################################################################################

7. OUTPUT:



#############################################################################################################################

You May Like:-

      - ARDUINO with GLCD
     
          -Know Your Arduino


No comments:

Post a Comment

For You!

KiCad (PCB Layout)

I n this tutorial, we will continue the previous tutorial where we were discussed about how to design a schematic of the circuit. 1...