You are on page 1of 25

PROGRAMMABLE CODE LOCK

INTRODUTION

Today every body is very consious about the security of their assets and
home appilance. So home security system is very popular nowadays but it also have some
drawbacks. In case conventional home security system, any one can operate it that means
any one can swtich it on or off without permission of the owner. Introduction of code lock
home security system can greatly solve this problem. By using this system only user can
operate home security stystem. In this system, when correct code is entered the controller
senses it and triggers motor and whenever faulty code is entered the microcontroller senses
it and alarm turns on. Hence user can change the code and can keep it secret.
BLOCK DIAGRAM

CIRCUIT DIAGRAM
V C C

S E V E N S E G M E N T

V C C
47 0 oh m s *7 U 6

16
7 13 4
O U TA B I/ R B O
a

VCC
V C C 6 12 5
b

O U TB R B I
4 11 3
O U TC LT
c

R 1 U 4
D 16 A 2 10 7 R 2 R A T 89C 51
O U TD IN A +12 V
d

3 R

40

31
CC

1 9 1 3 9 21
O U TE IN B P 0 .0 P 2 .0
e

3 8 22

EA
P 0 .1 P 2 .1

VCC
9 15 2 3 7 23
O U TF IN C P 0 .2 P 2 .2
f

3 6 24
10 14 6 3 5 P 0 .3 P 2 .3 25

9
O U TG IN D P 0 .4 P 2 .4
g

3 4 26 1 16
P 0 .5 P 2 .5 IN A O U TA

GND
5 7 447 A 3 3 27 2 15
DP

P 0 .6 P 2 .6 IN B O U TB

COM
3 2 28 3 14
P 0 .7 P 2 .7 4 IN C O U TC 13
JP 1

8
1 10 5 IN D O U TD 12
2 P 1 .0 P 3 .0 11 1 6 IN E O U TE 11
3 P 1 .1 P 3 .1 12 2 7 IN F O U TF 10
4 P 1 .2 P 3 .2 13 3 IN G O U TG
5 P 1 .3 P 3 .3 14 4
P 1 .4 P 3 .4 5

GND
6 15
7 P 1 .5 P 3 .5 16 6
P 1 .6 P 3 .6 7 V C C
8 17 U LN 200 4

8
P 1 .7 P 3 .7 8 U 7
1 19 8 H E A D E R
X 1 C 26
2 18 9 V C C +12 V
X 2 R S T

GND
K 1
10 M FD 4
TO KEY BOARD R E LA Y S P D T 3
6M hz

20
C 25 C 15 5
1
18p F 18p F J6 2
R 12 2
L M 7805 1 V C C
V C C 10K
U 1 m o to r TO ALARM
3 1 J3
V O U T V IN TO MOTOR
D 3 1
J10
C 27 C A 2
1
GND

C A P N P b uzz er
2
C 23 3
1N 400 7
2

D 1 1 5 -0 -1 5
+12 V C A
2 2 0 0 M F D /2 5 v
U 5
1N 4 007
3 1
V O U T V IN
GND

C 24
C A P N P
2

L M 7812

CIRCUIT DESCRIPTION

Micro controller:

A Micro controller is used for controlling entire circuits and to


maintain timings. Here a micro controller named AT89c51 from Atmel Corporation
is used for that purpose. AT89c51 is an bit micro controller has 40 pins arranged in
4 I/O ports, that ports are used here for connecting LCD module and to interface
with the load.
As shown in above figure micro controller is wired with a crystal for clock
and each pin of the crystal is connected to ground through a 18 pF capacitor to avoid
noise pulses in the clock. Here a 1 MHz crystal is used that gives 1MHz clock for
the micro controller.

Micro controller’s RESET pin is connected to an RC circuit as


shown in above figure. This will give a high pulse to the RESET pin at time of
starting. This will reset the micro controller means start execution from 0000h. It is
essential for a micro controller circuit. When the power is switched ON charge in
capacitor will be zero then the reset pin will get high voltage, capacitor starts
charging then the voltage across the RST pin will decrease, micro controller starts
execution.
KEY BOARD-:

Keyboard is used to input the code. Keyboard is continously sensed


by the microcontroller. Keyboard used is a 4Χ 3 matrix type keyboard. Rows and
columns are connected to port 3 of microcontroller . The three columns are
connected to P3.4, P3.5, and P3.7 which is programmed as input and is set as 0. The
four row are connected to P3.0, P3.1, P3.2, and P3.3 which is programmed as output
and is continously sensed. When this iall this keys at logic high no key is pressed
and when any of pin output goes low the two of output is made logic high and even
then if the input pin remains low then the key of the column which is not made high
is pressed. In this way key board is sensed by the microcontroller.
BCD to 7- SEGMENT DISPLAY DRIVER -:

A74LS47 IC is used as a display decoding/driving IC. This is used as


a display control. It is simple chip to use but bear in mind that its output go low
when activated thus requiring a common anode configured display unit. There two
types of decoder driverv corresponding to two types 7-segment displays. Indicator
logic circuits inside the 7447 converrt the four bit BCD input to the 7 bit output
which are active low 7446 can also be used in place of 7447.

7-SEGMENT DISPLAY-:

It consist of seven LED’s labelled ‘a’ through ‘g’. By forward


biasing different LEDs we can display the digit ‘0’through’9’. 7 segment indicators
are of two types common anode and common cathode .In common anode type ,
anodes of all 7 Led ‘s are tied togetyher whil;e in common cathode type all cathodes
are tied together .When common anode type is used a current limiting must be
connected between LED segments and ground .When common cathode type is used
resistor must be connected between every LED segment and +Vcc.
Relay switching:

Relays are connected to micro controller through UlN 2004 relay


driver. ULN 2004 has seven internal relay drivers that may be used to control seven
relays. Inputs of ULN 2004 is connected to micro controllers port which is used to
ON/OFF the relays. When port output is logic 1 the corresponding relay will be
switched ON, as well as when the out put is logic 0 the relay will be switched OFF.
These relays are used to control the loads that are to be controlled.
POWER SUPPLY

The present chapters the operation of power supply circuit built using
filter, rectifier, and then voltage regulators. Starting with an ac voltage, a steady dc
voltage is obtained by rectifying the ac voltage, then filtering to a dc level, and
finally, regulating to obtain a desired fixed dc voltage .The regulator is usually
obtained from an IC voltage regulator unit, which takes a dc voltage, which remain
the if the input dc voltage varies, or the output load connected to the dc voltage
changes
The ac voltage, typically 220 v rms is connected to a transformer, which step that ac
voltage down to the level for the desired dc output. Diode rectifier then provides a
full wave rectified voltage that is initially filtered by simple capacitor filter to
produce a dc voltage. This resulting dc voltage usually has some ripple or ac voltage
variation. The regulated circuit can use this dc input to provide a dc voltage that not
only has much less ripple voltage but also remain the same dc value even if the
input voltage vary some what, or the load connected to the output dc voltage
changes. This voltage regulation is usually obtained using regulator IC .

VOLTAGE REGULATOR

The voltage regulator plays an important role in a power supply unit .The primary
purpose of the regulator is to aid the rectifier and filter circuit in providing a constant dc
voltage to the device. Power supplies without regulators have an inherent problem of
changing of dc voltage values due to variations in the load or due to fluctuations in the ac
linear voltage. With regulator connected to the dc output, the voltage can be maintained
with a close tolerant region of the desired output.

IC VOLTAGE REGULATIOR

Voltage regulator comprises a class of widely use ICs. Regulator IC outs contain the
circuit for reference source, comparator, amplifier, control device, and overload protection
all in a single IC. Although the central construction of the IC is some what difference from
that described for discrete voltage regulator circuits, the central operation is much the
same .IC units provides regulation of either a fixed positive voltage, a fixed negative
voltage or an adjustable set voltage.

A power supply can be built using a transformer connected to the ac supply line to step
the ac voltage to desired amplitude, then rectifying that ac voltage, filtering with a
comparator RC filter, if desired, and finally regulating the dc voltage using IC regulator

The fixed voltage regulator has an unregulated dc input voltage, vi, applied to one
input terminal and a regulated output dc voltage, from a second terminal, with third
terminal connected to the ground. For a selected regulator, IC device specifications list a
voltage range over which the input voltage can vary to maintain a regulated output voltage.
Over a range of load, current .The specifications also list the amount of output voltage
change resulting from a change in load current (load regulation) or input voltage (line
regulation).

IC O/p Voltage (Vo) Minimum I/p Voltage (Vi)


7805 5 7.3
7806 6 8.3
7808 8 10.5
7810 10 12.5
7812

Example of monolithic regulator s are 78xx/79xxseries and 723general purpose


regulators.78xx series are three terminal, positive fixed voltage regulators .In 78xx the last
two numbers indicate the output voltage, the 7812 represent a 12 v regulator

The third IC terminal is connected to ground. While the input voltage may vary over
some permissible voltage range and the output load may vary over some acceptable range.
The output voltage remains constant within specified voltage variation limits

78xx series are three terminal positive fixed voltage regulators. There are some output
voltage options available such as 5, 6, 8,10,12,18and 24 v.

PCB LAYOUT
FABRICATION OF PCB

The PCB must be fabricated first. Then the components are soldered carefully to PCB.
We should keep in mind that the quality of soldering affects the quality of output. The
procedure for fabricating the PCB for setting up the circuit of any multi purpose
project is described below.

PCB MAKING

Making of Printed Circuits Boards (PCBs) is as much as art on a technique


particularly so when they are to fabricated in very small numbers. There are several
ways of drawing PCB patterns and making the final boards. The making of PCB patterns
and making PCB essentially involves two steps.

1. Preparing the PCB drawing and


2. Fabricating the PCB itself from the drawing.

The traditional method of drawing with complete placement of parts, taking a


photographic negative of the drawing, developing the image of negative formed on photo
sensitized copper plate and dissolving the excess copper by itching is a standard practice
being followed in large scale operations. However, for small-scale operations, where large
numbers of copies are not required, the cost saving procedure presented here may be
adopted.

PCB DRAWING

Making of PCB drawing involves some preliminary considerations such as placement


of components on a piece of paper. Locating holes, deciding the diameters of
various holes, the optimum area of each components should occupy the shape
and location lands for connecting two or more components at a place, full space
utilization and prevention of over crowding of components at a particular place.
There is no other way to arrive at the conclusion than by trial and error. For
anchoring leads of component 1mm diameter holes and for fixing PCB holding
screws to the 3mm diameter holes can be made. Following these hints, a sketch
of PCB is made.

PCB FABRICATION
The copper clad PCB laminate is now prepared by rubbing away the oxide, grease etc.
With fine emery paper or sand paper on this, the final PCB drawing may be traced by
using a carbon paper. Clips are used to prevent the carbon paper from slipping while PCB
pattern is being traced on the laminate. Only the connecting lines in PCBs, slants and
holes, should be traced. The components position can be marked on the PCBs reverse side
if desired.

The marked holes in PCB may be drilled using 1mm or 3mm drill bits and the traced
PCB pattern created with black, quick drilling enamel paint, using a thin brush or a small
metal case. In case, if there is any shorting of lines due to spilling of paint, there may be
removed by scrapping with a blade or knife, after the paint has dried.

After drying, 20-30gms of Ferric chloride in 75ml of water may be heated to about
60deg and over the PCBs placed with its copper side upwards in a plastic tray. Stirring the
solution helps speedy etching. The dissolution of unwanted copper would take about 45
minutes. If etching takes longer, the solution may be heated again and the process is
repeated. The paint on the pattern can be removed by rubbing with a rag soaked in thinner,
turpentine or acetone. The PCB may then be washed and dried.

Depending on the wiring diagram, the resistors are taken care at first, and then the ICs
are soldered.
FLOW CHART
.org 0000h
sjmp key0
.org 0050h

key0:mov sp,#50h
mov r0,#00h
mov 74h,#06h
mov 75h,#07h
mov 76h,#08h
mov 77h,#09h
mov r1,#00h
mov r2,#00h
mov p2,#0ffh
mov p1,#0ffh
clr p0.0
clr p0.1
key12: acall key1
ljmp store

key1:mov p3,#0feh
jb p3.7,skip1
ljmp a0
skip1: jb p3.5,skip2
ljmp a1
skip2: jb p3.4,skip3
ljmp a2

skip3: mov p3,#0fdh


jb p3.7,skip4
ljmp a3
skip4: jb p3.5,skip5
ljmp a4
skip5: jb p3.4,skip6
ljmp a5

skip6: mov p3,#0fbh


jb p3.7,skip7
ljmp a6
skip7: jb p3.5,skip8
ljmp a7
skip8: jb p3.4,skip9
ljmp a8

skip9: mov p3,#0f7h


jb p3.7,skip10
ljmp a9
skip10: jb p3.5,skip11
ljmp a10
skip11: jb p3.4,skip12
ljmp a11

skip12: ljmp key1

a0: lcall delay3


loop0: jnb p3.7, loop0
lcall delay3
mov a,#00h
ret
a1: lcall delay3
loop1: jnb p3.5, loop1
lcall delay3
mov a,#01h
ret

a2: lcall delay3


loop2: jnb p3.4, loop2
lcall delay3
mov a,#02h
ret

a3: lcall delay3


loop3: jnb p3.7, loop3
lcall delay3
mov a,#03h
ret

a4: lcall delay3


loop4: jnb p3.5, loop4
lcall delay3
mov a,#04h
ret

a5: lcall delay3


loop5: jnb p3.4, loop5
lcall delay3
mov a,#05h
ret

a6: lcall delay3


loop6: jnb p3.7, loop6
lcall delay3
mov a,#06h
ret

a7: lcall delay3


loop7: jnb p3.5, loop7
lcall delay3
mov a,#07h
ret

a8: lcall delay3


loop8: jnb p3.4, loop8
lcall delay3
mov a,#08h
ret

a9: lcall delay3


loop9: jnb p3.7, loop9
lcall delay3
mov a,#09h
ret

a10: lcall delay3


loop10: jnb p3.5, loop10
lcall delay3
mov a,#10h
ret

a11: lcall delay3


loop11: jnb p3.4, loop11
lcall delay3
mov a,#11h
ret
store:clr p0.1
cjne r0,#05h,str
ljmp cc
str: cjne r0,#04h,str0
cjne a,#10h,com1
mov r2,#01h
ljmp chan
com1: cjne a,#11h,str6
mov r2,#02h
ljmp chan
str0: cjne a,#10h,str1
ljmp key12
str1: cjne a,#11h,str2
ljmp key12
str2: cjne r0,#03h,str3
inc r0
mov 73h,a
mov p1,a
ljmp key12
str3: cjne r0,#02h,str4
inc r0
mov 72h,a
mov p1,a
ljmp key12
str4: cjne r0,#01h,str5
inc r0
mov 71h,a
mov p1,a
ljmp key12
str5: cjne r0,#00h,str6
inc r0
mov 70h,a
mov p1,a
str6: ljmp key12

chan:mov a,70h
cjne a,74h,alarm1
mov a,71h
cjne a,75h,alarm1
mov a,72h
cjne a,76h,alarm1
mov a,73h
cjne a,77h,alarm1
mov p1,#0ffh
mov p2,#0ffh
cjne r2,#01h,elev
inc r0
ljmp key12
elev: setb p0.0 ;motor open
lcall delay
clr p0.0
mov r0,#00h
mov r1,#00h
dis15: ljmp key12

alarm1: mov p1,#0ffh


setb p0.1
lcall delay1
clr p0.1
mov r0,#00h
mov r1,#00h
lcall delay1
ljmp key12

cc: cjne r1,#04h,chan0


cjne a,#11h,dis15
mov r0,#00h
mov r1,#00h
mov p1,#0ffh
mov p2,#0ffh
ljmp key12
chan0: cjne a,#10h,cc1
ljmp key12
cc1: cjne a,#11h,cc2
ljmp key12
cc2: cjne r1,#03h,chan1
inc r1
mov 77h,a
mov p1,a
ljmp key12
chan1: cjne r1,#02h,chan2
inc r1
mov 76h,a
mov p1,a
ljmp key12
chan2: cjne r1,#01h,chan3
inc r1
mov 75h,a
mov p1,a
ljmp key12
chan3: cjne r1,#00h,chan4
inc r1
mov 74h,a
mov p1,a
chan4: ljmp key12

.org 032dh
ljmp key0

;**********************delay for key debouncing *********************************;


delay3:
mov r6,#05h
d8 mov tmod,#10h
mov tl1,#6ah
mov th1,#0aah
d9: setb tr1
jnb tf1,d9
clr tf1
djnz r6,d8
ret

delay: mov r5,#0ah


s8: mov r6,#0ah
s9: mov tmod,#10h

mov tl1,#3ch
mov th1,#0afh
disp:
setb tr1
jnb tf1,disp
clr tr1
clr tf1
djnz r6,s9
djnz r5,s8
ret
delay1: mov r5,#02h
s1: mov r6,#0e4h
s2: mov tmod,#10h
mov tl1,#00h
mov th1,#00h
setb tr1
disp1: jnb tf1,disp1
clr tr1
clr tf1
djnz r6,s2
djnz r5,s1
ret

You might also like