Security Alarm System With Backup Battery and Emergency Light Using Pic - Che Mazlan b Che Marof -...
-
Upload
zaheeraniz -
Category
Documents
-
view
76 -
download
0
Transcript of Security Alarm System With Backup Battery and Emergency Light Using Pic - Che Mazlan b Che Marof -...
SECURITY ALARM SYSTEM \KITH
BACKUP BATERY AND EMERGENCY LIGHT USING PIC
CHE MAZLAN BIN CHE MAROF
This report is submitted in partial filfillment of requirements for the award of
Bachelor of Electronic Engineering (Industrial Electronics) with honors
Fakulti Kejunrteraan Elektnnrik dan Kejumtaaan Komputer
Universiti Teknikal Malaysia Melaka.
April 2008
ABSTRACT
The purpose of this project is to introduce a security system with application
of back up battery. The security system is assembling by using PIC chip to control
this system and its will fbnctioning with the emergency light automatically when it
detect with trouble situation. This security system is designed by using a security
keypad circuit with Liquid Crystal Display (LCD and emergency light circuit. This
system is compatible with the Microchip 40 pins of PIC 16F877A. Then to ensure
this system is running properly it will operate with a back up batteries. This back up
battery will charge while this security system is running with electric power and
ready to apply when there is no electricity black out. The automatic emergency light
is presented when the main supply (230V AC) is available, it charges a 12V battery
up to 13.5V and then the battery is disconnected fiom the charging section. The
battery discharges up to 10.2V, it is disconnected from the load and the charging
process is resumed. If the mains voltage is available and there is darkness in the
room, load (bulb or tube) is turned on by taking power fiom the main power
otherwise the battery is connected to the load.
Matlamat utama projek ini adalah untuk memperkenalkan satu sistem
keselamatan dengan aplikasi tenaga elektrik sokongan yang menggunakan bateri.
Sistem keselamatan ini akan menggunakan kawalan mikro PIC untuk mengawal
sistem dan lampu kecemasan akan b e h g s i secara automatik dengan tenaga
sokongan walaupun terputus bekalan tenaga utama. Sistem keselamatan ini direka
menggunakan litar papan kekunci dengan LCD dan juga litar lampu kecemasan.
Sistem ini adalah bersesuaian dengan kawalan mikro PIC 16F877A yang terdiri
daripada 40 pin PIC. Untuk mempastikan sistem ini beroperasi dengan sernpurna, ia
menggunakan bateri sokongan. Bateri ini akan mengecas semasa sistem keselamatan
beropemi dengan tenaga elektrik dan bersedia untuk digunakan apabila berlaku
bekalan terputus. Lampu kecemasan akan berfirngsi secara automatik apabila tenaga
utama dibekalkan clan mengecas bateri 12 volt meningkat kepada 13.5 volt
seterusnya akan memutuskan bateri cas daripada bahagian cas. Bateri cas akan
menyahcas sehingga 10.2 volt kemudian akan memutuskan litar dari beban (lampu)
dan akan mengulangi proses mengecas sernula. Sekiinya terdapat tenaga utama dan
sitausi berlaku &lam bilik gelap, beban (lampu) akan berfbngsi dmgan tenaga utarna
sebaliknya juga dengan h g s i lampu dengan tenaga bateri.
CHAPTER 1
PROJECT INTRODUCTION
1.1 Introduction
This project will introduce an application of a security system with back up
battery. The security system is assembling by using PIC chip to control this system
and its will fbnctioning with the emergency light automatically when it detect with
trouble situation.
This security system is design by using a security keypad circuit with Liquid
Crystal Display (LCD), magnetic lock, buzzer, and emergency light controller. This
system is compatibility with the Microchip PIC 16F877A. Basically, the hardware is
a terminal controlled by a 40-pin PIC.
Then to ensure this system is running properly it will operate with a back up
batteries. This back up battery will charge while this security system is running with
electric power and ready to apply when there is no electricity black out.
1.2 Objective
The purpose of this project is to overcome the problem and apply the
existing system security and to design the security system with improvement
emergency light development. Besides this project will apply the software and
hardware development in theoretical also hands on.
1 3 Scope Of Work
The purpose of this project is to design an operational a security system
using keypad lock system, magnetic lock, back up power (rechargeable battery) and
emergency light which are operate well neither use the main power or back up
power. Beside it will save the energy when the light is switch on without to waste the
energy of back up battery.
Then this system is to construct a control security using a microchip PIC
16F877A. A coding or programming system will designed to operate the instruction
of the security system by assembly language on microprocessor.
1.4 Problem Statement
This research is carried out to overcome and used the security system
application using the PIC microchip. Besides this system will have some problem
to do connection between the light sensor circuit, power circuit and battery charger
and discharger circuit.
-
1.5 Methodology
The logical structure of design is shown in the block diagram on the right.
The central system will handle light sensor and back up battery and keypad input,
output information to LCD screen, emergency light, and makes alarm.
r
Sensa Back-u Batter
Figure 1.1 : Overall Block Diagram
1.6 Tbesis Structure
The content of this thesis is about the flow of the project. This thesis is
divided into five chapters to provide the understanding of the whole project. For the
Chapter I, the overview of the project is briefly discussed.
The Chapter I1 covers the project theory, perspective, method that are used to
solve the problem and any hypothesis that related with the research of methodology.
The Chapter III explains the research methodology in this project. The
Chapter IV is covers the expected result of this project.
Finally, the Chapter V discusses whole content of this project.
CHAPTER Il
LITERATURE REMEW
2.1 Introduction
This chapter discusses about the project theory, perspective, methodology and
any hypothesis that related with the research methodology.
23 Project Theory and Concept
This project is present the method that improves the existing alarm security
system. The original system with emergency light warning is not perfectly operated
since it does not use a backup power to support the lack of main power. To overcome
this problem, this project uses PIC (Programmable Integrated Controller). The
security features that is used in this project is keypad lock and magnetic lock with
added the emergency light for a warning and to prevent fiom stopping the electric
current. By designing the circuit to prevent over charge can extend the life of a
battery, and can be as a prevention of electric current in emergency and according to
the lightness around. The emergency light is modified by using the light sensor
circuit to control the battery life time.
The keypad lock and magnetic lock is a kind of the security feature that used
for door lock. Basically, this project is to identify the interface between the
with the hardware. The PIC 16F877A will be programmed to control
the insertion of pin number on keypad either to lock or unlock the magnetic lock.
The insertion of the pin number is then identified whether the number is true or not.
2.3 Project Components Description
This part will discuss about several component that used in this project.
Basically the kind of components and equipment are important also give a major
effect for this project achievements. Below are explanations about for the
components.
23.1 Light Dependent Resistor (LDR)
A Light Dependent Resistor (LDR) is special type of resistor that reacts to
changes in light level. The resistances of the LDR changes as different amounts of
light fall on the top window of the device. This allows electronic circuits to measure
changes in light level.
11 ->
L r n
: , Ligbt irtersity i (Lux) 1 I IQht
Figure 2.1 : Resistances versus Light Intensity
LDR is used in automatic street lamps to switch them on at night and off
during the day. They are also used within many alarm and others application to
measure light levels.
The LDR is a type of analogue sensor. An analogue sensor measures a
continuous signal such as light, temperature or position rather than a digital on-off
signal like a switch. The analogue sensor provides a varying voltage signal. This
voltage signal can be represented by a number in the range 0 and 255. The range 0 is
assumed to very dark and 255 is assumed to bright light.
A l i h l
5v
a3 D, (CJ - - 8
dark V
ov - b
Time
Figure 2.2: Voltage versus Time
LDR can be used in two ways and the simplest way to use an LDR is as a
simple on-off digital switch. When the light level is above a certain value which is
called the threshold value the LDR will provide an on signal, when the light level is
below a certain value the LDR will provide an off signal.
In this case the LDR is used in a potential divider with a standard resistor.
The value of the standard resistor sets the 'threshold value'. For miniature LDR a
suitable value is depend on the circuit requirement. If desired the fixed resistor can
be replaced by a variable resistor so that the threshold value can be 'tuned' to
different light values.
A more versatile way of using the LDR is to measure a number of different
light values, so that decisions can be made at varying light levels rather than just one
fixed threshold value. A varying value is known as an 'analogue' value, rather than a
digital 'on-off value.
The type of LDR that we prefer used in this project is the cadmium sulphide
(CdS) photoconductive cells with spectral responses similar to the human eye and the
cell falls with increasing light intensity.
Figure 2.3: Cadmium Sulphide (Cds) Photoconductive Cells
23.2 Liquid Crystal Display (LCD)
Figure 2.4: LCD Model HD44780
HD 44780 is one of the most popular LCD modules used in industry. This
module is monochrome and comes in different shapes and sizes. The display
provides a 16-pin connecter to interface to the external world.
23.2.1 The Liquid Crystal Description.
The liquid crystal is in the condition to have the nature of the liquid (Fluidity)
and the nature of the solid (Crystal). When the temperature is low, the object
becomes the solid condition. When the temperature rises, it becomes a liquid
condition. Moreover, when the temperature rises, it becomes the gaseous condition.
P o l r r i z i q I t ' s !?a* tpistCd 1 1 - the c r y s t a l
f t l tcr of tk Itquld crystal rd ~t
Cr-al af th. I ~qund eryr ta l 1.Y) *need ~ d l a n ~ thc dstch)
Figure 2.5: The Structure of the TN (Twisted Nematic) Liquid Crystal Display
Polariznw ,
f i l t e r Eacarse I + 8m.t M' t x ~ s t e d .
ttu clcctr-t~c f trld).
Figure 2.6: The Crystal of the Liquid Crystal Matches the Constant Direction
In the liquid crystal condition, it is the neutrality of the solid and the liquid.
The material of the biphenyl of some k i d which has this nature at the normal
temperature is used for the liquid crystal display. With the material which we know
well, the one of the liquid crystal condition is the soap water or the cuttlefish ink.
They are the material to have the structure of crystals while being the liquid.
Because the cuttlefish ink is always black, it isn't possible to use for the
indicator.
23.2.2 Pin Assignment
The pin assignment shown in Table 2.1 is the industry standard for character
LCD modules and functions.
Table 2.1 : The Pin Assignment
instruction or data register
2 3 3 Voltage Regulator
The LM78XX series typically has the ability to drive current up to 1A. For
application requirements up to 150mA, 78LXX can be used. As mentioned above,
the component has three legs: Input leg which can hold up to 36VDC Common leg
(GND) and an output leg with the regulator's voltage. For maximum voltage
regulation, adding a capacitor in parallel between the common leg and the output is
usually recommended. Typically a O.1MF capacitor is used. This eliminates any high
frequency AC voltage that could otherwise combine with the output voltage.
VCC
GND
15
16
Figure 2.7: LM7805
23.4 Relay
LED+
LED-
Figure 2.8: Relay and Symbol
Backlight positive input
Backlight negative input
A relay in figure 2.17 is a simple electromechanical switch made up of an
electromagnet and a set of contacts. Current flow through the coil of the relay creates
a magnetic field which attracts a lever and changes the switch contacts. The coil
current can be ON or OFF so relay have two switch positions and they are double
throw (changeover) switches. Relays allow one circuit to switch a second circuit
which can be completely separate h m the fust. For example a low voltage battery
circuit can use a relay to switch a 230V AC mains circuit. There is no electrical
connection inside the relay between the two circuits; the link is magnetic and
mechanical. The coil of a relay passes a relatively large current, typically 30mA for a
12V relay, but it can be as much as 10- for relays designed to operate h m lower
voltages. Most ICs (chips) cannot provide this current and a transistor is usually used
to amplify the small IC current to the larger value required for the relay coil. Relays
are usually Single Pole Double Throw (SPDT) or Double Pole Double b w
(DPDT) but they can have many more sets of switch contacts, for example relays
with 4 sets of changeover contacts are readily available.
23.5 Transistor
3 NPN
Figure 2.9: Symbol of NPN Transistor
The transistor used to amplify the current for the relay is an NPN transistor,
2N2222A. The pin sequence is as shown in Figure 3. Beware that wrong sequence
will burn the transistor.
23.6 Magnetic lock
A magnetic lock is a simple locking device that consists of an electromagnet
and armature plate. By attaching the electromagnet to the door M e and the
armature plate to the door, a current passing through the electromagnet attracts the
annature plate holding the door shut. Unlike an electric strike a magnetic lock has no
interconnecting parts and is therefore not suitable for high security applications
because it is possible to bypass the lock by disrupting the power supply.
Nevertheless, the strength of today's magnetic locks compare well with conventional
door locks and cost less than conventional light bulbs to operate.
Figure 2.1 0: Magnetic Lock
23.7 PIC 16M177A
This powerhl (200 nanosecond instruction execution) yet easy-to-program
(only 35 single word instructions) CMOS FLASH-based 8-bit microcontroller packs
Microchip's powerfi~l PIC architecture into an 40- or 44-pin package and is upwards
compatible with the PIC 1 K5X, PIC 12CXXX and PIC 1K7X devices.
Features of the device:
i. 256 bytes of EEPROM data memory self programming
ii. ICD (in circuit debugging function)
iii. 2 Comparators
iv. 8 channels of 10-bit Analog-to-Digital (AID) converter
v. 2 captureIcompare/PWM functions
vi. synchronous serial port can be configured as either 3-wire Serial Peripheral
Interfkce ( S P Y or the 2-wire Inter-Integrated Circuit (IT) bus
vii. Universal Asynchronous Receiver Transmitter (UART).
23.7.1 Device Overview
Below is the specific information about the following devices PIC 16F877A
which are existing in 40-pin and 44-pin packages. The available features are
summarized in Table 2.2.
Table 2.2: The PIC 16F877A Device Features
23.7.2 General Description Integrated Circuit 16F877A
Figure 2.1 1 : Shows the Pin Diagram of The PIC 16F877A.
Table 2.3: The Description Pin Name of PIC16F877A
PinMamc
OSC 1:CLhl C S t 1
C h l
OSZ2CLh3 0s""
C h Z
- hltL~:'JUJ -
hKL?
:/Y
F!.*c:.~K~ W C MiC
P.A-:.w- PA? I;E; 7
P . . . . P.& tJ.2 .$'-=- cc.ap
F%?:.WG.'~aS* P.4? &.ti? ;:q=+
F!AA:Xd:i:t IOJ- F??s
TICK1 ClOUT
~ k . 5 : k h U . c ~ ~ ~ - R.Af Chd - 2 5 C,~JUT
QFN Pinb
.;-
33
' 9
- o
23
21
2d
PClP Pi*
1:
14
1
2
3
L
7
bQ!P Type
C u
C
1
s
I :5 I
I -3 I
I :3 I
C
I:= I
1 ;3
C
1-2 I
C
PLCC Pi&
r 4
:5
2
3
r
5
8
B a r Type
p-,.,-.t>~,~~[+
-
S
n-
TT-
TT,
TT,
ST
TT-
TQFP P i 9
23
31
13
l a
43
1
C C 2 2 2 2
C 2 3 2 2 1
14
Oorcription
2s: llstx i ~ ~ b l c * tx:end clodi nmt Cs:kb-cyshl i r x t 37erW-J e x 4 s6u-S inat. 2- tc 'er w-ec .:~nf adred ,-I RC modil ='+*-A%@ .C'.'OS. E*lcrJ d3CIC ZE-6 i rst L M p rsrociatec
pir $nsIlw 05C: :see CSZm;CL*:'. CSCSCLYO pn).
3s:lIbtx c,~stzl=-c 3:k -3- CS: lkt>- c.'-fsbl CXF'J!.
C = r +:-s to qs-2 a rssona- I 7 Crpta 2s:Astsruce. 17 RC rnxs C 3 C F.-I =xpmCi<O. 'R7kk w s 1:d +? C r r ? ~ w ~ ~ y sf O S t 1 a d .kno&s h nstrxt io cyck rate
'.'m. = tzV {in=:: v 3rcprnrn~a .i~I-ap IWPAI. klastw C tsr ~?#et:o n n t . Th s fi s w xi34 CW' F i e ~ E 1 3 F e C & s .
F - ~ r z m - ng =:tap nxt .
=3-4 is a Wirsric w l 1-3 F w .
Wid 1:c. bw =g i r x t 16.
Digii? I:C. Aw ag i r x t '.
miei.* I.'=. C w 00 ira.32. b!: r'trrt *&age :Lw: inpx C:~psritx 5.J*Er 3~tWt .
Mg'ra 1:c. LwCgkLbLt5. 4:: .?lt.tw v & v :klghr iw:.
mitar 1.C - C r - f * wter mf .&nd as O-tp~t T mtC e m J o l d -&put C.c?~draW '
Digiirs' 1:C. 4 w q i r x t 4 . SJ slave K K. bout. Cs-rpsrstJr 2 out%*.
23.73 Block Diagram of PIC16F877A
Figure 2.12: Block Diagram of PIC 16F877A
Dwioc 3:-.:- .-574.:. ,.-.r:c7: " - - . .
m n Flascl
1.' .m.:r E* a=-::
wk*mory
'2: E f l + ~ * - - a:.: ~ f i e ;
D m EEPROM
128 ?.yes zce 31.7~
This part describes the software that is used in this project. The soha re is
used for circuit simulation, code programming for PIC 16F877A, and for Printed
Circuit Board (PCB) etching.
2.4.1 SourceBoost IDE
SourceBoost IDE (Integrated Development Environment) is a low cost
development environment for Microchip Inc; PIC processors. SourceBoost IDE
includes a modern editor, a project manager, C, C+t, and Pascal cross-compilers, a
Project wizard, an assembler level debugger, a clock accurate simulator, and a
number of virtual devices.
- *. - *c I lei- . .L
5 - r x - 1CaglD--g ( // This a r e w e IS wcrlmgcd nua.EYI =-lei I / on t o an ~ l u port co mln BC0l .U rs: /I access co cbc LCD pi-. BoM.IAN mi I / Tne bits arc ollosolrcd from B0011UI m e : / / lo. order up. WULI -111
4ata : I: // be pin BO. 1
at.:?? i:.? - c / / on to port B Isr &"s 6) =5r<2ce IIC i C l d iz-i,:. let :i>l ? ' X I - - e?~.e,7.. :re r.c* 1 - // T I*-. : 5 i c e v 2 3 // LCD WI sadrcsr for the second l ine srn Ty..s. -m-a~--~~~ - 10120 << Jl,01C,t,6)i
// These bgret -d t o be sent to the LCD // =o s t w c 1r up. // The f o l l o ~ i n g arr -a tor n c t i w I / rht I I O porr direecion rtgi-rer.
arr-:c.. lCaglm--g cnru: LCD-aCITL - 10.0.0.0.0); // lor w i r e aode a l l pi- a:r:?ct lcd-pin--g csn-: LCD-mAD - 10.0,0,0,15): // For rcsd mde data pins
srn M-rcad-bV=O ( " . . .......... -- . . . . .
! < D
. . . . . . . . . . = Irwasnmrmla... , Irwas-..
bed,... Roahpnarhad.. ..m- . . . Red,...
Figure 2.13: SourceBoost IDE to Create the C Language
2.4.2 PROTEUS VSM
PROTEUS VSM allows professional engineers to run interactive simulations
of real designs, and to reap the rewards of this approach to circuit simulation.
It is possible to simulate complete micro-controller systems and thus to
develop the software for them without access to a physical prototype.
Structurally, Proteus 6 Professional is separated into two main components,
which are ISIS 6 Professional and ARES 6 Professional. ISIS 6 Professional mainly
involved on circuit designing and simulation.
:...... ............................................................... ..................................................................... a:::::::::::::::::::::::::: : ................................................................................................... ...................................................................................................... ...................................................................................................... ..................................................................................................... ..................................................................................................... ..................................................................................................... ...................................................................................................... ..................................................................................................... ..................................................................................................... .....................................................................................................
C 3 F + + l b l u j u ~ m ~ what - - - - . - - - - -- -. --- - - - - - - - - - . -
Figure 2.14: Proteus 6 Professional Simulation
2.43 PCB W i r d 3 Printed Circuit Board Design Software
One of the steps in completing a project is designing the circuit and
constructing the PCB (Printed Circuit Board). PCB is not compulsory to been made
but PCB will make the construction of the circuit easier and neat especially when
constructing a wmplicated or small circuit. There is a lot of software that can be
used to design the schematic diagram for the circuit such as multisim and many
more. Different software is needed to design the PCB for the circuit. There is also
soha re that can provide both of this application in single software. This is much
more useful because it could convert the schematic diagram into a PCB layout
according to the user requirement. Every of software has a different advantage and
disadvantages. It can be downloaded from internet w brought h m a suitable shop.
Figure 2.15: PCB W i d 3 Printed Circuit Board Design Software
METHODOLOGY
3.1 Introduction
This chapter study is to describe the method or process that is used in this
project. This chapter discusses about the development and explanation of the
methodology or processes.
3 3 , Methodology Flow Chart
The flow chart is used to explain the procedure and the step that will be use to
accomplish this project. It will show the process step by step until the end of this
project. To accomplish this project, there are a few steps that will be taken and
shown by the figure next page.
3.2.1 Flow Chart
Research Source c +
Learning the C
Hardware I I component I
Repair Design circuit on PCB board
4
I
+ + Design the circuit
using Proteus Software
r Write the coding
NO
Repair using the SourceBoost
Repair
A c J A
+ The system operates well
Repair
Figure 3.1 : Methodology Flow Chart
Combine the two parts and operate with each others
3 3 Flow Cbart Description
Following the flow chart, the thesis will be explained in description below.
A
33.1 Project Title
Firstly, the project title is identified since the title is a prior aspect in any
project.
3.3.2 The Information of Project Improvement
After identifying the most appropriate project title, the information about the
project must be collected through reference source. This also includes the
specification of the Integrated Circuit that will be used.
3 3 3 Research and the Basic Project Circuit.
In order to gather the correct information about the project, the objective of
the project must be clear. A basic to the circuit project such as circuit design, circuit
size, component to be used and other things should be identified and understood
before starting the project. All the problem statement has to be considered to ensure
the accomplishment of the project.
33.4 Research on the Project Circuit.
The component that is required in this project is listed before constructing the
circuit. The electronic component listed is IC16F877A, LCD, Capacitor and others.
The figure below shows the circuit project which including two part of
circuit. Those circuits are keypad security and emergency light circuits. This part will
give an explanation of operating block diagrams.