Académique Documents
Professionnel Documents
Culture Documents
ABSTRACT
TABLE OF CONTENTS
CHAPTER NO.
PAGE
NO.
TITLE
1.
2.
2.
1
2.
2
3.
3.
1
3.
2
3.
3
INTRODUCTION
PROJECT DESCRIPTION
BLOCK DIAGRAM
CIRCUIT DIAGRAM
17
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
.
8.
RESISTOR
40
CAPACITOR
40
TRANSISTOR
41
DIODE
42
INTEGRATED CIRCUITS
PCB FABRICATION
9.
APPLICATIONS
10.
FUTURE ENHANCEMENT
11.
CONCLUSION
12.
REFERENCES
13.
APPENDICES
42
46
48
49
49
49
50
LIST OF TABLES:
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
a
the
number keypa
keypads
ar
b i t microcontroller AT89C2051. This is one
e connected to the 8
of
popular
a n d t he
the
Microcontrollers.
It has only 20 pins
re
are 15
in p u t /o u tp u t li n e s . T he mic r o c o n t
p ro g r a me mo r
ro lle r
ha s a
m
y
monitor the
o f 2 Kilobytes. The microcontroller continuously
keypad
and if somebody enters the password it will check the entered password
with the password which was stored in the memory and if it they are
same then the microcontroller will switch on the corresponding device.
The system will allow the person who knows the password and it will
not allow who dont know the password and the system will also show
the persons who try to break the protection barrier.
2. PROJECT DESCRIPTION
2.1
BLOCK DIAGRAM
Figure: A
2.2 BLOCK DIAGRAM EXPLANATION
devic
in the
e
for internal
use
fo
stac
d
r
k
operations and
(8051)
with
user's program
Arithmetic
U n it ( A LU ),
register, Stack
bit re g is te rs
,
(D P TR ) . T he
the two inputs or then retains a portion of the result. For other
instructions, it can be used as another general purpose register.
10
Timers/Counters
DESCRIPTION
TheAT89C2051
is a
bitmic r o c o mp u
te r
w it h 2
e ra s a b le re a d
ma n u fa c t u re d
it y
o n ly
low-voltage, high-performance
CMOS
8Kb y te s o f Fla s h Pr o g ra mma b a n
le
d
me mo r y (P ER O M ) .
us in g
A t me l s
non-volatile
The
d e v ic e is
h ig h
memory
dens
12
Figure : B
13
BLOCK DIAGRAM
Figure: C
14
VCC
GND
Port 1
Supply voltage.
Ground.
Port 1 is an 8 -bit bidirectional I/O port. Port pins P1.2
to P1.7 provide internal pull-ups. P1.0 and P1.1 require
external pull-ups. P1.0 and P1.1also serve as the
positive input (AIN0) and the negative input (AIN1),
respectively, of the on-chip precision analog
comparator. The Port 1output buffers can sink 20 mA
and can drive LED displays directly. When 1s are
written to Port 1 pins, they can be used as input s. When
pins P1.2 to P1.7 are used as inputs and are externally
pulled low, they will source current (IIL) because of
the internal pull-ups. Port 1 also receives code data
during
Flash programming and program verification.
Port 3
Po rt 3 p in s P3 . 0 to P3 . 5 , P3 . 7 a re s e v e n
b id ir e c t io n a l I /O p ins w it h internal pull-ups. P3.6
is
hard-wired as an input to the output of the on -chip
comparator and is not accessible as a general purpose
I/O pin.
The Port 3 output buffers can sink 20 mA. When 1s are
written to Port 3p in s t h e y a re p u l le d h ig h b y t h e
in te r n a l p u l l - u p s a n d c a n b e us e d a s inputs.
As
inputs, Port 3 pins that are externally being pulled low
will s o u r c e c u rr e ( II L) b e c a u s e o f t h e p u ll - u
nt
ps.
Po rt 3 a ls o s e r ve
s
t he functions of various special
features of the AT89C2051 as listed below. Port 3 also
receives some control signals for Flash programming
and programming verification.
RST
R e s e t in p u t . A ll I /O p in s a re r e s e t to 1 s a s s o
on
a s R S T go e s h ig h . Holding the RST pin high for two
XTAL1
XTAL2
Alternate functions
P3.0
P3.1
P3.2
P3.3
P3.4
TABLE: 2
16
3. CIRCUIT DIAGRAM
3.1 MAIN CIRCUIT DIAGRAM
17
FIGURE: D
The
Main
Part
of
the
above
the
Circuit
diagrams
is
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 w t h r o u g h t h e Ke y p a
ord
d.
T he n t he M ic r o c o n t ro lle r c o mp a r e s fo u r d ig it p a s s w o
t he
rd
withthe number
ogrammed
equal
ill
then
s w itc h
which
and
if
on
is
it
pre-pr
is
t h e M ic r o c o n t ro lle r
t h e mo t o r fo r
t he d o o r a nd if w e e n te r t he w r o n g p a s s w o rd fo r mo re t h
a n t h re e t i me s t he n a n a la r m w ill b e s w itc he d o n u n t il a r
ig h t password was pressed through the Keypad.
The Password was stored in the EEPROM and the password can be
changed at anytime using the same keypad. To change the password
dial 12345 Old password - New Password. The power supply section is
the important one. It should deliver constant output regulated power
supply
18
4. FLOWCHART
Figure: E
19
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
go to step 4
6.4
else
7.1.3
7.1.2
retry count = 3
20
7.1.4
7.1.5
goto step 4
7.2
else
21
6. PROGRAM
Delay
program:
#include
"delay.h"
void delayus(unsigned char delay)
{
while(delay--);
}
void delayms(unsigned char delay)
{
while(delay--)
delayus(1
49);
}
Keypad
program:
#include
"keypad.h"
#include
"delay.h"
bit keystatus =
FALSE; void
keypad_init()
{
keyport &=0x0F;
22
23
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';
24
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;
25
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);
lcd_cmd(LCD_SETVISIBLE+0x
04);
lcd_cmd(LCD_SETMODE+0x02
);
shift.
lcd_cmd(LCD_SETCGADD
R); for(i=0;i<8;i++)
lcd_data(lockicon[i]);
26
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);
// Address DDRAM with 0
offset 80h.
}
void lcd_cmd (char cmd)
{ lcd_port = ((cmd >> 4) & 0x0F)|
LCD_EN; lcd_port = ((cmd >> 4)
& 0x0F);
lcd_port = (cmd & 0x0F)|
LCD_EN; lcd_port = (cmd &
0x0F); delayus(200);
delayus(200);
}
void lcd_data (unsigned char dat)
{ lcd_port = (((dat >> 4) & 0x0F)|LCD_EN|
LCD_RS); lcd_port = (((dat >> 4) &
0x0F)|LCD_RS);
lcd_port = ((dat & 0x0F)|LCD_EN|LCD_RS);
27
28
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_SETDDADD
R); lcd_str("Enter
Mastercode");
lcd_cmd(0xC0);
lcd_data(LOCK);
lcd_data(':');
status =
getinput(10);
if(status ==
TRUE){
if(check(input,masterloc
k,10)){
retry1:
lcd_cmd(LCD_CLS);
29
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)
30
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)
{unsigned char i,key;
31
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);
32
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"
33
void main(){
unsigned char
status,i=0; bit
lockstatus;
lcd_init();
keypad_ini
t();
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,"1234
5",5)){
setulock();
34
goto done;
}
if(status ==
TRUE)
{ if(newlo
ck)
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("deactivat
ed!");
delayms(250);
delayms(250);
delayms(250);
delayms(250);
lcd_cmd(LCD_CLS
);
35
lcd_str("Press '#'
key to");
lcd_cmd(0xC0);
lcd_str("lock
again!");
while(getkey()!
=12); lockpin = 1;
lcd_cmd(LCD_CLS);
lcd_data(OK);
lcd_str("Lock is
active!");
delayms(250);
delayms(250);
delayms(250);
delayms(250);
}
else{
retrycount--;
lcd_cmd(LCD_CL
S); lcd_data(EX);
lcd_str(" Wrong
Code!");
lcd_cmd(0xC0);
lcd_str("Tries left =
");
36
lcd_data('0'+retry
count);
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);
37
if(check(input,masterlock,1
0)){
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);
38
goto blocked;
}
}
}
}
done:;
}
}
39
7. COMPONENTS DETAILS
7.1. Resistor:
7.2 Capacitor:
7.3 Transistor:
41
7.4 Diode:
of
an
s te e l
e n ve lo p e c o n ta in
e le c tr o d e s
in g
two
devices
e v a c ua te d g
a cathod
e
and an
anode.
p o s it iv e
3 - te r min a l
e
vo lta g
Th e LM 7 8 0 5 mo n o lit h ic
re g u la to rs e mp
lo y
internal current-limiting, thermal shutdown and
safe-area compensation, making t he
e s s e nt ia in d e s t r uc t ib le .
m
lly
If
a d e q u a te h e a t s in k in g is p r o v id t he y c a n deliver over 1.0A
ed,
output
42
including
local
for
elimination
us
e
use
be
d
Features:
Complete specifications at 1A load
Output voltage tolerances of 2% at Tj = 25
Line regulation of 0.01% of VOUT/V of VIN at 1A
load Load regulation of 0.3% of VOUT/A
Internal thermal overload protection
Internal short-circuit current limit
Output transistor safe area protection
43
FIGURE: F
FIGURE: G
Figure: H
45
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 software Adobe PageMaker 6.5. The layout is printed
in a buffer sheet using a laser procedure. First, a negative screen 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.
46
PCB LAYOUT
47
COMPONENT LAYOUT
9. APPLICATIONS
lock is ver
y
comparatively
48
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
49
13. APPENDICES
5
0