Académique Documents
Professionnel Documents
Culture Documents
Smoke detector
SUBMITTED TO:-
Prof.Sundar.S
AIM:
To write a program to detect smoke in two rooms then to display the status on LCD and to make led glow when smoke is detected. Simulation is done in proteus software.
EQUIPMENT REQUIRED:
AT89C51RD2 microcontroller TGS308 smoke sensor LM016L LCD Crystal oscillator Capacitors NOT gates Switches Potentiometer
METHOD:
This project consists of two TGS308 sensors which are placed in two different rooms to detect smoke. Sensor outputs a high signal when smoke is detected or low otherwise. Outputs of the sensors are given to a signal conditioning circuit for amplification. Output of this circuit is given to Pin P3.2 & P3.3 of 8051 microcontroller through NOT logic gates. BUZZER and LCD are connected to pin P2.4 and PORT 1 of the microcontroller. Pin 3.2 & 3.3 are high always and go low when smoke is detected. This triggers the interrupt of the microcontroller and the buzzer rings indicating smoke in a room. The room in which smoke occurred is displayed on LCD.
BLOCK DIAGRAM:
SMOKE SENSOR
SIGNAL CONDITIONING
NOT LOGIC
BUZZER
SMOKE SENSOR
SIGNAL CONDITIONING
NOT LOGIC
CONNECTION DIAGRAM:
C1
1nF
X1
CRYSTAL
D1 U2
19 XTAL1 P0.0/AD0 P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 P2.0/A8 P2.1/A9 P2.2/A10 P2.3/A11 P2.4/A12 P2.5/A13 P2.6/A14 P2.7/A15 P3.0/RXD P3.1/TXD P3.2/INT0 P3.3/INT1 P3.4/T0 P3.5/T1 P3.6/WR P3.7/RD 39 38 37 36 35 34 33 32 21 22 23 24 25 26 27 28 10 11 12 13 14 15 16 17 LED-RED
C2
1nF 18
XTAL2
SW3
9 SW-SPDT-MOM 29 30 31 RST
PSEN ALE EA
U1 SW1
NOT SW-SPDT-MOM
1 2 3 4 5 6 7 8
U3
SW2
SW-SPDT-MOM
NOT
14 13 12 11 10 9 8 7
6 5 4
3 2 1
E RW RS
D7 D6 D5 D4 D3 D2 D1 D0
RV1
1k
LCD1
LM016L
ALGORITHM:
1. Use DB instruction to store the message to be displayed on LCD in ROM memory 2. Enable the two external interrupts in the interrupt enable register 3. Prepare the LCD by sending initial commands such as 38H, 01H etc. Each and every command sent to the LCD should be associated with a delay. Every time you send a command, call the command function 4. Create a COMNWRT subroutine to send the command to LCD 5. Create a WRITE subroutine to display the data sent by microcontroller on LCD 6. When smoke is not detected, LCD displays NORAML STATE . 7. When there is an interrupt the microcontroller will jump to ISR of that interrupt, it displays the room in which smoke is present and LED is turned on.
PROGRAM CODE:
ORG 0300H DB "SMOKE IN ROOM1" ORG 030EH DB "SMOKE IN ROOM2" ORG 031CH DB "NORMAL STATE" ORG 0003H LJMP INT_ONE ORG 0013H LJMP INT_TWO ORG 000H LJMP MAIN ORG 0030H MAIN: MOV IE,#85H MOV A,#38H ACALL COMNWRT ACALL DELAY MOV A,#0EH ACALL COMNWRT ACALL DELAY MOV A,#01H ACALL COMNWRT ACALL DELAY MOV A,#06H ACALL COMNWRT ACALL DELAY
CLR P2.4 AGAIN: CLR P2.4 MOV R6,#12D MOV DPTR,#031CH NEXT3: CLR A MOVC A,@A+DPTR ACALL WRITE ACALL DELAY INC DPTR DJNZ R6,NEXT3 CLR P0.1 MOV A,#01H ACALL COMNWRT ACALL DELAY SJMP AGAIN INT_ONE: MOV A,#80H ACALL COMNWRT ACALL DELAY SETB P2.4 MOV R1,#14D MOV DPTR,#0300H NEXT1: CLR A MOVC A,@A+DPTR ACALL WRITE ACALL DELAY
INC DPTR DJNZ R1,NEXT1 RETI INT_TWO: MOV A,#80H ACALL COMNWRT ACALL DELAY SETB P2.4 MOV R2,#14D MOV DPTR,#030EH NEXT2: CLR A MOVC A,@A+DPTR ACALL WRITE ACALL DELAY INC DPTR DJNZ R2,NEXT2 RETI COMNWRT: MOV P1,A CLR P2.0 CLR P2.1 SETB P2.2 ACALL DELAY CLR P2.2 RET WRITE: MOV P1,A SETB P2.0
CLR P2.1 SETB P2.2 ACALL DELAY CLR P2.2 RET DELAY: MOV R3,#40H HERE1: MOV R4,#0FFH HERE: DJNZ R4,HERE DJNZ R3,HERE1 RET END