Beruflich Dokumente
Kultur Dokumente
LOCK
PROJECT REPORT
SUBMITTED BY
KABIL DAS K
KRISHNA PRIYA VINOD M
KURIAN MATHEW
in partial fulfilment for the award
of the degree of
BACHELOR OF TECHNOLOGY
In
MG UNIVERSITY: KOTTAYAM
APRIL 2011
MG UNIVERSITY- KOTTAYAM
BONAFIDE CERTIFICATE
Certified that this project report MICROCONTROLLER
BASED DIGITAL CODE LOCK is the onafide ork of KABIL
DAS K, KRISHNA PRIYA VINOD M and KURIAN MATHEW who
carried out the project work under my supervision.
SIGNATURE
PROF. ARUMUGASAMY
HEAD OF THE DEPARTMENT
SIGNATURE
Mr. DEEPAK.P
STAFF IN CHARGE
ASST. PROFESSOR
DEPARTMENT OF ECE
KADAYIRUPPU
S.N.G.C.E
KOLENCHERY
KADAYIRUPPU
ACKNOWLEDGEMENT
Department
their
support
and
ABSTRACT
TABLE OF CONTENTS
CHAPTER NO.
TITLE
PAGE
NO.
1.
INTRODUCTION
2.
PROJECT DESCRIPTION
7
8
BLOCK DIAGRAM
CIRCUIT DIAGRAM
17
2.
1
2.
2
3.
3.
1
3.
2
3.
3
17
POWER SUPPLY
18
CIRCUIT EXPLANATION
18
4.
FLOW CHART
19
5.
ALGORITHM
20
6.
PROGRAM
22
7.
COMPONENTS DETAILS
40
7.
1.
7.
2
7.
3
7.
4
7.
5.
RESISTOR
40
CAPACITOR
40
TRANSISTOR
41
DIODE
42
INTEGRATED CIRCUITS
42
8.
PCB FABRICATION
46
9.
APPLICATIONS
48
FUTURE ENHANCEMENT
49
11.
CONCLUSION
49
12.
REFERENCES
49
13.
APPENDICES
50
10.
LIST OF TABLES:
1. PIN DESCRIPTION OF AT89C2051
2. PORT ALTERNATE FUNCTIONS
LIST OF
FIGURES:
A. BLOCK DIAGRAM
B. PIN OUT OF AT89C2051
C. BLOCK DIAGRAM OF AT89C2051
D. PCB FBRICATION
E. FLOW CHART
F. PINOUT FOR IC LM7805
G. BLOCK DIAGRAM OF IC LM7805
H. PINOUT FOR BC547
1. INTRODUCTION
15
p ro gr a m
mo r y
mi c r oco n t ro l le r
of
has
Kilobytes.
a
The
2. PROJECT DESCRIPTION
2.1 BLOCK DIAGRAM
Figure: A
2.2 BLOCK DIAGRAM EXPLANATION
So,
it
has
two
distinctive memory spaces of 64K X 8 size for both program and data.
It is based on an 8 bit central p r oc e s s ing un it w i t h an 8 b i t
A c c u mu l at o r a n d a no t he r 8 b it B re gis te r as ma in
processing
blocks. Other portions of the architecture include few 8 bit and 16 bit
registers and 8 bit memory locations. Each 8031 device has some
amount of data R A M
built
in
the
device
for
inter
n a l p r o c e s s i n g . T h i s a r e a i s u s e d f o r s t a c k operations and
temporary storage of data. This base architecture is supported with on
chip peripheral functions like
t he
(8751)
with
reprogrammable
times.
the
microcontrollers
reading
user's
programs and executing the expected task as per instructions stored there in.
Its primary elements are an 8 b it A r it h me t ic Lo gic U n i t ( A LU ),
A c c u mu l at o r ( A cc ), fe w mo r e 8 bit registers, B register, Stack
Pointer (SP), Program Status Word (PSW) and 16 bit re g is te rs ,
P r o g ra m C o un t e r ( PC ) a nd D a ta Po int e r R e g i s t e r ( D P TR ). The
ALU (Acc) performs arithmetic and logic functions on 8 bit input
variables.
Arithmetic
1
0
Timers/Counters
8031 has two 16 bit Timers/Counters capable of working in different
modes. Eac h co ns is ts of a ` Hi g h ' b yt e a nd a ` Lo w ' b y t e w hic h
c a n be ac ce s s e d und e r software. There is a mode control register
and a control register to configure these t ime rs / c o un t e rs in nu mb e r
of w a ys . T he s e t i me rs c a n be us ed to mea s ure t ime intervals,
determine pulse widths or initiate events with one microsecond resolution up to
a maximum of 65 millisecond (corresponding to 65, 536 counts). Use software
to get lo ng er d e la ys . Wo rk i n g as c o un t e r, t he y c a n a c c u mu l at e
o c c u rr e nc e s of external events (from DC to 500 KHz) with 16 bit precision.
In o u r p ro je c t we a re us ing 8 b i t mi cr oc o nt ro ll e r AT 89 C 2 05 1
,
1
2
DESCRIPTION
The AT89C2051 is a
8-
The
de v ic e
is
Figure : B
BLOCK DIAGRAM
Figure: C
VCC
GND
Supply voltage.
Ground.
Port 1
Port 3
RST
XTAL1
XTAL2
Table:1
PORT ALTERNATE FUNCTIONS:
Port Pin
Alternate functions
P3.0
P3.1
P3.2
P3.3
P3.4
TABLE: 2
3. CIRCUIT DIAGRAM
3.1 MAIN CIRCUIT DIAGRAM
FIGURE: D
Main
Part
of
the
above
Circuit
diagrams
is
the
Microcontroller AT89C2051. The Keypad was the input device and it was
connected in a matrix format so that the numbers of ports needed are reduced.
The Microcontroller reads a four-digit p a s s wor d t h r o ug h t he Ke yp ad.
T he n the M ic r oco n t ro l le r co mp a r e s the fo u r d i g i t p a s s w o r
d
d a n d i f i t i s e q u a l t h e n t h e M ic r o co n t ro l le r w il l s w it c h
on t he mot o r fo r
p a s s w o rd fo r mo re t h a n
w il l be s w i tc he d on un t i l a r i gh t
t h re e t i mes t he n an a lar m
password was pressed
4. FLOWCHART
Figure: E
5. ALGORITM
1. START
2. initialise lcd , keypad
3. clear lcd
4. print Enter lock code on lcd
5. get 5 char long password using matrix key pad
6. if input = 12345 then
6.1 print Enter master code
6.2 get 10 char long password using matrix key pad
6.3 if input = masterlock then
6.3.1 change user password
6.3.2go to step 4
6.4 else
6.4.1 print wrong code on lcd
6.4.2 go to step 4
7. else
7.1 if input = userlock or input = default lock then
7.1.1 unlock the lock
7.1.2 retry count = 3
2
0
2
0
2
1
6. PROGRAM
Delay program:
#include "delay.h"
void delayus(unsigned char delay)
{
while(delay--);
}
void delayms(unsigned char delay)
{
while(delay--)
delayus(149);
}
Keypad program:
#include "keypad.h"
#include "delay.h"
bit keystatus = FALSE;
void keypad_init()
{
keyport &=0x0F;
key = k+1;
while(!col2);
return key;
}
if(!col3)
{
key = k+2;
while(!col3);
return key;
} j+
+;
}
k+=3;
keyport |= 0x80>>i;
delayms(10);
}
return FALSE;
}
unsigned char translate(unsigned char keyval)
{
if(keyval<10)
return keyval+'0';
else if(keyval==10)
return 'x';
else if(keyval==11)
return '0';
else if(keyval==12)
return 'e';
}
LCD program:
#include "lcd.h"
#include "delay.h"
#include <REG2051.H>
unsigned char code lockicon[]={0xe, 0xa, 0x1f, 0x1f, 0x1b, 0x1b, 0xe, 0x0};
unsigned char code unlockicon[]={0xe, 0x2, 0x1f, 0x1f, 0x1b, 0x1b, 0xe, 0x0};
unsigned char code ex[]={0x1f, 0x1b, 0x1b, 0x1b, 0x1b, 0x1f, 0x1b, 0x1f};
unsigned char code ok[]={0x0, 0x1, 0x3, 0x16, 0x1c, 0x8, 0x0, 0x0};
void lcd_reset()
{
lcd_port =
0xFF;
delayms(20);
lcd_port = 0x03+LCD_EN;
lcd_port = 0x03;
delayms(10);
lcd_port =
0x03+LCD_EN; lcd_port
= 0x03; delayms(1);
lcd_port =
0x03+LCD_EN; lcd_port
= 0x03; delayms(1);
lcd_port =
0x02+LCD_EN; lcd_port
= 0x02; delayms(1);
}
void lcd_init ()
{
unsigned char
i; lcd_reset();
lcd_cmd(LCD_SETFUNCTION);
font. lcd_cmd(LCD_SETVISIBLE+0x04);
blink.
shift
.
lcd_cmd(LCD_SETMODE+0x02);
Display
// Automatic Increment - No
lcd_cmd(LCD_SETCGADDR); for(i=0;i<8;i+
+)
lcd_data(lockicon[i]);
for(i=0;i<8;i++)
lcd_data(unlockicon[i]);
for(i=0;i<8;i++)
lcd_data(ex[i]); for(i=0;i<8;i+
+)
lcd_data(ok[i]);
lcd_cmd(LCD_SETDDADDR);
80h.
}
void lcd_cmd (char cmd)
{
}
void lcd_data (unsigned char dat)
while(*str){
lcd_data(*str++);
}
}
Lock program:
#include "keypad.h"
#include "lcd.h"
#include "delay.h"
#include "lock.h"
unsigned char code masterlock[10]="1234567890", defaultulock[5]="54321";
unsigned char userlock[5], input[10];
extern bit newlock;
bit check(unsigned char *first, unsigned char *second, unsigned char len)
{
unsigned char i=0;
for(i=0;i<len;i++){
if(first[i]!=second[i])
return FALSE;
}
return TRUE;
}
void setulock(){
char status;
retry:
lcd_cmd(LCD_CLS);
lcd_cmd(LCD_SETDDADDR);
lcd_str("Enter Mastercode");
lcd_cmd(0xC0);
lcd_data(LOCK);
lcd_data(':');
status = getinput(10);
if(status == TRUE){
if(check(input,masterlock,10)){
retry1:
lcd_cmd(LCD_CLS);
lcd_str("Enter new
code"); lcd_cmd(0xC0);
lcd_data(LOCK);
lcd_data(':');
status = getinput(5);
if(status == TRUE){
lcd_cmd(LCD_CLS);
lcd_data(OK);
lcd_str("lock code
saved!"); newlock =
TRUE; store_code();
delayms(250);
delayms(250);
delayms(250);
delayms(250);
goto exit;
}
else if(status == RETRY)
goto retry1;
else if(status == EXIT)
3
0
goto exit;
}
else{
lcd_cmd(LCD_CLS);
lcd_str("WRONG
CODE!"); delayms(250);
delayms(250);
delayms(250);
delayms(250);
goto exit;
}
}
else if(status == RETRY)
goto retry;
else if(status == EXIT)
goto exit;
exit:;
}
char getinput(unsigned char max)
{
i=0;
while(1){
while(!(key=getkey()));
key = translate(key);
input[i]=key;
if(key=='x'){
if(i==0)
return EXIT;
i--;
lcd_cmd(0xC2+i);
lcd_data(' ');
lcd_cmd(0xC2+i);
}
else if(key=='e')
{
return TRUE;
}
else{ i+
+;
if(i>max){
lcd_cmd(LCD_CLS);
lcd_data(EX);
lcd_str(" Code too
Long..."); delayms(250);
delayms(250);
delayms(250);
delayms(250);
return RETRY;
}
lcd_data('*');
}
void store_code(){
unsigned char i;
for(i=0;i<5;i++)
userlock[i]=input[i];
}
Main program:
#include "lcd.h"
#include "keypad.h"
#include "lock.h"
#include "delay.h"
void main(){
unsigned char
status,i=0; bit
lockstatus;
lcd_init();
keypad_init();
while(1){
lcd_cmd(LCD_CLS);
lcd_str("Enter lock
code"); lcd_cmd(0xC0);
lcd_data(LOCK);
lcd_data(':');
status = getinput(5);
if(check(input,"12345",5)){
setulock();
goto done;
}
if(status == TRUE){
if(newlock)
lockstatus = check(input,userlock,5);
else
lockstatus = check(input,defaultulock,5);
if(lockstatus){
retrycount = 3;
lockpin = 0;
lcd_cmd(LCD_CLS);
lcd_data(OK);
lcd_str(" Lock is");
lcd_cmd(0xC0);
lcd_str("deactivated!");
delayms(250);
delayms(250);
delayms(250);
delayms(250);
lcd_cmd(LCD_CLS);
lcd_data('0'+retrycount);
delayms(250);
delayms(250);
delayms(250);
delayms(250);
if(retrycount==0){
blocked:
lcd_cmd(LCD_CLS);
lcd_data(EX);
lcd_str("BLOCKED");
for(i=0;i<150;i++)
{
bus=~bus;
delayms(250);
}
lcd_data(EX);
lcd_cmd(0xC0);
lcd_data(LOCK);
lcd_data(':');
status = getinput(10);
if(check(input,masterlock,10)){
retrycount=3;
lcd_cmd(LCD_CLS);
lcd_data(EX);
lcd_str("UNBLOCKED");
lcd_data(EX);
delayms(250);
delayms(250);
delayms(250);
delayms(250);
}
else{
lcd_cmd(LCD_CLS);
lcd_data(EX);
lcd_str("WRONG
CODE"); lcd_data(EX);
delayms(250);
delayms(250);
delayms(250);
delayms(250);
goto blocked;
}
}
}
}
done:;
}
}
7. COMPONENTS DETAILS
7.1. Resistor:
Resistor is a component that resists the flow of direct or alternating electric
c irc u it . Res is to rs ca n l i mi t or d ivi de t h e c ur re nt , red u ce the
v o lt a ge , p ro te c t an electric circuit, or provide large amounts of heat
or light. An electric current is the
movement
of
charg
c ur re nt d e ns i ty i s directly proportional to
temperature is constant.
7.2 Capacitor:
Capacitor or electric condenser is a device for storing an electric charge. The
simplest form of capacitor consists of two metal plates separated by a non
touching layer called the dielectric. When one plate is charged with
electricity from a direct current or electrostatic source, the other plate
have induced in it a charge of the opposite sign; that is, positive if the
original charge is negative and negative if the original charge is
4
0
capacitance.
coils
as
resonant
circuits
in
radios
d u c e d i n a w i d e v a r i e t y o f f o r m s . A i r , M i c a , C e ra mic s ,
P ape r, O il , and
Vac uu ms are us e d as d ie l ec t r ic s d e pe nd i n g
7.3 Transistor:
Transistor is a device which transforms current flow
resistance pa t h to
h i gh
res is ta n ce
p a t h.
It
is
from
low
ca pa b le
of
7.4 Diode:
Diode is a electronic device that allows the passage of current in
only one d i r e c t i o n . T h e f i r s t s u c h d e v i c e s w e r e v a c
u u m - t u b e d i o d e s , c o n s i s t i n g o f a n e v ac ua te d gl as s or s
t ee l
an
e n ve l op e c o n t a in in g t w o e le c tr o d es a c a t h o d e a nd
anode.
kinds of
p o s i t ive
vo l ta ge
(on-card)
regulation
for
elimination
to obtain
43
FIGURE: F
FIGURE: G
Figure: H
4
5
8. PCB FABRICATION
The first step of assembling is to produce a printed circuit
board. The fabrication of the program counter plays a crucial
role in the electronic field. The success of the circuit is also
dependent on the PCB. As far as the cost is concerned, more
than 25% of the total cost is for the PCB design and
fabrication.
The board is designed using a personal computer. The
layout is drawn using the softare Adoe PageMaker .. The
layout is printed in a uffer sheet using a laser proedure.
First, a negatie sreen of the layout is prepared with the help
of a professional screen printer. Then the copper clad sheet is
kept under this screen. The screen printing ink is poured on the
screen and brushed through the top of the screen. The
printed board is kept under shade for few hours till the ink
becomes dry.
The etching medium is prepared with the un-hydrous ferric
chloride water. The printed board is kept in this solution till the
exposed copper dissolves in the solution fully. After that the
board is taken out and rinsed in flowing water under a tap.
The ink is removed with solder in order to prevent oxidation.
Another screen, which contains component side layout, is
prepared and the same is printed on the component side of
the board. A paper epoxy laminate is used as the board. Both
the component and the track layout of the peripheral PCB is
given at the end of this report.
PCB LAYOUT
COMPONENT LAYOUT
9. APPLICATIONS
Our electronic door lock performed as expected. We were able to implement all
the functions specified in our proposal. The biggest hurdle we had to overcome
with this project was interfacing the micro controller with the hardware
components. We f e e l t h a t t h i s e l e c t r o n i c d o o r l o c k i s v
e r y m a r k e t a b l e b e c a u s e i t i s e a s y t o u s e , comparatively
inexpensive due to low power consumption, and highly reliable. This
door lock is therefore particularly useful in applications such as hotel room door
locks, residential housing, and even office buildings.
10.
E lec t r ic a l
de vices
FUTURE ENHANCEMENTS
s uch as L i ghts ,
Co mp ut e r e tc c a n be
11.
CONCLUSION
This project is meant for security systems whose access is only for respected
authorities. Using a microcontroller the password entered is checked with the
stored password and then does the corresponding operations. Here we use a 5
digit password for better secrecy.
12.
REFERENCES
13. APPENDICES
5
0