Professional Documents
Culture Documents
Participants
Nisar Ahmed Rana
Shekh M. Arshad
0
Digital Security Lock
TABLE OF CONTENTS
Abstract 2
1 Introduction 3
1.1 Scope 3
2 Technical Background 4
3 Technical Approach 5
3.1 Preliminary Design 5
3.2 Programming the Microcontroller 5
3.3 Pseudo-Code & Flow Chart 6
3.4 Testing 7
3.4 Circuit Designing and Simulation 7
3.5 Practical Implementation 8
3.6 Troubleshooting 9
4 Circuit Explanation 10
4.1 Microcontroller Module 10
4.2 Power Board 11
4.3 LCD Board 12
5 Results and Conclusions 13
6 Future work 13
7 Appendix A 0
Appendix B 1
7.1 ATMEL AT89S52 Datasheet 1
7.2 ULN2003A Datasheet [2] 3
7.3 ABSOLUTE MAXIMUM RATINGS 4
8 Bibliography 5
8.1 References 5
8.2 Books 5
ABSTRACT
This project is a digital security lock made by using AT89S52 microcontroller. It is
designed for automobiles (i.e. SUZUKI MEHRAN). It will be attached on its dashboard
the user has a keypad for interaction and an LCD for instruction. The user will enter the
code when the instruction “Enter the Code” will appear on the LCD. In case of right code
it will grant the access to the user otherwise it will ask again three times. Failing to do
this the user have to enter the master code which is six digit if it is right then the user
have access to start the car otherwise the car will be locked and a security alarm start to
ring.
S COPE
This project has huge industrial applications. It can be used as automobiles Thief Lock
and can also be used as a code lock at many places. This code lock can be made more
secure by introducing finger print sensor with code.
TECHNICAL BACKGROUND
Security is a major concern in today world. The automobiles need new technologies for
their security. Different industries are working on automobiles security project such as
car tracker or digital locks. These code locks contains different techniques. Many of the
code lock are quite expensive which can‟t be used everywhere. We have also designed a
digital security lock for a car which contains a keypad to enter the code and an LCD to
display instructions on it. It consists on a microcontroller to control its operation. It is
simple but secure code lock which cost much less than the code locks manufactured by
different industries. It can be mounted on a car or can be attached separately with any
automobile. The same code lock can be used as a door lock the user has to interface the
motor and alarm with it.
Technical Approach
The design process of digital security lock consists on four steps.
1. Preliminary Design
2. Programming the Microcontroller
3. Circuit Designing and Simulation
4. Practical Implementation
5. Troubleshooting
P RELIMINARY D ESIGN
Due to knowledge, gained till now, it has decided by our team that the design should be
as simple and secure as possible. Our motto was to design a simple and secure security
lock which can be usable for common person. Other factors for this consideration are cost
effect and limitation to embedded system design.
Check the D7 pin for busy condition of LCD (if D7=1 then wait until D7=0).
Send the data to D0-D7 (0x38) to initialize 5X7 matrix, (0x01) to clear screen, (0x02) to
go to home, (0x80) to go to the beginning of 1st line, (0xC0) to move to the beginning of
2nd line or (0x0F) to set the cursor blinking.
Set Rs & Rw ‘0’ and apply a 20ms high to low pulse to use it as a command.
Send the char as a data on D0-D7.
Set Rs=1 & Rw=0 and apply a 20ms high to low pulse to use it for printing data.
T ESTING
After completing the whole code the program was debugged using KEIL debug tool. The
errors were corrected easily. We have created the object file in KEIL in INTEL *.hex file
format. The clock speed used was 11.0592MHz.
P RACTICAL I MPLEMENTATION
After completing the simulation we have generated its PCBs using ARES a package of
Proteus. We placed the PCB packages of all the components we have used in schematic
diagram. After completing the PCB layout we have implemented it through the following
processes:-
PCB layout of power board is shown in the figure 4.1. This layout was printed on the
paper and then converted to printed circuit board.
PCB layout of microcontroller module is shown in figure 4.2. There was no PCB for
LCD board we made its circuit on zero board because it was a simple circuit and we have
to connect the wires parallel to the LCD.
T ROUBLESHOOTING
Troubleshooting is one of the difficult task in designing a prototype of a project. After
completing all the circuits and making necessary connections we have faced some
problems in LCD display. The keypad and other circuits were working properly.
LCD does not display text: The whole port 3 and 3 pins of port 0 were checked. The pin
P0^0 was damaged so pin P0^1 was used in its place.
Text doesn’t hold on the LCD: Pins RS and E were interchanged so they were
corrected.
LCD didn’t show complete words: LCD didn‟t show complete words. Some of the
characters in a word were replaced with unwanted symbols. The reason for it is that we
haven‟t initialized the LCD before use but it work properly during simulation because it
doesn‟t need initialization.
Circuit Explanation
The complete circuit consists on the following three portions.
Microcontroller Module
Power Board
LCD Board
M ICROCONTROLLER M ODULE
A microcontroller module has been used as a main circuit. It has parallel as well as serial
port communication circuits in it.
We have used parallel port communication. It has four IDC connectors connected to its
four ports. Clock and reset circuit are also on it.
P OWER BOARD
The four output ports are connected on the power board through IDC connectors. Port 1
and Port 2 are used for keypad. We have used four pins of each port for keypad. An eight
bit connector was used to connect the eight pins of two ports (4 pins per port). The
keypad is connected to this eight bit connector.
Port 3 is connected with eight bit data bus of LCD. Rs, R/W and E (enable) pins are used
from port 0. VCC, VEE & VDD are provided externally from the power board. These 14
pins are connected to another IDC connector which connects these 14 pins with LCD on
another board.
Two outputs from Port 0 are connected to ULN2003A which act as a current buffer. First
output is applied at pin 1A (pin # 1) and its output from pin 1C (pin # 14) is again
connected to pin 6A (pin # 6) and final output is taken at pin 6C (pin # 11). Second
output is applied at pin 2A (pin # 2) and its output from pin 2C (pin # 13) is again
connected to pin 7A (pin # 7) and final output is taken at pin 7C (pin # 10). This is done
due to two reasons. 1st is that the ULN2003 act as a logic inverter. It converts a „1‟ into
„0‟ and second time it is again inverted from „0‟ to „1‟. So we finally get the same output
which we have applied as an input with a current amplification. 2nd is that we need more
current to turn the relay on so due to double buffer we get enough current to derive a
relay.
The output of 1st relay is connected to the ignition coil of a car. The car will not start till
then relay is on (conducting). When the relay is off (cut) the signal will not reach to the
ignition coil so it will not start. When logic „1‟ came it gets amplified from ULN2003 and
turns the relay on so the car will start. The output of second relay is connected to a ringer.
When the user enter the Master (Administrator) password wrong for three attempts the
ringer will start ringing.
LCD BOARD
A small circuit is made using zero board. The 8 pin IDC connector take the LCD data
inputs from power board (Port 3) and connect them with this board. Here these pins are
connected with pin 7 to pin 14 of LCD. Pin 4, 5 & 6 are connected to port „0‟. A 5V
power is also provided on LCD board. Pin 1, 3 and 16 are connected to ground. Pin 2 and
15 are connected to +5V VCC.
FUTURE WORK
This project can be used as a door lock at secure places by addition of finger prints sensor
module. The person has to enter the code and then finger print sensor will scan its finger
prints and then it will grant access.
Also it can be used as a wireless digital lock for automobiles. The person has to enter the
code from handheld module which will transmit then signal after verification to open the
car then he can start it. I am also working on it if a person breaks the whole system and
directly start the car then the handheld module or through mobile communication the user
can stop the car. It will send a signal to another module which directly cut the ignition
coil from batteries and it will stop. The car can also be tracked later on.
Appendix A
The whole programming code is given below.
#include <REGX51.H>
#include<string.h>
#define COL P2
#define ROW P1
void main()
{
unsigned char ch[5];
unsigned char count;
bit n;
rel1=rel2=0;
lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x01);
lcdcmd(0x85);
lcdprint("Welcome",7);
lcdcmd(0xC4);
lcdprint("Theif Lock",10);
msdelay(1000);
lcdcmd(0x01);
lcdcmd(0x80);
count=0;
for(count=0;count<3;count++)
{
lcdprint("Enter The Code",14);
lcdcmd(0xC0);
lcdcmd(0x0F);
ch[0]=getkey();
lcddata(ch[0]);
ch[1]=getkey();
lcddata(ch[1]);
ch[2]=getkey();
lcddata(ch[2]);
ch[3]=getkey();
lcddata(ch[3]);
ch[4]=getkey();
lcddata(ch[4]);
msdelay(500);
n=check(a,ch,5);
if(n==1)
{
count=10;
lcdcmd(0x01);
lcdcmd(0x02);
lcdprint("Access Granted",14);
rel1=1;
rel2=1;
msdelay(500);
}
else
{
lcdcmd(0x01);
lcdcmd(0x02);
lcdprint("Access Denied",13);
rel1=rel2=0;
msdelay(500);
}
lcdcmd(0x01);
lcdcmd(0x02);
}
if(count>5)
{
lcdcmd(0x01);
lcdcmd(0x80);
lcdprint("Thanx 4 Using",13);
msdelay(50);
lcdcmd(0xC0);
lcdprint("Thief Lock",10);
while(1);
}
master_code();
lcdcmd(0x01);
lcdcmd(0x02);
lcdprint("Thanx 4 using",13);
msdelay(25);
lcdcmd(0xC0);
lcdprint("Thief Lock",10);
while(1);
}
void lcdready()
{
busy=1;
rs=0;
rw=1;
while(busy==1)
{
en=0;
msdelay(1);
en=1;
}
return;
}
while(1)
{
do
{
ROW=0x00;
colloc=COL;
colloc&=0x0F;
}
while(colloc!=0x0F);
do
{
do
{
msdelay(20);
colloc=COL;
colloc&=0x0F;
}
while(colloc==0x0F);
msdelay(20);
colloc=COL;
colloc&=0x0F;
}
while(colloc==0x0F);
while(1)
{
ROW=0xFE;
colloc=COL;
colloc&=0x0F;
if(colloc!=0x0F)
{
rowloc=0;
break;
}
ROW=0xFD;
colloc=COL;
colloc&=0x0F;
if(colloc!=0x0F)
{
rowloc=1;
break;
}
ROW=0xFB;
colloc=COL;
colloc&=0x0F;
if(colloc!=0x0F)
{
rowloc=2;
break;
}
ROW=0xF7;
colloc=COL;
colloc&=0x0F;
rowloc=3;
break;
}
if(colloc==0x0E&&rowloc==0)
return('1');
else if(colloc==0x0E&&rowloc==1)
return('4');
else if(colloc==0x0E&&rowloc==2)
return('7');
else if(colloc==0x0E&&rowloc==3)
return('*');
else if(colloc==0x0D&&rowloc==0)
return('2');
else if(colloc==0x0D&&rowloc==1)
return('5');
else if(colloc==0x0D&&rowloc==2)
return('8');
else if(colloc==0x0D&&rowloc==3)
return('0');
else if(colloc==0x0B&&rowloc==0)
return('3');
else if(colloc==0x0B&&rowloc==1)
return('6');
else if(colloc==0x0B&&rowloc==2)
return('9');
else if(colloc==0x0B&&rowloc==3)
return('#');
else if(colloc==0x07&&rowloc==0)
return('A');
else if(colloc==0x07&&rowloc==1)
return('B');
else if(colloc==0x07&&rowloc==2)
return('C');
else if(colloc==0x07&&rowloc==3)
return('D');
}
}
void master_code()
{
bit n;
unsigned char count;
unsigned char m[6]="362481";
while(1)
{
lcdprint("Enter Mastr Code",16);
lcdcmd(0xC0);
lcdcmd(0x0F);
m[0]=getkey();
lcddata(m[0]);
m[1]=getkey();
lcddata(m[1]);
m[2]=getkey();
lcddata(m[2]);
m[3]=getkey();
lcddata(m[3]);
m[4]=getkey();
lcddata(m[4]);
m[5]=getkey();
lcddata(m[5]);
msdelay(500);
n=check(master,m,6);
count=0;
if(n==1)
{
count=10;
lcdcmd(0x01);
lcdcmd(0x02);
lcdprint("Access Granted",14);
rel1=1;
rel2=0;
msdelay(500);
return;
}
else
{
lcdcmd(0x01);
lcdcmd(0x02);
lcdprint("Access Denied",13);
rel1=rel2=0;
msdelay(500);
lcdcmd(0x01);
lcdcmd(0x02);
if(count>=3)
{
rel1=0;
rel2=1;
lcdprint("LOCKED",6);
while(1);
}
lcdcmd(0x01);
lcdcmd(0x02);
}
}
void msdelay(unsigned int time)
{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<320;j++);
}
Appendix B[1]
ATMEL AT89S52 D ATASHEET
Compatible with MCS®-51 Products
8K Bytes of In-System Programmable (ISP) Flash Memory
Endurance: 1000 Write/Erase Cycles
4.0V to 5.5V Operating Range
Fully Static Operation: 0 Hz to 33 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Eight Interrupt Sources
Full Duplex UART Serial Channel
Low-power Idle and Power-down Modes
Interrupt Recovery from Power-down Mode
Watchdog Timer
Dual Data Pointer
Power-off Flag
Fast Programming Time
Flexible ISP Programming (Byte and Page Mode)
Green (Pb/Halide-free) Packaging Option
AT89C51 is available in three packages PDIP, PLCC and PQFP. We have used dual in line
package. Pin configuration of DIP with pin numbering is shown in figure A1.
Pin configuration with block diagram of ULN2003A is shown in figure A3. It has seven
input pins and seven output pins in front of the corresponding inputs for the purpose of
simplicity.
Figure A4
BIBLIOGRAPHY
R EFERENCES
[1] Datasheet, Type “ATMEL AT89S52”, Link http://www.google.com
BOOKS
1) The 8051 Microcontroller and Embedded Systems, Edition “2 nd”, Author
“Muhammad Ali Mazidi”, Publisher “Printice Hall”