Upload
others
View
13
Download
0
Embed Size (px)
Citation preview
Home Security System Based on PIC18F452 Microcontroller Md. Shafiul Islam
Department of Electrical Engineering
University of North Dakota
Grand Forks, ND 58202
Email: [email protected]
Abstract- We used PIC18F452 microcontroller for hardware and
software implementation of our home security system design.
Based on PIC18F452, our system can monitor doors and windows
of a house and can set alarm and warming signal to a nearest
police station if anybody tries to break in. This security system
also provides the functionality to identify the residents ID card to
get access to the house without turning on the warning signal and
alarm. Also, the security system provides a status that is not
monitoring the door and windows since there is some possibility
that the host do not want the system always checks the status of
their house.
I. INTRODUCTION
Home security system has become popular to avoid robbery
and theft. Due to tremendous improvement in microcontroller
unit now a day's embedded system can provide security by
monitoring people’s house. Our designed PIC18F452 micro-
controller based home security system can monitor windows
and doors of a house [1]. The objective is to build an integrated
home security system using traditional magnetic switch
equipped doors and windows. Through monitoring the status of
doors and windows, we proposed the home security system can
send the warning signal to host or police station and sound an
alarm when there is an attempt of break-in. Our design offers
two status of monitoring. One is security status. When this
status is switched on through a button, the home security
system starts to monitor all doors and windows and will send
the warning signal if there is an attempt of break-in. The other
status is free-entry status. When this status is switched on, the
home security system stops monitoring the door and windows
and people can enter or go out of the house without causing
any kind of warnings. Also, this home security system provides
a functionality that can let only the residents enter the house
without causing the warning when the security status is on.
When anybody swipes his/her ID card, then the system reads
the card using a card reader attached to the door and tries to
match that with its own password array which was assigned
previously. If the password array matches with the given one,
then the home security system will close all warning signals
and will let the residents of the house to get in.
Fig. 1. Block diagram of the home security system.
II. PIC MICROCONTROLLER
PIC18F452 is one of the most popular microcontroller
which has lot of features to design embedded systems [2]. This
microcontroller is based on Harvard architecture and has 40
pins with five input/output ports. This microcontroller unit can
be used for handling interrupt, A/D conversion, timer, CCP
modules and other purposes too [1]. Because of its high
capability and being cheap we used this Microcontroller unit to
design our system [5]. Because this microcontroller unit
provides lots of feature so we are able to do further
modification of our design depending on user demand. It is
possible to process data with PIC18F452 microcontroller of
978-1-4799-4774-4/14/$31.00 ©2014 IEEE
202
which oscillator frequency can reach up to 40 MHz [1].
Fig. 2. Pin diagram of PIC18F452 [1].
III. SOFTWARE SUBSYSTEM
Algorithm: We used software MPLAB IDE v8.87 and HI-
TECH ANSI C compiler provided by microchip for
programming and implementation of our design. Algorithm
steps of our code are given below:
1. Defining the microcontroller.
2. Defining constants and variables.
3. Define reset vectors and interrupt vectors.
4. Defining the I/O ports.
5. Configure RCON, INTCON, INTCON2 and
INTCON3 registers.
6. Defining PORTA as input to allow residents to enter
the house.
7. When first interrupt occurs it sets the security system
by turning on the red LED through PORTC.
8. Then if anyone tries to break the door or window it
will set the alarm and will create an output through
PORTC to notify the nearest police station.
9. Repeat from step 3 to 7.
Source code in C programming language:
#include<p18f452.h>
#include<delays.h>
#include<stdio.h>
#include<stdlib.h>
void low_ISR(void);
void high_ISR(void);
int id[5]= 0x00,0x50,0x49,0x51,0x52;
#pragma code high_vector=0x08
void high_interrupt(void)
#asm
goto high_ISR
#endasm
#pragma code
#pragma interrupt high_ISR
void high_ISR(void)
if (INTCONbits.INT0IF)
PORTCbits.RC2=1;
else if (INTCON3bits.INT1IF)
PORTC=0x03;
else if (INTCON3bits.INT2IF)
PORTC=0x03;
#pragma code low_vector = 0x18
void low_interrupt(void)
#asm
goto low_ISR
#endasm
#pragma code
#pragma interrupt low_ISR
void low_ISR(void)
#asm
retfie
#endasm
void main ()
203
while(1)
int i;
TRISA=0xFF;
TRISC=0x00;
if (PORTA==id[5])
PORTCbits.RC0=0;
PORTCbits.RC1=0;
PORTCbits.RC2=0;
Delay10KTCYx(100);
if (INTCONbits.INT0IF)
PORTCbits.RC2=1;
if (INTCON3bits.INT1IF)
PORTC=0x03;
else if (INTCON3bits.INT2IF)
PORTC=0x03;
RCONbits.IPEN=1;
INTCON=0x90;
INTCON2=0xF0;
INTCON3=0xD8;
for(i=0;i<5;i++)
Delay10TCYx(100);
IV. HARDWARE SUBSYSTEM
We used PORTC of PIC18F452 microcontroller as output
and PORTB as input. When the residents are leaving from
house and press a bottom which generates the first interrupt
INT0 (Fig. 4.), that activates the whole security system. Then if
any intruder tries to break in through door or window that will
generate other interrupts signal through PORTB and will set the
alarm and will send a signal to notify the nearest police station
through PORTC of the microcontroller unit.
Fig. 3. Hardware which are simulating the home security system.
Every residents of the house is assigned with a password in a
card. So when they want to get inside the house they just have
to swipe their card through the card reader. If their password
matches with the assigned password the security system will let
them in by deactivating the system (fig. 3.).
Fig. 4. Security system is turned on (red LED) after the first interrupt given (
Black wire).
The residents have to repeat the process again to activate their
home security system whenever they need. Until they activate
the security system by pressing a button it will remain
deactivated.
Interrupt
Section
Output
Section
1st Interrupt
204
Fig. 5. Graphical interface of MPLAB IDE v8.87 for coding and to program
the PIC18F452 microcontroller unit.
Fig. 6. Green LEDs simulating the result for alarm and output to notify the
nearest police station.
V. RESULT
In our embedded system lab we used capacitor of .1µF
and resistors of 512Ω to generate interrupts for the security
system through PORTB using push pull circuit. When we
have given first interrupt which is INT0 through RB0 pin of
the microcontroller unit our security system turns on by
showing the red LED (Fig. 4.). Then if anyone tries to break
in through the door or window that will generate INT1 and
INT2 sequentially through RB1 and RB2 pin which will set
the alarm and will give an output thorough PORTC to notify
the nearest police station about the break in (Fig. 6.). To
implement our design we used two green LEDs to simulate
the outputs due to hardware limitations. One green LED
simulates the alarm and another one simulates the output for
notifying nearest police station. If any residents want to enter
the house then they have to swipe their card which will be
read through PORTA, and if the password array in the card
matches with the given password array, the security system
will allow the resident to get in and will deactivate the
warning signals (Fig. 3.).
VI. CONCLUSION
Embedded systems can be designed for various purpose
and it's easy to modify. The source code and hardware we
developed for the home security system is very cheap,
reliable and easy to implement. It can be further modified as
needed. It also gives the perfect result as we desired
according to design. We didn't built the circuit on printed
circuit board though tested the design using breadboard in
embedded system laboratory.
REFERENCES
[1] http://www.microchip.com/
[2] Kaur, Inderpreet. "Microcontroller based home automation system
with security." International Journal of Advanced Computer Science
and Applications (IJACSA) 1.6 (2010): 60-65.
[3] Alheraish, A. "Design and implementation of home automation system."
Consumer Electronics, IEEE Transactions on 50, no. 4 (2004): 1087-
1092.
[4] Alkar, Ali Ziya, and Umit Buhur. "An Internet based wireless home
automation system for multifunctional devices." Consumer Electronics,
IEEE Transactions on 51, no. 4 (2005): 1169-1174.
[5] Azid, Sheikh Izzal, and Sushil Kumar. "Analysis and performance of a
low cost SMS based home security system." International Journal of
Smart Home 5, no. 3 (2011).
[6] Ab-Rahman, Mohammad Syuhaimi, Aswir Premadi, and Kasmiran
Jumari. "Remote monitor and control based access control system using
PIC microcontroller." IJCSNS 8, no. 11 (2008): 423
[7] Lamberti, Fabrizio, and C. Demartini. "Low-cost home monitoring
using a Java-based embedded computer." In Information Technology
Applications in Biomedicine, 2003. 4th International IEEE EMBS
Special Topic Conference on, pp. 342-345
[8] Mukhopadhyay, Subhas C., Anuroop Gaddam, and Gourab S.
Gupta. "Wireless sensors for home monitoring-a review." Recent
Patents on Electrical Engineering 1, no. 1 (2008): 201-1.
[9] Moghavvemi, M., and Lu Chin Seng. "Pyroelectric infrared sensor for
intruder detection." In TENCON 2004. 2004 IEEE Region 10
Conference, vol. 500, pp. 656-659. IEEE, 2004.
[10] Na, S. U. N. "The design of security alarm system for intelligent
residential area [J]." Journal of Shandong University of Technology
(Science and Technology) 6 (2005): 021.
2nd Interrupt
205