You are on page 1of 79

ADAMA SCIENCE AND TECHNOLOGY UNIVERSITY

SCHOOL OF ENGINEERING

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

TITLE: DIGITAL DOOR LOCK SYSTEM

A senior project submitted to department of electrical and computer


engineering in the partial fulfillments of a requirement of degree of bachelor
science in electrical engineering (specialization power).

GROUP MEMBERS:

NAME ID NUMBER

1) TolossaAssefa 02023391

2) TesfuFeleke 02023318

3) TesferiEshetu 02023255

4) MengistuBediye 02022683

5) MekoninTsega 02022641

ADVISOR: Mr. KenaLikassa

June, 2014 Adama Ethiopia.


DIGITAL DOOR LOCK SYSTEM

Project Approved Sheet


This is to certify that the project entitled Digital door lock system submitted for the partial
fulfillment of the requirement for the award of “Bachelor of Science Electrical Engineering “to
the best of our knowledge. It is developed and submitted by students listed below.
NAME ID NUMBER SIGNATURE
1) TolossaAssefa 02023391 ………………
2) TesfuFeleke 02023318 ……………….
3) TesferiEshetu 02023255 ………………
4) MengistuBediye 02022683 ………………
5) MekonninTsega 02022641 ………………

Approval sheet:

1) Advisor Name Signature Date


………………… ……………………… ………………
2) Department head Signature Date
MilkiyasBirhanu ………………………. …………………
3) Examiner Name Signature Date

1. ………………… ……………………… ……................


2. …………………… ……………………… ………………
3. …………………… ……………………… ………………...

ii
DIGITAL DOOR LOCK SYSTEM

Declaration

We hereby declare that the project entitled “Digital Door lock system” submitted in partial
fulfillment of the requirement of the BSc degree in Electrical and Computer Engineering
(ECENG) in Adama Science and Technology University, is record of our own work carried out
by us during the academic year2013/14 under the supervision and guidance of
MrKenaLikasa, Department of Electrical and Computer Engineering, School of Engineering.
The extent and source of information are derived from the existing literature and have been
indicated through the project at the appropriate places. The matter embodied in this work is
original and has not been submitted for the award of any other degree, either in this or any other
University.

Declared by: Name Signature

TolossaAssefa: ___________________

TesfuFeleke : ___________________

TeferiEshetu : ___________________

MengistuBediye: ___________________

MekonninTsega: ___________________

Confirmed by:

Signature: ____________________

Project Advisor:

Mr.KenaLikassa

Signature: ____________________

iii
DIGITAL DOOR LOCK SYSTEM

ACKNOWLEDGEMENT

First of all we would like to express our heart full gratitude for our GOD to help us during our
work throughout all things.

Next to this we would thanks our heart full gratitude to our advisor Mr. Kena Likasa for his an
reserved guidance, suggestion and advice. We great full to his motivation for the timely
completion of our project, especially in programming part.

Beside this we would like to thanks E/G poullinger v.ogoc to help us on hard ware part of our
project and also we like to thanks our friends who support and help us in different aspects.

Finally we would like to express our gratitude to our family for their whole heart full support
during our study in university, without their encouragement and supports, both financial and
mental, we would not have gone this far. Thanks for their tolerance and understanding shown
during our project.

iv
DIGITAL DOOR LOCK SYSTEM

CHAPTER ONE ........................................................................................................................... 1

1. INTRODUCTION ................................................................................................................... 1

1.2. BACKGROUND OF THE PROJECT STUDY.............................................................................. 1


1.2. PROJECT OBJECTIVES......................................................................................................... 2
1.2.1. General objective ...................................................................................................... 2
1.2.2. Specific objective ...................................................................................................... 2
1.3. STATEMENT OF THE PROBLEM........................................................................................... 3
1.4. SCOPE OF WORK ............................................................................................................... 3
1.5. ADVANTAGES OF KEYLESS DOOR LOCKS ......................................................................... 4
1.6. DISADVANTAGES OF KEYLESS DOOR LOCKS .................................................................... 4
1.7. THESIS OUT LINE ............................................................................................................... 5

CHAPTER TWO .......................................................................................................................... 6

2. LITERATURE REVIEW ........................................................................................................ 6

2.1. THEORETICAL EXPLANATION OF THE COMPONENTS USED IN THE PROJECT ........................ 7


2.1.1. Power supply............................................................................................................. 7
2.1.1.1. The Transformer .................................................................................................... 8
2.1.1.2. Bridge diode .......................................................................................................... 9
2.1.1.3. The filter circuit ................................................................................................... 11
2.1.1.4. Voltage Regulator: .............................................................................................. 11
2.1.1.4.1. Regulator LM7805 .......................................................................................... 12
2.1.1.4.2. Regulated LM7812 .......................................................................................... 12
2.1.2. Microcontrollers ...................................................................................................... 13
2.1.2.1. PIC16F877A Description .................................................................................... 15
2.1.2.2. PIC16F877A Features, Parameters, Memories ................................................... 15
2.1.2.3. EEPROM:............................................................................................................ 17
2.1.2.4. RAM: ................................................................................................................... 17
2.1.2.5. Flash program memory: ...................................................................................... 18
2.1.2.6. Pin Description of PIC16F887A ......................................................................... 18
2.1.2.7. APPLICATION OF PIC16F877A ...................................................................... 19
2.1.3. Clock Generator (Oscillator)................................................................................... 19

v
DIGITAL DOOR LOCK SYSTEM

2.1.4. Resistor: .................................................................................................................. 20


2.1.5. Potentiometer: ......................................................................................................... 20
2.1.6. Capacitors: .............................................................................................................. 20
2.1.7. Transistors: .............................................................................................................. 21
2.1.7.1. N-type and P-type Transistor: ............................................................................. 21
2.1.8. Relay Driver (BC547): ............................................................................................ 22
2.1.9. The keypad unit....................................................................................................... 23
2.1.10. The display unit (liquid crystal display) ................................................................. 24
2.1.10.1. Pin description of LCD ....................................................................................... 25
2.1.10.1.1. EN (Enable): .................................................................................................. 25
2.1.10.1.2. RW (Read/Write): .......................................................................................... 25
2.1.10.1.3. RS (Register Select): ...................................................................................... 26
2.1.11. Stepper motor .......................................................................................................... 26
2.1.11.1. Types of Stepper Motors ..................................................................................... 27
2.1.11.1.1. Permanent-magnet (PM) stepper motor ......................................................... 27
2.1.11.1.2. Variable-reluctance (VR) stepper motor........................................................ 28
2.1.12. Interfacing circuits .................................................................................................. 29
2.1.12.1. High-voltage high-current Darlington transistor array (ULN2003A) ................. 29

CHAPTER THREE .................................................................................................................... 31

3. PROJECT METHODOLOGY .............................................................................................. 31

3.1. THE GENERAL BLOCK DIAGRAM OF THE SYSTEM ............................................................. 32


3.2. THE CIRCUIT DIAGRAM OF THE SYSTEM: .......................................................................... 33
3.2.1 Brief Description of the general circuit diagram of the system .................................. 33

CHAPTER FOUR ...................................................................................................................... 35

4. DESIGN AND ANALYSIS OF PROJECT .......................................................................... 35

4.1. SOFTWARE DESIGN .......................................................................................................... 35


4.1.1. Software components: ............................................................................................. 35
4.1.1.1. Micro C: .............................................................................................................. 35
4.1.1.2. . Proteus 8 Professional: .................................................................................... 35

vi
DIGITAL DOOR LOCK SYSTEM

4.1.1.3. Visual Basic: ....................................................................................................... 36


4.1.1.4. Hyper Terminal: .................................................................................................. 37
4.1.1.5. Serial Port Monitoring :....................................................................................... 37
4.1.2. Flow chart ............................................................................................................... 38
4.1.3. Software Debugging. ............................................................................................. 38
4.1.3.1. Keypad program. ................................................................................................ 40
4.1.3.2. LCD program ...................................................................................................... 41
4.2. HARDWARE DESIGN. ....................................................................................................... 46
4.2.1. The major building blocks of this project are: ........................................................ 46

5. REASULT AND DISCUSION: ............................................................................................ 48

5.1. REASULT ......................................................................................................................... 48


5.2. DISCUSION: ..................................................................................................................... 55

CHAPTER SIX .......................................................................................................................... 56

6. CONCLUSION AND RECCOMMENDATION .................................................................. 56

6.1. CONCLUSION ................................................................................................................... 56


6.2. RECCOMMENDATION ............................................................................................... 57
6.3. REFERENCES. .................................................................................................................. 58
6.4. APPENDIX........................................................................................................................ 59
6.4.1. The system program or code ................................................................................... 59

vii
DIGITAL DOOR LOCK SYSTEM

LIST OF FIGURES
FIGURE TITLE PAGE
2.1 Block diagram of power supply system…………………………………...7
2.2 Transformer Circuit………………………………………….....................8
2.3 Full wave (Bridge) Rectifier and Wave forms using four Diodes……..10
2.4 Regulator…………………………………………………………………13
2.5 pin description of PIC16F877A………………………………………….18
2.6 Clock Generator Circuit…………………………………………………20
2.7 Transistors………………………………………………………………..21
2.8 Showing the 4x3 Matrix Keypad………………………………………...25
2.9 LCD……………………………………………………………………..25
2.10 Unipolar stepper motor………………………………………………….27
2.11 ULN2003A………………………………………………………………30

3.1 block diagram of the microcontroller based digital door lock system…...32

3.2 Description of the general circuit diagram……………………………….33

4.1 Micro C………………………………………………………………….35


4.2 Proteus 8 Professional…………………………………………………………36
4.3 flow chart …………………………………………………………38
4.4 general circuit diagram…………………………………………………..40
4.5 hardware implementation…………………………………………………47
5.1 result show WELL TO ASTU……………………………………..….…48
5.2 show DIGITAL DOOR LOCK BY ECENG STUDENT………………49
5.3 show press *………………………………………..……………………50
5.4 show enter code…………………………………………………………51
5.5 show correct……………………………………………………………52
5.6 show door closed………………………………………………………..53
5.7 wrong password ………………………………………………………...54

viii
DIGITAL DOOR LOCK SYSTEM

LIST OF TABLES
Table TITLE PAGE

2.1 PIC16F877A Parameters, Memories, Features………………………………..16

4.1 External dependencies of Lcd..…………………………………………………41

4.2 Lcd_Init………………………………………………………………………….43

4.3 Lcd_Out…………………………………………………………………………43

4.4 Available Lcd Commands………………………………………………………..45

ix
DIGITAL DOOR LOCK SYSTEM

LIST OF SYMBOLS

A Ampere

A/D Analog –to- Digital converter

CRT Cathode Ray Tube

CPU Central processing unit

EN Enable

EEPROM Electrically Erasable Programmable Read Only Memory

EPROM Erasable Program Read Only Memory

GND Ground

ICSP In serial programming

LED Light Emitting Diode

LCD Liquid Crystal Display

RAM Read Access Memory

SPI Serial peripheral interface

WR Read Write

RS Register Select

OSC Oscillator

PCB Printed Circuit Board

PIC Programmable Interface Controller

MCU Micro Controller unit

MCLR Master Clear

NPN Negative Positive Negative

BC 547 Base Collector Transistor

VB Visual Basic

x
DIGITAL DOOR LOCK SYSTEM

ABSTRACT
The increasing rate of crime, attacks by thieves, intruders and vandals, despite all forms of
security gadgets and locks still need the attention of researchers to find a permanent solution to
the well being of lives and properties of individuals .so, Security is a prime concern in our day-
today life. Everyone wants to be as much secure as possible. . To this end, we design a effective
security system for doors open and close. to prevent unauthorized person from having access to
ones properties through the use of codes, we therefore experiment the application of electronic
devices as locks.

An access control for doors forms a vital link in a security chain. The microcontroller based
Door locker is an access control system that allows only authorized persons to access a restricted
area. The major components that we used include a keypad, LCD, EEPROM and the micro
controller PIC16F877A which belongs to the 16F877A series of micro controllers. The system is
fully controlled by the 8 bit microcontroller PIC16F877A which has a 2Kbytes of ROM for the
program memory. The password is stored in the EPROM so that we can change it at any time.
The system has a Keypad by which the password can be entered through it. The electronic
control assembly allows the system to unlock the device with a password. A four digit predefined
password needs to be specified the user. The system has a Keypad by which the password can be
entered through it. A 4x3 matrix KEYPAD and a 16x2 LCD have been used here to set the
password which is stored in the EPROM so that we can change it at any time. While unlocking,
if the entered password from keypad matches with the stored password, then the lock opens and
a message is displayed on LCD. The keypad is scanned for pressed digits one by one. Every
time, row and column of the key pressed is detected and the digit is displayed on LCD. As the
program starts, string ‘Enter Password’ is displayed on LCD. If all the four digits match with set
password, LCD displays ‘password is correct’ and the lock output pin goes high and the led
glows. After the led give light the door is opened and after some delay time another led glows
and the door is closed.

xi
DIGITAL DOOR LOCK SYSTEM

CHAPTER ONE

1. INTRODUCTION

1.2. Background of the project study


Security of human life and property is one of the paramount challenges facing any nation
or any corporate organization. Also, ensuring safety and confidentiality of data & message
stored in a system or electrical appliances is quite essential to prevent unauthorized access.

qADue to the need to increase the security of life and properties in our environment,
security systems are used as selective systems to decide who has access to a given location
based on a personal distinctive trait of the user. It also serves the function of sensing or
detecting false intrusion .The term false intrusion here is used to mean any form of attempt
to gain entry without following the proper pre-designed protocol(s). From time past until
present, security locks usually includes mechanical devices made of forged metal i.e.
simple lock and bolt, the door chain, pin tumbler lock, the jam lock and padlock etc. Other
recently developed security devices are gadgets like laser beam detectors, motion detectors
and magnetic card readers. Most recent of these devices are offshoots of biometric
engineering. They include voice recognition systems, finger print readers, etc. The major
characteristic of security devices is to prevent an intruder from gaining access to a location.
Most of these devices however have lapses which give an unauthorized person access to
where they are barred i.e. the simple jam lock and pad lock can be forced open or the keys
duplicated by unauthorized persons and under certain conditions, i.e. physical changes of
the individual concerned, the biometric devices sometimes fail in recognizing the authentic
individual concerned. Hence they cannot be totally relied on. Furthermore, these devices
are very expensive; its use is restricted to only a few individuals or organizations that can
afford it.

Devices such as motion detectors, light detectors among others are susceptible to be
triggered by false signals such as noise impulses, whenever its sensitivity is increased.
They are not suitable for most outdoor security protection due to the fact that they don’t

1
DIGITAL DOOR LOCK SYSTEM

possess high discriminative capability during operation and they are fairly expensive. It is
hence imperative to provide a locking device, one which is also efficient and reliable; with
high discriminative capability, non-reliance on the physical quality of the individual
concerned, which when forced open triggers an alarm and which is by far less expensive
than their counterparts. This has led to the design and construction of a microcontroller
based electronic lock system. It includes using correct personal identification numbers to
operate the locking device, by conditioning the access based on the configuration of the
security device thereby granting access to the user with correct pin number.

The microcontroller based electronic lock finds application in homes, banks in the field of
military applications i.e. ammunition ware house, industries, ministries and government
parastatals etc. due to the above problem we select code lock system with microcontroller.

The design and construction of a programmable electronic digital code lock system
provides a sure way of ensuring this security and safety for data. Programmable digital
code lock system is a high security code lock system. This system is a combination of
hardware and software at its best. In this design, a device is locked using a four digit code
(password). The code can be set according to the user’s desire.

1.2. Project objectives

1.2.1. General objective


1. To provide a security lock that is efficient and reliable, in comparison with traditional
devices.

2. To design and enable each individual to have secured home using door security code
system.

3. Unlock the door by using pre-decided password.

1.2.2. Specific objective

i. To familiarize with the concept and operation of PIC16f877a programming software.


ii. To develop programming code of the security PIC-based system.

2
DIGITAL DOOR LOCK SYSTEM

iii. To familiarize with the skills and techniques in combining software and hardware for a
system.

1.3. Statement of the Problem


We want to make our final year project on something that will be useful in real life.

The issue of Security is a problem of both developed and developing countries ;it is a
serious challenge on the area of unsecured place or unprotected area like home,
government organization, public service and etc.; however this security system somewhat
decrease this problem. There are great varieties of electronic code locks. Generally
speaking, they can be classified into scores of types, such as digital lock, finger print lock,
card lock, biological lock etc. among them the most practical and the most popularized one
can come to electronic code lock. These kinds of lock can avoid the problems caused by
the copying of keys. On the premise that its safety is high, it’s another feature without key
is getting more and more favor of people. It is because the keys people carry have become
burden most of the time, but by construct people need only to remember asset of codes for
electronic locks, and don’t have to carry any key, thus freeing themselves from worries.

We all are aware of the fact that there has been a sharp increase in criminal offences like
theft, robberies, assaults, murders etc. in the recent past that is affecting our society on a
large scale. So the requirement for a well-equipped home security system is definitely on
the rise. We want to utilize the electronic technology to build an integrated and fully
customized home security system at a reasonable cost. We hope this project will be useful
in keeping thieves, dacoits and other sort of dangers at bay.

Nowadays, human always rely on electronic devices to make their lives more convenience.
The purpose of this project is to replace door key into a reliable door security system using
microcontroller. This will be the best solution for those who always forget to bring their
house or office room key before left.

1.4. Scope of Work


This project will focus primarily on circuit construction such as PIC16F877A as the
microcontroller, LED as power indicator, and 4x3 keypad for keying in password, ICSP

3
DIGITAL DOOR LOCK SYSTEM

(In Circuit Serial Programming)for loading program, and push button as input for PIC
microcontroller. Second, this project will also focus on LCD screen display which is used
to display words and password symbols. Finally, relay driver and motor will function as
output for this system which can be applied to any daily application such as door lock.

Generally the scope of the project is listed as follows:

To study the basic idea and operation of door locking system.

To identify thesuitable type of PIC microcontroller for the project, to develop interfacing
link between hardware circuit and software programming.

To display the code and signal at LCD screen display

1.5. Advantages of Keyless Door Locks


One of the main advantages of a keyless door lock is the fact that you will not be required
to carry a key. This makes it less likely that you'll lose the key and have a difficult time
getting in to the home. It also means that you won't need to store a spare key somewhere
on your property, as many home owners currently do. This poses a security risk, so
eliminating the need for that additional key helps to make your home safer.

Another advantage of a keyless door lock is the fact that you can provide entry into your
home to others at your discretion. You will not need to make copies of a key or leave keys
for someone else to get in to your home. Rather, you'll simply need to tell those people the
proper code to put into the keyless entry system in order to gain access. With the system in
place, you can also tell exactly when and how people attempted to access your home. This
gives you a good idea of how secure your house is.

1.6. Disadvantages of Keyless Door Locks


While there are many benefits to including a keyless door lock system in your home, there
are also some major drawbacks to consider as well. The first of these is a security issue.
While keyless door lock systems are generally very safe and are designed to alert police or
other authorities if incorrect codes are entered too many times, it is nonetheless possible
that an intruder may be ableto gain access to your home through this system by guessingor
hackingthe code.

4
DIGITAL DOOR LOCK SYSTEM

Just as you can forget your keys and be locked out of your home, you can also forget the
pass code to access your keyless entry system and be locked out as well. This can pose a
problem if you have a difficult time remembering things; it's safest to use a completely
random code and to avoid things like birth dates.

One final disadvantage of keyless door locks is that those systems which are powered by
electricity may not function properly in the case of a power failure. This can leave your
door completely locked throughout the failure, or it may result in the door not locking
properly and remaining open during the failure as well.in ordering to solve the proplem of
power supply failure it possiple to use Generator.

1.7. Thesis out line


Chapter 1 – Introduction
This chapter gives an overview of the entire project including project motivation, project
objective, and project schedule.

Chapter 2 – Literature Review


This chapter reviews the development of Digital door lock system and the theoretical
foundation of the components including the previous related projects to the title.

Chapter 3 – project methodology


The all data gathering methods and analysis of the general block diagram of the project
will be discussed in this chapter.

Chapter 4 – Software Design and Analysis


The software of embedded system design of the final design’s program is explained in
detail in this chapter.

Chapter 5– Result and Discussion


The result of PIC16F877A microcontroller is displayed on LCD will be showed in picture
and the problems encountered during the implementation of the project will be covered and
also the simulation of the overall circuit diagram is discussed under this chapter.

Chapter 6 – Conclusion and recommendation


Lastly, summarized the overall achievement of the project (thesis) and provides some
recommendation for future work.

5
DIGITAL DOOR LOCK SYSTEM

CHAPTER TWO

2. LITERATURE REVIEW
When we think of locks, we think of a bolt containing a notch known as a talon(the
shoulder of a bolt against which the key presses to slide it in a lock.), which is operated by
moving the bolt backwards or forward by engaging a key in the talon. But there is more to
locks than just a bolt or latch. A lock is a mechanical device that can be used for securing
doors, cabinets, lid of brief cases or other luggage. It consists essentially of a bolt guarded
by a mechanism which can be released by a mechanical, hydraulic or electrical /electronic
actuator. The oldest known mechanical functioning lock was an Egyptian door lock used
about 2000BC, made of wood and fastened vertically on the door post, the wooden block
contained moveable pins or “pin tumblers” that dropped by gravity into openings in the
cross piece of “bolts” and locked the door. It was operated by a wooden key with pegs that
raised the number of tumblers sufficiently to clear the bolt so that it could be pulled back.
The major disadvantage with it is that it was wholly made of wood.

The Romans made an improvement on this by fabricating the first metal locks which was
later improved by Robert Bar son, an English man in 1778 and Linus Yale Jnran American
in 1861. The Yale lock consists of essentially a cylindrical plug placed in an outer barrel.
The plug is rotated and in turn moves the bolt of the lock by means of a cam. The inserted
key raises five pins of different sizes into corresponding holes in the plug. The most
common form of cylindrical lock used in homes is the so-called night latch, operated from
a key from outside and a knob from inside. In the 20th century, as machine tools and
manufacturing methods became more sophisticated, locks were produced, which are either
key operated (opened) or keyless.

In the late 20th century, electro mechanical locks were developed to trip electrical circuit
as seen in automobile ignitions. Other keyless locks include remote controlled lock,
“security card” operated and electronic code lock.

This project is about the electronic digital code lock, which is designed by microcontroller
in order open and closes the door. It is operated by putting the correct code by keypad into

6
DIGITAL DOOR LOCK SYSTEM

a microcontroller which already have a pin number in its EEPROM memory to compare
with, so that if it is correct .It activates the port to which the LED is connected the load.

2.1. Theoretical explanation of the components used in the project

2.1.1. Power supply


Power supply is used to drive the circuit. Inappropriate voltage will damage the entire
circuitry therefore it constitutes a very important part of the circuit. Every electronic circuit
requires power for its operation. Every function simple or complex is controlled by the
power supply. Even a little variation in voltage can damage all the circuitry. So, power
supply is of prime importance in all the circuits. The power supply which we get is AC
operating at 220Volts.But as our electronic circuits work only on DC therefore; we cannot
employ direct usage of supply which we get. In order to overcome this, we require various
process namely transformation, rectification, smoothing or filtering and regulation. These
entire process using bridge rectifiers are illustrated below.

U2
LM7812CT
D1
V1 LINE VREG
VOLTAGE
T1 S2 COMMON
220 Vrms S1 C2
C1
50 Hz
S3 100uF U3

10:1 100uF
LINE VREG
VOLTAGE
COMMON
LM7805CT

Fig2. 1 Block diagram of power supply system

7
DIGITAL DOOR LOCK SYSTEM

2.1.1.1. The Transformer

A transformer is an electrical A.C. component or equipment which consists of two or more


coils that are linked together by mutual inductance. The center tapped step down
transformer, with the ratings 240V/24Vrms, 500mA is employed. This is required to suit
the circuit fed by the DC supplied, it also the mains circuit from the power line.

As already discussed the supply which we get is 220V A.C. supply. In order to decrease
the magnitude of the voltage we make use of step down transformer. This transformer has
more windings in the primary coil than in the secondary coil. So the voltage output at the
secondary is an A.C. supply with magnitude less than 220V as shown below in the figure.

In mathematical analysis we have:

= =a where v1 primary voltage which is 220v and v2 is the secondary voltage

Then in our design we should have to get 12v ac which step down by the transformer. So
to gate this the ratio should become

= 18.33

V1
U1 12V
240 Vrms
50 Hz 24V

2 12V

Fig 2.2 Transformer Circuit

For an ideal transformer,

VpIp = VsIs

Where Vs - is the voltage at the secondary coil

Vp - is the voltage at the primary coil

8
DIGITAL DOOR LOCK SYSTEM

Is - is the current at the secondary coil

Ip - is the current at the primary coil

2.1.1.2. Bridge diode

Diodes have two active electrodes between which the signal of interest may flow, and most
are used for unidirectional electric current property. The unidirectional most diodes exhibit
is sometime called the rectifying property. The most common function of a diode is to
allow an electric current in one direction (called the forward biased condition) and to block
the current in the opposite direction (the reverse biased condition).

As all the electronic circuits work on DC therefore this low voltage A.C. cannot be directly
fed to our circuit. Thus a process of rectification is required. In this process, A.C. voltage is
converted into DC voltage using bridge rectifying diodes (using four diodes).

Now the diodes are connected in the opposite manner; such that diode D1 and DiodeD2 are
in opposite direction with D3andD4. Therefore two of the diodes get forward biased during
the positive half of the AC input and other gets forward biased during the negative half of
the AC input. Thus during the positive half cycle rectification takes place through diode
D1 and D2(diode D3 and D4 being reverse biased, cannot rectify) and during the negative
half cycle, the rectification takes place through the diode D3 and D4(diodes D1 and D2
being reverse biased, cannot rectify). But as at least two of the diodes always remain in the
conducting mode therefore both the halves of the AC input gets rectified and hence the
name full wave rectifier

This circuit converts the transformer AC output to DC power supply. This design uses four
diodes; this arrangement is known as bridge rectification, as shown in the diagram below;

9
DIGITAL DOOR LOCK SYSTEM

Fig 2.3 Full wave (Bridge) Rectifier


and Wave forms using four Diodes

When point A is positive with respect to point B (positive half cycle), current flows
through the forward biased diodes D1 and D3 while D1 and D2 are reverse biased, giving
the output wave form in (b). Conversely, when point B is positive with respect to point A
(positive half cycle), current flows through the forward biased D1 and D2 giving an output
wave form in (c).

The result of the two wave form is an output voltage whose ripple frequency is twice the
supply frequency.

For a bridge rectifier with four diodes

Vrms = 12V

Vpeak = Vrms√ 2

= 12 √2 = 16.9V

The average DC voltage is given by

Vdc = Vpeak – diode drop imposed by rectifier circuit

Vdc = 16.9V – 1.5V

Vdc≈ 15V

10
DIGITAL DOOR LOCK SYSTEM

2.1.1.3. The filter circuit


The output of the rectifier circuit above is pulsating; it has a DC value and very significant
AC component called RIPPLES. The filter circuit consists of capacitors and is necessary to
minimize the ripple content in the rectifier output. The capacitor charges up during the
diode conduction period, to peak secondary voltage and discharges through the load when
the rectifier voltage falls. If the output voltage has a ripple voltage of 50V, the filter can be
chosen as follows;

I = C (dv/dt) ………………………….. (3.1)

Where I = 500mA (max transformer secondary current)

dv= ripple content = 50V

dt= ½ time during which the capacitor discharges

=½ the period of the 50Hz supply input

=2

=½ × 1/50

=1/100

= 10ms

Hence,

C ==500×10-3×10×10-3 ⁄ 50=100µF

Thus, the filter capacitor is chosen as 100µf.

2.1.1.4. Voltage Regulator:


A voltage regulator circuit is designed to automatically maintain the voltage at the constant
level. The microcontroller IC requires a +5V DC supply. The 7805 fixed voltage regulator
thus functions to provide a stable 5V, DC voltage at its output. The 7805 is a three-pin
integrated circuit with external connections. Its input voltage is from the 7812 Regulator
output and has a capacitor C2 =100µF, connected across the output to remove transient
response

11
DIGITAL DOOR LOCK SYSTEM

2.1.1.4.1. Regulator LM7805


The LM7805 monolithic 3-terminal positive voltage regulators employ internal current-
limiting, thermal shutdown and safe-area compensation, making them essentially
indestructible. If adequate heat sinking is provided, they can deliver over 1.0A output
current. They are intended as fixed voltage regulators in a wide range of applications
including local regulation for elimination of noise and distribution problems associated
with single-point regulation. In addition to use as fixed voltage regulators, these devices
can be used with external components to obtain adjustable output voltages and currents.
Considerable effort was expended to make the entire series of regulators easy to use and
minimize the number of external components. It is not necessary to bypass the output,
although this does improve transient response. Input bypassing is needed only if the
regulator is located far from the filter capacitor of the power supply.

2.1.1.4.2. Regulated LM7812


The ±12 V supply required in our design is provided by the 12V supply circuit
arrangement. The circuit diagram of ±12V power supply unit is shown in figure3. Initially
220 V AC supply is reduced to (12V-0-12V) with the help of a step down transformer
which is the center tap of the transformer is grounded. This low voltage is rectified with
the help of bridge rectifier. Since the input voltage to the regulator IC should be more than
its output voltage, transformer secondary voltage is 12V-0-12V.The ripples are minimized
with the help of capacitor filter to get a smooth DC supply. The rating of the chosen
capacitor filter is 100µF.The regulated DC output voltage is obtained by using regulator
ICs. For regulated +12V DC supply, IC 7812 is used. In the case of IC7812 the
unregulated DC voltage is applied to Pin 1, and the output is taken at Pin 3 and Pin 2 is
grounded (look in the general circuit diagram).

PINOUT FOR LM7805/LM7812:

12
DIGITAL DOOR LOCK SYSTEM

Fig 2.4 Regulator:

2.1.2. Microcontrollers
A microcontroller often abbreviated MCU is a single computer chip integrated circuit that
executes a user program normally for the purpose of controlling some device hence the
name microcontroller. Microcontroller includes several thousands of transistors stored into
one chip, with addition of external peripherals such as memory input-output lines, timers
built into it. Microcontrollers can be found in any products these days. For example
modern washing machine in our house that consists of timer, button and LED contains a
microcontroller. All modern cars contain microcontroller.

On the PIC16F84A, there are 68 bytes of general-purpose RAM, located at addresses C to


hex 4F. Besides the general-purpose memory, there is a special "working register" “or
register" where the CPU holds the current data. There are also several special function
registers each of which controls the operation of the PIC in some way. The program
memory of the PIC16F84A consists of flash EPROM; it can be recorded and erased
electronically, and it retains its contents when powered off.

There are minimum six requirements for proper operation of microcontroller.

13
DIGITAL DOOR LOCK SYSTEM

Those are:

1) Power supply section

2) Pull-ups for ports (it is must for PORT0)

3) Reset circuit

4) Crystal circuit

5) ISP circuit (for program dumping)

6) EA/VPP pin is connected to Vcc.

PORT0 is open collector that’s why we are using pull-up resistor which makes PORT0 as
an I/O port. Reset circuit is used to reset the microcontroller. Crystal circuit is used for the
microcontroller for timing pluses. In this project we are not using external memory that’s
why EA/VPP pin in the microcontroller is connected to Vcc that indicates internal memory
is used for this application.

There are two input- output ports, port A and port B, and each pin of each port can be set
individually as an input or an output. The bits of each port are numbered, starting at 0. In
output mode, bit 4 of port A has an open collector (or rather open drain); the rest of the
outputs are regular CMOS. The CPU treats each port as one 8-bit byte of data even though
only five bits of port A are actually brought out as pins of the IC. PIC inputs are CMOS-
compatible; PIC outputs can drive TTL or CMOS logic chips: Each output pin can source
or sink 20mA as long as only one pin is doing so at a time.

Microcontroller consists of:

Processor that executes programs. Processor execute program digitally. All instruction
given to the processor should be in digital form.

Program Memory to store the program that has been compiled success fully by the
programmer.

RAM (random-access memory) to store "variables."

IO Port to connect sensor, keypad, LED, Relay and so on.

Timer to count the time to execute some process.

14
DIGITAL DOOR LOCK SYSTEM

Here are the examples of microcontrollers:

( i ) PIC 16F870

( ii ) PIC 16F871

( iii ) PIC 16F872

( iv ) PIC 16F873A

( v ) PIC 16F874A

( vi ) PIC 16F876A

( vii ) PIC 16F877A

Digital electronics knowledge is essential in order to understand the way microcontroller


works. However, with the existing latest microcontroller like PIC16F877A from
microchip, microcontroller works by writing programming code using C programming
language. Everything becomes so simple by learning C programming and uses it to
program the microcontroller. The microcontroller stage is implemented by using the
PIC16F877A. It is preferred because of its popularity, versatility, availability and
simplicity to comprehend.

2.1.2.1. PIC16F877A Description

This powerful (200 nanosecond instruction execution) yet easy-to-program (only 35 single
word instructions) CMOS FLASH-based 8-bit microcontroller PIC16F877A packs
Microchip's powerful PIC architecture into an 40- or 44-pin package and is upwards
compatible with the PIC16C5X, PIC12CXXX and PIC16C7X devices.

The PIC16F877A features 256 bytes of EEPROM data memory, self programming, an
ICD, 2 Comparators, 8 channels of 10-bit Analog-to-Digital (A/D) converter, 2
capture/compare/PWM functions, the synchronous serial port can be configured as either
3-wire Serial Peripheral Interface (SPI™) or the 2-wire Inter-Integrated Circuit (I²C™) bus
and a Universal Asynchronous Receiver Transmitter (USART). All of these features make
the PIC16F877A ideal for more advanced level A/D applications in automotive, industrial,
appliances and consumer applications.

2.1.2.2. PIC16F877A Features, Parameters, Memories

15
DIGITAL DOOR LOCK SYSTEM

Features:

2 PWM 10-bit

256 Bytes EEPROM data memory

ICD

25mA sink/source per I/O

.Self-Programming

Parallel Slave Port

Table 2.1 PIC16F877A Parameters, Memories, Features


PIC16F877A Memories
Flash (KB) 14
RAM (Bytes) 368
Data EEPROM (bytes) 256
PIC16F877A Features
Program Memory Type Flash
CPU Speed (MIPS) 5
1-A/E/USART
Digital Communication Peripherals
1-MSSP(SPI/I2C)
Capture/Compare/PWM Peripherals 2 CCP
2 x 8-bit
Timers
1 x 16-bit
ADC 8 ch, 10-bit

16
DIGITAL DOOR LOCK SYSTEM

Comparators 2
Operating Voltage Range (V) 2 to 5.5

Microcontrollers from different manufacturers have different architectures and different


capabilities.

Some may suit a particular application while others may be totally unsuitable for the same
application. The hardware features of microcontrollers in general are described in this
section.

PIC16F877A belongs to a class of 8-bit microcontrollers of RISC architecture.

2.1.2.3. EEPROM:
EEPROM is Electrically Erasable Programmable Read Only Memory, which is a non-
volatile memory.

These memories can be erased and also be programmed under program control. EEPROMs
are used to save configuration information, maximum and minimum values, identification
data, etc.

It is a memory used for storing important data that must not be lost if power supply
suddenly fails. The PIC16F877A is made up of up to 256 x 8 bytes of EEPROM data
memory. For instance the EEPROM stores the personal identification number which is
compared with the user input so as to activate the port to which the door relay is
connected.

2.1.2.4. RAM:
RAM means Random Access Memory. It is a general-purpose memory which usually
stores the user data used in a program. RAM is volatile, i.e. data is lost after the removal of
power. Most microcontrollers have some amount of internal RAM. 256 bytes is a common
amount, although some microcontrollers have more, some less. In general it is possible to
extend the memory by adding external memory chips.

It contains data used by a program during its execution. The PIC16F877A consists of up to
368 x 8 bytes of data memory (RAM).

17
DIGITAL DOOR LOCK SYSTEM

2.1.2.5. Flash program memory:


This is another version of EEPROM-type memory. This memory has become popular in
microcontroller applications and is used to store the user program. Flash EEPROM is non-
volatile and is usually very fast. The data is erased and then re-programmed using a
programming device. The entire contents of the memory should be erased and then re-
programmed. This is used for storing a written program; it is an8K x 14 words memory
which can be programmed and cleared more than once, it makes the PIC16F877A suitable
for device development.

2.1.2.6. Pin Description of PIC16F887A

Fig 2.5 pin description of PIC16F877A

18
DIGITAL DOOR LOCK SYSTEM

PIC16F877A has a total of 40 pins which consist of the following;

Port A (6-pin); its pin RA4 functions as a timer; others have no additional function.

Port B( 8- pin); its pin RB0 functions as an input interrupt, RB0 functions as “clock” line
in program mode. RB7, ‘Data’ line in program mode.

Port C (8-pin): its pins are used for transmitting and receiving data from peripheral
components.

Port D (8-pin): all pins are used for parallel slave port with external peripherals.

Port E (3-pin): enable port , can be used as chip select CS.

Vcc (2-pin): use for supply of +5V dc to the microcontroller.

MCLR (1 pin): reset input and Vpp programming voltage of microcontroller.

GND (2-pin): use for grounding the supply to the microcontroller.

OSC 1 & OSC2: assigned for oscillator connection, for clocking and clock out
respectively.

The clock is microcontroller’s main starter, and is obtained from an external component
called an “oscillator” the clock is divided into four; Q1, Q2, Q3 and Q4. The four together
makes up an instruction cycle during which one instruction is executed.

2.1.2.7. APPLICATION OF PIC16F877A


Its applications include the design and implementation of electronic lock with display
controlling home appliances, remote sensors and several safety devices. It is also used in
systems where permanent storage of various parameters is needed due to its EEPROM
memory; this system includes codes for transmitters, motor speed, receiver frequency etc.

2.1.3. Clock Generator (Oscillator)


The clock oscillator is a clock pulse generator required to operate the microcontroller, it
increases the speed of execution of each task. Based on the microcontroller PIC16F877A, a
20MHz is suitable for the operation hence; it is used in this project.

19
DIGITAL DOOR LOCK SYSTEM

Fig 2.6 Clock Generator Circuit

2.1.4. Resistor:
Resistor is a component that resists the flow of direct or alternating electric circuit.
Resistors can limit or divide the current, reduce the voltage, protect an electric circuit, or
provide large amounts of heat or light. An electric current is the movement of charged
particles called electrons from one region to another. Resistors are usually placed in
electric circuits. Physicists explain the flow of current through a material, such as a
resistor, by comparing it to water flowing through a pipe. Resistors are designed to have a
specific value of resistance. Resistors used in electric circuits are cylindrical. They are
often colour coded by three or four colour bands that indicate the specific value of
resistance. Resistors obey ohm’s law, which states that the current density is directly
proportional to the electric field when the temperature is constant.

2.1.5. Potentiometer:
It is one type resister that used for LCD brightens to show every things that display on
LCD screen.

2.1.6. Capacitors:
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 positive. The electrical
size of the capacitor is its capacitance. Capacitors are limited in the amount of electric

20
DIGITAL DOOR LOCK SYSTEM

charge they can absorb; they can conduct direct current for only instances but function well
as conductors in alternating current circuits. Fixed capacity and variable capacity
capacitors are used in conjunction with coils as resonant circuits in radios and other
electronic equipment. Capacitors are produced in a wide variety of forms. Air, Mica,
Ceramics, Paper, Oil, and Vacuums are used as dielectrics depending on the purpose for
which the device is intended.

2.1.7. Transistors:
Transistor is a device which transforms current flow from low resistance path to high
resistance path. It is capable of performing many functions of the vacuum tube in
electronic circuits, the transistor is the solid state device consisting of a tiny piece of semi
conducting material, usually germanium or silicon, to which three or more electrical
connections are made.

PINOUT FOR BC547:

Fig 2.7 Transistors

2.1.7.1. N-type and P-type Transistor:


A germanium or silicon crystal, containing donor impurity atoms is called a negative or n-
type semiconductor to indicate the presence of excess negatively charged electrons. The

21
DIGITAL DOOR LOCK SYSTEM

use of an acceptor impurity produces a positive, or p-type semiconductor so called because


of the presence of positively charged holes. When an electrical voltage is applied, the n-p
junction acts as a rectifier, permitting current to flow in only one direction. If the p-type
region is connected to the positive terminal of the battery and the n-type to the negative
terminal, a large current flows through the material across the junction.

2.1.8. Relay Driver (BC547):


The BC547 transistor is an NPN Epitaxial Silicon Transistor. The BC547 transistor is a
general-purpose transistor in small plastic packages. It is used in general-purpose
switching and amplification BC847/BC547 series 45 V, 100 mA NPN general-purpose
transistors.

The BC547 transistor is an NPN bipolar transistor, in which the letters "N" and "P" refer to
the majority charge carriers inside the different regions of the transistor. Most bipolar
transistors used today are NPN, because electron mobility is higher than whole mobility in
semiconductors, allowing greater currents and faster operation. NPN transistors consist of
a layer of P-doped semiconductor (the "base") between two N-doped layers. A small
current entering the base in common-emitter mode is amplified in the collector output. In
other terms, an NPN transistor is "on" when its base is pulled high relative to the emitter.
The arrow in the NPN transistor symbol is on the emitter leg and points in the direction of
the conventional current flow when the device is in forward active mode. One mnemonic
device for identifying the symbol for the NPN transistor is "not pointing in." An NPN
transistor can be considered as two diodes with a shared anode region. In typical operation,
the emitter base junction is forward biased and the base collector junction is reverse biased.
In an NPN transistor, for example, when a positive voltage is applied to the base emitter
junction, the equilibrium between thermally generated carriers and the repelling electric
field of the depletion region becomes unbalanced, allowing thermally excited electrons to
inject into the base region. These electrons wander (or "diffuse") through the base from the
region of high concentration near the emitter towards the region of low concentration near
the collector. The electrons in the base are called minority carriers because the base is
doped p-type which would make holes the majority carrier in the base.

22
DIGITAL DOOR LOCK SYSTEM

2.1.9. The keypad unit


This is the input unit. It consists of digital devices such as switches, push buttons, pressure
mats and float switches. In our case we used push buttons to make keypad.

Keypads are an excellent way of entering data into microcontroller. The keys is usually
numbered but they can also be labeled as function keys, for example in the remote control
handset of a TV to adjust the sound or color, etc. Like remote controls, keypads find
applications in burglar alarms, door entry systems, calculators and microwave ovens.

Keypads are usually arranged in a matrix format to reduce the number of input/output
connections. A 12 key-keypad is arranged in a 4 x 3 format requiring seven connections
while a 16 key-keypad is arranged in a 4 x 4 format requiring eight connections. In this
project we use 4x3 keypad. It perform two separate functions, they can serve as numeric
keys and function keys. The numeric keys are design to input numeric values into the
system, they include “0 – 9”. While the function keys “A – D” and “#”, “*” are used to
process the inputs. In the design of the keypad, there is a need for mandatory processing
unit to decipher an authentic key pressed from an unwanted noise pulse. This is known as
key de bouncing, to prevent against multiple single inputs a de bounced delay of 150ms
was chosen as a start value in the program written, this provided an advantage of reduced
hardware and flexible de bouncing period.
1

A 1 2 3
B 4 5 6
C 7 8 9
D 0 #

Fig 2.8 Showing the 4x3 Matrix Keypad


23
DIGITAL DOOR LOCK SYSTEM

The output of the button pressed on the keypad is displayed on LCD screen. This help to
makes correction if a mistake is made during the typing of the codes. When the input pin is
correct it causes the microcontroller to generate the control signal to drive the lock
mechanism else the message wrong password is displayed on the LCD screen.

2.1.10. The display unit (liquid crystal display)


A liquid crystal display (LCD) is an electronically modulated optical device shaped into a
thin, flat panel made up of any number of color or monochrome pixels filled with liquid
crystals and arrayed in front of a light source (backlight) or reflector. It is used for
electronically displaying information such as text, images, and moving pictures. Its uses
include monitors for computers, televisions, instrument panels, and other devices ranging
from aircraft cockpit displays, to every-day consumer devices such as video players,
gaming devices, calculators, and telephones. Among its major features are its lightweight
construction, its portability, and its ability to be produced in much larger screen sizes than
are practical for the construction of cathode ray tube (CRT) display technology. Its low
electrical power consumption enables it to be used in battery-powered electronic
equipment. Its advantage is display numbers, characters and graphics, but its disadvantage
is it restrict character and not available on the market.

24
DIGITAL DOOR LOCK SYSTEM

LCD1
LM016L VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14
Fig 2.9 LCD

2.1.10.1. Pin description of LCD

2.1.10.1.1. EN (Enable):
The EN line is called "Enable". This control line is used to tell the LCD that you are
sending it data. To send data to the LCD, your program should first set this line high (1)
and then set the other two control lines and/or put data on the data bus. When the other
lines are completely ready, bring EN low (0) again. The 1-0 transition tells the 44780 to
take the data currently found on the other control lines and on the data bus and to treat it as
a command.

2.1.10.1.2. RW (Read/Write):
The RW line is the "Read/Write" control line. When RW is low (0), the information on the
data bus is being written to the LCD. When RW is high (1), the program is effectively
querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read
command. All others are write commands, so RW will almost be low.

25
DIGITAL DOOR LOCK SYSTEM

2.1.10.1.3. RS (Register Select):


There are two important registers inside the LCD. When RS is low (0), the data is to be
treated as a command or special instruction (such as clear screen, position cursor, etc.).
When RS is high (1), the data that is sent is a text data which should be displayed on the
screen. For example, to display the letter "T" on the screen you would set RS high.

The LCD may be connected to the PIC microcontroller using either a 4-bit bus or an 8-bit
bus. If an 8-bit bus is used, all 8 bits must be on one port. If a 4-bit bus is used, it must be
connected to either the bottom 4 or top 4 bits of one port. Enable and Register Select may
be connected to any port pin. R/W should be tied to ground as the LCD OUT command is
write only. PICBasic assumes the LCD is connected to specific pins unless told otherwise.
In this project, the LCD is used with a 4-bit bus with data lines DB4- DB7 connected to
PIC microcontroller PORTB.4 - PORTB.7, Register Select to PORTB.4 and Enable to
PORTB.5. It is also preset to initialize the LCD to a 2 line display. Data lines D0-D3, VSS
and RW are connected to ground.VEE and VDD are connected to potentiometer.

2.1.11. Stepper motor


A stepper motor is a brushless, synchronous electric motor that converts electrical pulses
into mechanical movement. It is also an electrically powered motor that creates rotation
from electrical current driven into the motor. Physically, stepper motors can be large but
are often small enough to be driven by current about mili ampere. Current pulses are
applied to the motor, and this generates discrete rotation of the motor shaft. This is unlike a
DC motor that exhibits continuous rotation. Although it is possible to drive a stepper motor
in a manner where it has near continuous rotation, doing so requires more finesse of the
input waveform that drives the stepper motor. Every revolution of the stepper motor is
divided into a discrete number of steps, and the motor must be sent a separate pulse for
each step. The stepper motor can only take one step at a time and each step is the same
size. Since each pulse causes the motor to rotate a precise angle, the motor’s position can
be controlled without any feedback mechanism. As the electrical pulses increase in
frequency, the step movement changes into continuous rotation, with the speed of rotation
directly proportional to the frequency of the pulses. Step motors are used every day in both
industrial and commercial applications because of their low cost, high reliability, high

26
DIGITAL DOOR LOCK SYSTEM

torque at low speeds and a simple, rugged construction that operates in almost any
environment.

The shaft or spindle of a stepper motor rotates in discrete step increments when electrical
command pulses are applied to it in the proper sequence.

The motors rotation has several direct relationships to these applied input pulses. The
sequence of the applied pulses is directly related to the direction of motor shafts rotation.
The speed of the motor shafts rotation is directly related to the frequency of the input
pulses and the length of rotation is directly related to the number of input pulses applied.
One of the most significant advantages of a stepper motor is its ability to be accurately
controlled in an open loop system. Open loop control means no feedback information
about position is needed. This type of control eliminates the need for expensive sensing
and feedback devices such as optical encoders. Your position is known simply by keeping
track of the input step pulses.

Fig 2.10 Unipolar stepper motor

2.1.11.1. Types of Stepper Motors


There are varieties of stepper motors available, but most of them can be separated into two
groups:

2.1.11.1.1. Permanent-magnet (PM) stepper motor


This kind of motor creates rotation by using the forces between a permanent magnet and an
electromagnet created by electrical current. An interesting characteristic of this motor is
that even when it is not powered, the motor exhibits some magnetic resistance to turning.

27
DIGITAL DOOR LOCK SYSTEM

2.1.11.1.2. Variable-reluctance (VR) stepper motor


Unlike the PM stepper motor, the VR stepper motor does not have a permanent magnet
and creates rotation entirely with electromagnetic forces. This motor does not exhibit
magnetic resistance to turning when the motor is not powered. but in this project we use
permanent-magnet(pm) stepper motor.

Features

The rotation angle of the motor is proportional to the input pulse.

The motor has full torque at stand still(if the windings are energized)

Precise positioning and repeatability of movement since good stepper motors have an
accuracy of – 5% of a step and this error is non cumulative from one step to the next.

Excellent response to starting/stopping/reversing.

Very reliable since there are no contact brushes in the motor. Therefore the life of the
motor is simply dependant on the life of the bearing.

The motors response to digital input pulses provides open-loop control, making the motor
simpler and less costly to control.

It is possible to achieve very low speed synchronous rotation with a load that is directly
coupled to the shaft.

A wide range of rotational speeds can be realized as the speed is proportional to the
frequency of the input pulses

Stepper motor 28BYJ-48 Parameters

Model : 28BYJ-48

Rated voltage : 12V DC

Number of Phase : 3

Speed Variation Ratio : 1/64

Stride Angle : 5.625° /64

Frequency : 100Hz

28
DIGITAL DOOR LOCK SYSTEM

2.1.12. Interfacing circuits


The bipolar stepper motor usually has four wires coming out of it. Unlike uni-polar
steppers, bipolar steppers have no common center connection. They have two independent
sets of coils instead. You can distinguish them from uni-polar steppers by measuring the
resistance between the wires. You should find two pairs of wires with equal resistance. If
you’ve got the leads of your meter connected to two wires that are not connected (i.e. not
attached to the same coil), you should see infinite resistance (or no continuity).

2.1.12.1. High-voltage high-current Darlington transistor array (ULN2003A)


The ULN2003A is monolithic high-voltage, high-current Darlington transistor arrays. Each
consists of seven NPN Darlington pairs that feature high-voltage outputs with common-
cathode clamp diodes for switching inductive loads. The collector-current rating of a single

Darlington pair is 500mA.

The Darlington pairs may be paralleled for higher current capability.

Applications include relay drivers, hammer drivers, lamp drivers, display drivers (LED and
gas discharge), line drivers, and logic buffers. From listed application we used it as relay
driver . The ULN2003A has a 2.7kΩ _series base resistor for each Darlington pair for
operation directly with TTL or 5-V CMOS devices.

Features

500-mA-Rated Collector Current (Single Output)

High-Voltage Outputs ... 50V

Inputs Compatible With Various Types of Logic

Relay-Driver Applications

29
DIGITAL DOOR LOCK SYSTEM

U2
9
COM
1 16
1B 1C
2 15
2B 2C
3 14
3B 3C
4 13
4B 4C
5 12
5B 5C
6 11
6B 6C
7 10
7B 7C
ULN2003A

Fig 2.11 ULN2003A

30
DIGITAL DOOR LOCK SYSTEM

CHAPTER THREE

3. PROJECT METHODOLOGY
In the first stage of conducting the project, we are going to search for reading materials.
Since we are going to use digital devices, we are expecting to refer points on the working
principles, logical characteristics and general operation principle of these components. In
addition, we use any related materials and/or their electronic equivalents that can provide
us any help throughout the design process.Then we will start the design process by starting
to calculate values of resistors, capacitors ,center tap transformer ,diode and motor needed
for the proper operation of the components and adjustment of the working principles.
Moreover, we determine the appropriate power supply for the components. Then we will
check our preceding work and the connections before our next step. And we’ll draw the
right circuit making it ready for simulation. Then the next step is simulation of the design
with the aid one of many simulation software’s such as protest, and so on. Then we will
prepare for the final process by buying the required materials. After buying the necessary
equipment’s, we will implement the project in physically realizable form.

Proteus ISIS 8 Professional is used to design the circuit and simulate it. After completing
the circuit assembly and configuration, it’s time to verify whether the source code
compiled is virtually accurate or not.. When the simulation After all done without error, the
circuit will be packaged and the users may ready to use. Successfully runs, this means that
the circuit can be constructed and soldered on PCB board. Then, the circuit will be tested
and troubleshooting may necessary taken to overcome those circuitry problems.

The approach is by experimental modular design where each is analyzed extensively and
tested for functionality so as to prove satisfactory before joining the blocks to form the
overall circuit.

The modules considered in this project are:

The power supply module

The keypad unit

31
DIGITAL DOOR LOCK SYSTEM

The display unit ( LCD)

The control unit (microcontroller PIC16F877A)

v)The output e.g. LED

Finally, the last part of our project is testing and inspecting of our work, i.e. we will put the
device in the place where it is intended to be and see if it works as proper as it was
intended to work.

3.1. The general block diagram of the system


In the construction of this project, the modular design is employed, the project is divided
into two parts namely hardware and software with each of the section analyzed
extensively. The block diagram of the microcontroller based digital door lock system is
shown below:

12V regulator 5V regulator


Power supply Transformer
Circuit Circuit

UN2003A Microcontroller 4x3 keypad


Driver

LCD LED
Motor

Fig3.1 block diagram of the microcontroller based digital door lock system.

The construction of this project employs majorly the PIC16F877A microcontroller for
several reasons.

Firstly, it is operated on a +5V DC supply and draws very little current. Furthermore, it has
a very low power dissipation and high speed of operation and still maintains its data in
case of power loss. Finally it has a large storage memory.

32
DIGITAL DOOR LOCK SYSTEM

3.2. The circuit diagram of the system:


The general circuit diagram of the system is explained as follows.
LCD1

LM016L
+5V
VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E

+5v
1
2
3

4
5
6

7
8
9
10
11
12
13
14

D1
LED-YELLOW

D2
LED-RED
Q1
BC547

C2
U1 Q2
22pf 13 33 BC547
OSC1/CLKIN RB0/INT
CRYSTAL 14 34
OSC2/CLKOUT RB1
35
RB2
100k X12 36
26%

RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RV1 C1 RA2/AN2/VREF-/CVREF RB5
22pf 5 39
+5v RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
R1 RC4/SDI/SDA
23
10k 1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
+12V RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9

U2
D 0 #
+88.8

3
10 7
7C 7B
11 6
12
6C
5C
6B
5B
5
A
1 2 3
13 4
4C 4B
14 3
3C 3B
15 2
16
2C
1C
2B
1B
1
B 4 5 6
9
COM
ULN2003A
C 7 8 9
D 0 #

Fig 3.2 Description of the general circuit diagram

3.2.1 Brief Description of the general circuit diagram of the system


This project entails the use of a microcontroller PIC16F877A as the basis for a security
lock.

The crystal oscillator used is 20MHz speed. The system is peculiar because of the use of
the microcontroller and the LCD. The LCD has 8 pins and uses a serial protocol which is
compatible with the microcontroller PIC16F877A with 4 pins use for communication. The

33
DIGITAL DOOR LOCK SYSTEM

motor supplied by 12V while the microcontroller is supplied with 5V.After all program of
our project load on microcontroller, the microcontroller communicate with LCD to display
WELL COME TO ASTU and DIGITAL DOOR LOCK BY ECENG STUDENTS. Then
immediately microcontroller gives command press * through LCD.

The keypad accepts digits from the user, based on the code written inside the
PIC16F877A microcontroller. The digits are simultaneously displayed on LCD screen.

The microcontroller compares the digits with the right pin number in its EEPROM
memory. If the password entered to 4x3 keypad is correct then, the “correct” is displayed
on the LCD screen, the LED1 gives yellow light and the motor rotates in the clockwise
direction which shows that the door is opened. After delay time (2000ms) LED2 gives red
light. Finally, the motor rotates anticlockwise direction and the word “door closed” is
displayed on the LCD.

The Authentic user can change the pin to another one, which is stored in the memory by
first inputting the right code. To change the old (current) password we use the master
password to keep the system security.

34
DIGITAL DOOR LOCK SYSTEM

CHAPTER FOUR

4. DESIGN AND ANALYSIS OF PROJECT

4.1. Software design

4.1.1. Software components:


This section presents the software’s used in the design of the system .

4.1.1.1. Micro C:
Micro C is powerful, feature rich development tool for PIC micros. It designed to provide
the programmer with the easiest possible for developing applications for embedded
systems, without compromising performance or control.

Fig 4.1 Micro C

4.1.1.2. . Proteus 8 Professional:


is an interactive system level simulator. Which combines mixed mode circuit simulation,
micro-processor models and interactive component models to allow the simulation of
complete micro-controller based designs.

35
DIGITAL DOOR LOCK SYSTEM

Fig4.2 Proteus 8 Professional


The software is designed in order to support the effectiveness of the hardware device.

The complex and intricate operating routine of the software is achieved by writing the
program in modules starting with the program algorithm.The software was written in
Mikrobasic language, and was written in sections for easy debugging and troubleshooting.
Each section is tailored to meet the duty that will be imposed on the corresponding
hardware unit.

4.1.1.3. Visual Basic:


(VB) is an ideal programming language for developing sophisticated professional
applications for Microsoft Windows. It makes use of Graphical User Interface for creating
robust and powerful applications. Coding in GUI environment is quite a transition to
traditional, linear programming methods where the user is guided through a linear path of
execution and is limited to small set of operations. In GUI environment, the number of
options open to the user is much greater, allowing more freedom to the user and developer.
Visual Basic is an event-driven programming language. Visual Basic enables the user to
design the user interface quickly by drawing and arranging the user elements.

36
DIGITAL DOOR LOCK SYSTEM

4.1.1.4. Hyper Terminal:


is a computer networking assistance program for the Microsoft Windows operating system
from version 3.1 to Vista. HyperTerminal was designed to remotely connect to other
computers as well as to provide diagnostic tools to the local computer system.
HyperTerminal is a text-based program, as opposed to a graphical one. Thus, it uses text
commands to perform functions. HyperTerminal also has scroll functionality that enables
us to view received text that has scrolled off the screen.

4.1.1.5. Serial Port Monitoring :


Serial Port Monitor is a professional and powerful system utility for RS232/422/485 COM
ports monitoring. The program monitors, displays, logs and analyzes all serial port activity
in a system. This is an ideal way to track down problems that may occur during application
or driver development, testing and optimization of serial devices, etc. Serial Port Monitor
also offers advanced filtering and search, professional built-in terminal and data exporting
options, user-friendly and flexible interface among its key advantages. It is a completely
software solution, you don't need any additional hardware to use it. from the above soft
ware we used Micro C programming and Proteus 8 Professional.

The software was designed in order to support the effectiveness of the hardware device.
The complex and intricate operating routine of the software is achieved by writing the
program in modules starting with the program algorithm. The software was written in
Mikro C language, and was written in sections for easy debugging and
troubleshooting. Each section is tailored to meet the duty that will be imposed on the
corresponding hardware unit.

37
DIGITAL DOOR LOCK SYSTEM

4.1.2. Flow chart


Read Check
correct Door open
start keypad password

wrong

Password attempt
Check wrong
password

Wrong
password

Fig 4.3 flow chart

4.1.3. Software Debugging.

38
DIGITAL DOOR LOCK SYSTEM

The program for the keypads was tested and buttons were discovered not working properly
due to bounce, to overcome this problem key de bounce with delay varied was done until
the bouncing disappeared. The power supply, keypads and display unit were further tested
by-employing them in the circuitry of the electronic door lock, the input into the
microcontroller was done using the keypads and it worked properly without no error of
bouncing. Also the display unit displays the output of the keypad. It was however observed
that the display (LCD) had some of its lines cut off; this is due to manufacturers fault,
because another LCD display was tested with the circuit and no such fault discovered. The
whole project was later tested by inputting the correct and wrong PINs. The
microcontroller activated the port to which the LED (which represents the load) was
connected when the correct PIN was entered. And when the wrong pin was entered the
microcontroller activated the port to which the wrong password is displayed.

All the process involves were displayed on the LCD accordingly. Hence the whole circuit
was confirmed to be working properly.

39
DIGITAL DOOR LOCK SYSTEM

LM016L
+5V

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
+5v
1
2
3

4
5
6

7
8
9
10
11
12
13
14
D1
LED-YELLOW

D2
LED-RED
Q1
BC547

C2
U1 Q2
22pf 13 33 BC547
OSC1/CLKIN RB0/INT
CRYSTAL 14 34
OSC2/CLKOUT RB1
35
RB2
X12 36
26%

RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
C3 RA2/AN2/VREF-/CVREF RB5
22pf 5 39
RV1 +5v RA3/AN3/VREF+ RB6/PGC
100k 6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
R1 RC4/SDI/SDA
23
10k 1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
+12V RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9

U2
D 0 #
+88.8

3
10 7
7C 7B
11 6
12
6C
5C
6B
5B
5
A 1 2 3
13 4
4C 4B
14 3
3C 3B
15 2
16
2C
1C
2B
1B
1
B 4 5 6
9
COM
ULN2003A
C 7 8 9
D 0 #

Fig4.4 general circuit diagram

4.1.3.1. Keypad program.


Apart from the programming of the key pad to coordinating the activities of the
microcontroller, another major programming done here is preventing jumping of the input
key (bouncing). The program scans each key to detect a depressed key, and then a de
bouncing routine which is about 150ms delay is then executed. The routine is important so
as to decipher authentic key pressed from Electrical noise. This can lead to multiple
inputs. The program decodes an authentic key pressed and stores the numeric values in a
given register, it repeats this until the required numbers of key inputs are collected.
Kp=0;
int i = 0, j, cnt;
int w1;
//keypad module connections
char keypadPort at PORTD;
//end keypad module connections.

40
DIGITAL DOOR LOCK SYSTEM

4.1.3.2. LCD program


Table 4.1 External dependencies of Lcd.

External dependencies of Lcd.

The following Description Example :


variables must be :
defined in all
projects using Lcd
Library :
extern sfr sbit Register sbit LCD_RS at
LCD_RS: Select line. RB4_bit;
extern sfr sbit Enable line. sbit LCD_EN at
LCD_EN: RB5_bit;
extern sfr sbit Data 7 line. sbit LCD_D7 at
LCD_D7; RB3_bit;
extern sfr sbit Data 6 line. sbit LCD_D6 at
LCD_D6; RB2_bit;
extern sfr sbit Data 5 line. sbit LCD_D5 at
LCD_D5; RB1_bit;
extern sfr sbit Data 4 line. sbit LCD_D4 at
LCD_D4; RB0_bit;
Extern sfr sbit Register sbit
LCD_RS_Direction; Select LCD_RS_Direction
direction at TRISB4_bit;
pin.
extern sfr sbit Enable sbit
LCD_EN_Direction; direction LCD_EN_Direction
pin. at TRISB5_bit;
Extern sfr sbit Data 7 sbit
LCD_D7_Direction; direction LCD_D7_Direction

41
DIGITAL DOOR LOCK SYSTEM

pin. at TRISB3_bit;
extern sfr sbit Data 6 sbit
LCD_D6_Direction; direction LCD_D6_Direction
pin. at TRISB2_bit;
extern sfr sbit Data 5 sbit
LCD_D5_Direction; direction LCD_D5_Direction
pin. at TRISB1_bit;
extern sfr sbit Data 4 sbit
LCD_D4_Direction; direction LCD_D4_Direction
pin. at TRISB0_bit;

42
DIGITAL DOOR LOCK SYSTEM

Table4.2 Lcd_Init

Prototype void Lcd_Init();


Returns Nothing.
Description Initializes Lcd module.
Requires Global variables:
LCD_D7: Data bit 7
LCD_D6: Data bit 6
LCD_D5: Data bit 5
LCD_D4: Data bit 4
LCD_RS: Register Select (data/instruction) signal pin
LCD_EN: Enable signal pin
LCD_D7_Direction: Direction of the Data 7 pin
LCD_D6_Direction: Direction of the Data 6 pin
LCD_D5_Direction: Direction of the Data 5 pin
LCD_D4_Direction: Direction of the Data 4 pin
LCD_RS_Direction: Direction of the Register Select pin
LCD_EN_Direction: Direction of the Enable signal pin
must be defined before using this function.
Example // Lcd pinout settings
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;

// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;

43
DIGITAL DOOR LOCK SYSTEM

sbit LCD_EN_Direction at TRISB5_bit;


sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
...

Lcd_Init();

Table 4.3 Lcd_Out

Prototype void Lcd_Out(char row, char column, char *text);


Returns Nothing.
Description Prints text on Lcd starting from specified position. Both string
variables and literals can be passed as a text.
Parameters :
row: starting position row number
column: starting position column number
text: text to be written
Requires The Lcd module needs to be initialized. See Lcd_Init routine.
Requires The Lcd module needs to be initialized. See Lcd_Init routine.
Example // Write character "i" at row 2, column 3:
Lcd_Chr(2, 3, 'i');

Table 4.4 Available Lcd Commands

Available Lcd Commands

Lcd Command Purpose


_LCD_FIRST_ROW Move cursor to the 1st row
_LCD_SECOND_ROW Move cursor to the 2nd row

44
DIGITAL DOOR LOCK SYSTEM

_LCD_THIRD_ROW Move cursor to the 3rd row


_LCD_FOURTH_ROW Move cursor to the 4th row
_LCD_CLEAR Clear display
_LCD_RETURN_HOME Return cursor to home position, returns a
shifted display to its original position. Display
data RAM is unaffected.
_LCD_CURSOR_OFF Turn off cursor
_LCD_UNDERLINE_ON Underline cursor on
_LCD_BLINK_CURSOR_ON Blink cursor on
_LCD_MOVE_CURSOR_LEFT Move cursor left without changing display data
RAM
_LCD_MOVE_CURSOR_RIGHT Move cursor right without changing display
data RAM
_LCD_TURN_ON Turn Lcd display on
_LCD_TURN_OFF Turn Lcd display off
_LCD_SHIFT_LEFT Shift display left without changing display data
RAM
_LCD_SHIFT_RIGHT Shift display right without changing display
data RAM

45
DIGITAL DOOR LOCK SYSTEM

4.2. Hardware Design.

The power supply is provided first to the hardware and through voltage regulator, the
circuit components receive their proper supply voltage.

• After that, the LCD displays the required code and shows to the person to enter the
password

• The code is received by the module and checks the code availability.

• For correct code, LCD displays the word

4.2.1. The major building blocks of this project are:

Regulated Power supply.

Microcontroller.

LED Indicators.

LCD display unit.

4x3 keypad

Stepper motor

The functional Operation of the control Circuitry of the project is described in the
Subsection.

This project will require following hardware:

a. 1 x PIC16F877A

b. 1 x PR9B Printed Circuit Board (PCB)

c. 1 x 4x3 keypad

d. 1 x 2X16 LCD

e. 1x 2N2222 transistor

f. Related electronic components

46
DIGITAL DOOR LOCK SYSTEM

Fig 4.5 Hardware implementation

47
DIGITAL DOOR LOCK SYSTEM

CHAPTER FIVE

5. REASULT AND DISCUSION:

5.1. Reasult

LM016L
+5V
VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E

+5v
1
2
3

4
5
6

7
8
9
10
11
12
13
14

D1
LED-YELLOW

D2
LED-RED
Q1
BC547

C2
U1 Q2
22pf 13 33 BC547
OSC1/CLKIN RB0/INT
CRYSTAL 14 34
OSC2/CLKOUT RB1
35
RB2
100k X12 36
26%

RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RV1 C1 RA2/AN2/VREF-/CVREF RB5
22pf 5 39
+5v RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
R1 RC4/SDI/SDA
23
10k 1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20
1

3
RD1/PSP1
21
+12V RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9

U2
D 0 #
0.00
1

3
10 7
7C 7B
11 6
12
6C
5C
6B
5B
5
A 1 2 3
13 4
4C 4B
14 3
3C 3B
15 2
16
2C
1C
2B
1B
1
B
4 5 6
9
COM
ULN2003A
C 7 8 9
0 #
Fig 5.1 result show WELL TO ASTU

48
DIGITAL DOOR LOCK SYSTEM

LM016L
+5V

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
+5v
1
2
3

4
5
6

7
8
9
10
11
12
13
14
D1
LED-YELLOW

D2
LED-RED
Q1
BC547

C2
U1 Q2
22pf 13 33 BC547
OSC1/CLKIN RB0/INT
CRYSTAL 14 34
OSC2/CLKOUT RB1
35
RB2
100k X12 36
26%

RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RV1 C1 RA2/AN2/VREF-/CVREF RB5
22pf 5 39
+5v RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
R1 RC4/SDI/SDA
23
10k 1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
+12V RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9

U2
D 0 #
0.00

3
10 7
7C 7B
11 6
12
6C
5C
6B
5B
5
A 1 2 3
13 4
4C 4B
14 3
3C 3B
15 2
16
2C
1C
2B
1B
1
B
4 5 6
9
COM
ULN2003A
C 7 8 9
0 #
Fig 5.2 show DIGITAL DOOR LOCK BY ECENG STUDENT

49
DIGITAL DOOR LOCK SYSTEM

LM016L
+5V

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
+5v
1
2
3

4
5
6

7
8
9
10
11
12
13
14
D1
LED-YELLOW

D2
LED-RED
Q1
BC547

C2
U1 Q2
22pf 13 33 BC547
OSC1/CLKIN RB0/INT
CRYSTAL 14 34
OSC2/CLKOUT RB1
35
RB2
100k X12 36
26%

RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RV1 C1 RA2/AN2/VREF-/CVREF RB5
22pf 5 39
+5v RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
R1 RC4/SDI/SDA
23
10k 1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
+12V RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9

U2
D 0 #
0.00

3
10 7
7C 7B
11 6
12
6C
5C
6B
5B
5
A 1 2 3
13 4
4C 4B
14 3
3C 3B
15 2
16
2C
1C
2B
1B
1
B
4 5 6
9
COM
ULN2003A
C 7 8 9
0 #
Fig5.3 show press *

50
DIGITAL DOOR LOCK SYSTEM

LM016L
+5V

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
+5v
1
2
3

4
5
6

7
8
9
10
11
12
13
14
D1
LED-YELLOW

D2
LED-RED
Q1
BC547

C2
U1 Q2
22pf 13 33 BC547
OSC1/CLKIN RB0/INT
CRYSTAL 14 34
OSC2/CLKOUT RB1
35
RB2
100k X12 36
26%

RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RV1 C1 RA2/AN2/VREF-/CVREF RB5
22pf 5 39
+5v RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
R1 RC4/SDI/SDA
23
10k 1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
+12V RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9

U2
D 0 #
0.00

3
10 7
7C 7B
11 6
12
6C
5C
6B
5B
5
A 1 2 3
13 4
4C 4B
14 3
3C 3B
15 2
16
2C
1C
2B
1B
1
B
4 5 6
9
COM
ULN2003A
C 7 8 9
0 #
Fig 5.4 show enter

51
DIGITAL DOOR LOCK SYSTEM

LM016L
+5V

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
+5v
1
2
3

4
5
6

7
8
9
10
11
12
13
14
D1
LED-YELLOW

D2
LED-RED
Q1
BC547

C2
U1 Q2
22pf 13 33 BC547
OSC1/CLKIN RB0/INT
CRYSTAL 14 34
OSC2/CLKOUT RB1
35
RB2
100k X12 36
26%

RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RV1 C1 RA2/AN2/VREF-/CVREF RB5
22pf 5 39
+5v RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
R1 RC4/SDI/SDA
23
10k 1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
+12V RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9

U2
D 0 #
+40.9

3
10 7
7C 7B
11 6
12
6C
5C
6B
5B
5
A 1 2 3
13 4
4C 4B
14 3
3C 3B
15 2
16
2C
1C
2B
1B
1
B
4 5 6
9
COM
ULN2003A
C 7 8 9
0 #
Fig 5.5 show correct

52
DIGITAL DOOR LOCK SYSTEM

LM016L
+5V

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
+5v
1
2
3

4
5
6

7
8
9
10
11
12
13
14
D1
LED-YELLOW

D2
LED-RED
Q1
BC547

C2
U1 Q2
22pf 13 33 BC547
OSC1/CLKIN RB0/INT
CRYSTAL 14 34
OSC2/CLKOUT RB1
35
RB2
100k X12 36
26%

RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RV1 C1 RA2/AN2/VREF-/CVREF RB5
22pf 5 39
+5v RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
R1 RC4/SDI/SDA
23
10k 1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
+12V RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9

U2
D 0 #
-79.2

3
10 7
7C 7B
11 6
12
6C
5C
6B
5B
5
A 1 2 3
13 4
4C 4B
14 3
3C 3B
15 2
16
2C
1C
2B
1B
1
B
4 5 6
9
COM
ULN2003A
C 7 8 9
0 #

Fig 5.6 show Door closed

53
DIGITAL DOOR LOCK SYSTEM

LM016L
+5V

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
+5v
1
2
3

4
5
6

7
8
9
10
11
12
13
14
D1
LED-YELLOW

D2
LED-RED
Q1
BC547

C2
U1 Q2
22pf 13 33 BC547
OSC1/CLKIN RB0/INT
CRYSTAL 14 34
OSC2/CLKOUT RB1
35
RB2
100k X12 36
26%

RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RV1 C1 RA2/AN2/VREF-/CVREF RB5
22pf 5 39
+5v RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
R1 RC4/SDI/SDA
23
10k 1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
+12V RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9

U2
D 0 #
-79.1

3
10 7
7C 7B
11 6
12
6C
5C
6B
5B
5
A 1 2 3
13 4
4C 4B
14 3
3C 3B
15 2
16
2C
1C
2B
1B
1
B
4 5 6
9
COM
ULN2003A
C 7 8 9
0 #
Fig 5.7 wrong password

54
DIGITAL DOOR LOCK SYSTEM

5.2. Discusion:
After all program of our project load on microcontroller, the microcontroller communicate
with LCD to display the results on the above figure. At the first time WELL COME TO
ASTU and DIGITAL DOOR LOCK BY ECENG STUDENTS. Then immediately
microcontroller gives command press * through LCD.

The keypad accepts digits from the user, based on the code written inside the
PIC16F877A microcontroller. The digits are simultaneously displayed on LCD screen.

The microcontroller compares the digits with the right pin number in its EEPROM
memory. If the password entered to 4x3 keypad is correct then, the “correct” is displayed
on the LCD screen, the LED1 gives yellow light and the motor rotates in the clockwise
direction which shows that the door is opened. After delay time (2000ms) LED2 gives red
light. Finally, the motor rotates anticlockwise direction and the word “door closed” is
displayed on the LCD. which show that Door is closed.

55
DIGITAL DOOR LOCK SYSTEM

CHAPTER SIX
6. CONCLUSION AND RECCOMMENDATION
6.1. Conclusion
In this paper microcontroller based on Digital Door Lock System has been presented in
terms of the software algorism development and hard ware implementation. This senior
project has an attempt to design and implement the digital door lock system using
PIC16F877A microcontroller.

The simulation is performed as we expected. This digital door lock system is easy to use
and highly reliable. The system uses to keep owners property from theft. The digital door
lock system is very important and durable as when we compare with non electronic or
digital door lock system. Finally when we install in the hardware all series and parallel
push buttons (switches) arranged in the keypad form for simplicity for authorized person
and not to know the correct password to unauthorized person.

In summary, the microcontroller based Electronic lock is a security system device that
utilizes pin input as key for users’ access. Therefore, our objectives have been met, hence
the software and hardware implementation is successful undertaking.

56
DIGITAL DOOR LOCK SYSTEM

6.2. RECCOMMENDATION

In meeting the design requirements, there are several technical challenges that must be
overcome. In our project the challenging task was writing the program in MICRO C
language. In this project we face different problems and constraints in which some of them
have been met but there are different challenges that have been an obstacle to accomplish
the software and hardware of our project part.

The first challenge was being new for different software and equipment such as
microcontroller, PROTEUS and MICROC .We have never discuss these software and
equipment in our previous lessons, because of these we are forced to read and understand
every concepts, different programming languages, data sheets and other help tutorials.

The other big challenge was scarcity of materials for implementing our design in our
laboratories. As we tried to state on our proposal this project needs some materials such as
microcontroller, PIC socket, bridgeboard, keypad, LCD, relay driver, push button,
regulator, lead, iron solder, buffer or alarm indicator etc. but it was impossible to find these
equipment in our lab and as well as in the market area. We had tried to solve these
problems by our self but we face some financial problems and we forced our self to find
some substituted design of our hardware project part. It was impossible to find full version
software; this makes us to pass through a lot of cracked fake software that took our time.

Generally we recommend to our department in order to solve the above problem for the
next generation.

57
DIGITAL DOOR LOCK SYSTEM

6.3. References.
[1] Martin Bates “introduction to Microelectronic system”, The PIC16F877A
Microcontroller system security Eng.J., Vol. 3 No1, October 2000.pp4-8.

[2] www.freepatentonline.com/History_locks and safe/5775142.html, pp.3-6.

[3] Stan D’souza, “multiplexing LED drive and a 4X4 Keypad Sampling’’, Microchip
Technology Inc.,Application Note 529, DS000529E, November 1997, pp 27.

[4]Tutorial & Reference for 8052, http://www.8052.com. pp27

[5]PIC Microcontrollers for beginners, www.MicroElektronika.com, chapter 2.html.

[6]Y.A.Adediran, Applied Electricity, Finon Associates, Minna Nigeria, 1997, pp99.

[7]A.K Theraja and B.L Theraja, A textbook of Electrical Technology, 23rd Edition, S
Chand andCompany Limited, New Delhi, 2002, pp 2364.

[8]Datasheet For “PIC16F87X 28/40-Pin 8-bit CMOS FLASH Microcontroller”


www.microchip.com

[8]“PIC Micro Mid-range Microcontroller family Reference Manual”,DS33023A,


Microchip Technologyinc., December 1997,pp 8-15, 44

58
DIGITAL DOOR LOCK SYSTEM

6.4. Appendix

6.4.1. The system program or code


unsigned short kp;

char code1[15] ,user1[4];

int i = 0, j, cnt;

int w1;

//keypad module connections

char keypadPort at PORTD;

//end keypad module connections

//lcd module connections

sbit LCD_RS at RB4_bit;

sbit LCD_EN at RB5_bit;

sbit LCD_D4 at RB0_bit;

sbit LCD_D5 at RB1_bit;

sbit LCD_D6 at RB2_bit;

sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;

sbit LCD_EN_Direction at TRISB5_bit;

sbit LCD_D4_Direction at TRISB0_bit;

sbit LCD_D5_Direction at TRISB1_bit;

sbit LCD_D6_Direction at TRISB2_bit;

sbit LCD_D7_Direction at TRISB3_bit;

//

void code_enter(){

59
DIGITAL DOOR LOCK SYSTEM

kp = 0; //Reset key code variable

//wait for key to be pressed and released

do

//kp = Keypad_Key_Press(); // store key code in kp variable

kp = Keypad_Key_Click(); // store key code in kp variable

while (!kp);

//prepare value for output, transform key to it's ASCII value

switch (kp){

case 1: kp = 49; break; // 1

case 2: kp = 50; break; // 2

case 3: kp = 51; break; // 3

//case 4: kp = 65; break; // A for 4x4 pad

case 5: kp = 52; break; // 4

case 6: kp = 53; break; // 5

case 7: kp = 54; break; // 6

//case 8: kp = 66; break; // B for 4x4 pad

case 9: kp = 55; break; // 7

case 10: kp = 56; break; // 8

case 11: kp = 57; break; // 9

//case 12: kp = 67; break; // C for 4x4 pad

case 13: kp = 42; break; // *

case 14: kp = 48; break; // 0

case 15: kp = 35; break; // #

//case 16: kp = 67; break; // D for 4x4 pad

60
DIGITAL DOOR LOCK SYSTEM

code1[i] = kp;

Lcd_out(2, i+1,"*"); //Print key ASCII value on Lcd

i++;

//20ms delay function no need of it

void code_read(){ //read data from eeprom

Delay_ms(20);

user1[0] = EEPROM_Read(0x00); // Read data from address 0

Delay_ms(20);

user1[1] = EEPROM_Read(0x01); // Read data from address 1

Delay_ms(20);

user1[2] = EEPROM_Read(0x02); // Read data from address 2

Delay_ms(20);

user1[3] = EEPROM_Read(0x03); // Read data from address 3

Delay_ms(20);

void code_write(){ //write data to eeprom

Delay_ms(20);

EEPROM_Write(0x00,code1[0]); // Write data to address 0

61
DIGITAL DOOR LOCK SYSTEM

Delay_ms(20);

EEPROM_Write(0x01,code1[1]); // Write data to address 1

Delay_ms(20);

EEPROM_Write(0x02,code1[2]); // Write data to address 2

Delay_ms(20);

EEPROM_Write(0x03,code1[3]); // Write data to address 3

void change_code(){

Lcd_Cmd(_LCD_CLEAR); // clear display

Lcd_Out(1,1, "Enter New Code:");

i = 0;

code_enter();

code_enter();

code_enter();

code_enter()

code_write();

delay_ms(20);

code_read();

delay_ms(20);

Lcd_Cmd(_LCD_CLEAR); // clear display

Lcd_Out(1,1, "New Code Set");

Delay_ms(5000);

62
DIGITAL DOOR LOCK SYSTEM

void main(){

ADCON1 != 0x07;

Keypad_Init(); // Initialize Keypad

//ANSEL= 0; // Configure AN pins as digital I/O

//ANSELH = 0;

//c1on_bit=0; // disable comparator

//c2on_bit=0;

TRISC = 0x00;

PORTC = 0x00;

Lcd_Init(); // Initialize LCD

Lcd_Cmd(_LCD_CLEAR); // Clear display

Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off

code_read();

Lcd_Cmd(_LCD_CLEAR); //clear display

Lcd_Cmd(_LCD_CURSOR_OFF); // cursor off

//Lcd_Out(1, 1, msg1);

//Delay_ms(500);

Lcd_Cmd(_LCD_CLEAR); // Clear display

Lcd_Out(1, 5, "WELL COME TO"); // Write message text on LCD

Lcd_Out(2, 4, " ASTU");

delay_ms(2000);

Lcd_Cmd(_LCD_CLEAR);

Lcd_Out(1, 1, "DIGITAL DOOR LOCK :");

63
DIGITAL DOOR LOCK SYSTEM

Lcd_Out(2, 1, "BY ECENG STUDENTS");

delay_ms(2000);

cnt = 0;

L1: do{

Lcd_Cmd(_LCD_CLEAR);

Lcd_Out(2, 3, "Press *");

i = 0;

code_enter();

if(code1[0] == 42){ // *

Lcd_Cmd(_LCD_CLEAR); // clear display

Lcd_Out(1, 1, "Enter Code");

//delay_ms(500);

i = 0;

code_enter();

code_enter();

code_enter();

code_enter();

code_enter();

if(code1[0] == '1' && code1[1] == '2' && code1[2] == '3' && code1[3] == '4'
&& code1[4] == '5' ){ // master code

code_enter();

if(code1[5] == 35){ // #

64
DIGITAL DOOR LOCK SYSTEM

change_code();

else if(cnt<3 && code1[0] == user1[0] && code1[1] == user1[1] &&


code1[2] == user1[2] && code1[3] == user1[3] && code1[4] == 35){ // save password
verification

//PORTC.f6=1;

//delay_ms(2000);

Lcd_Cmd(_LCD_CLEAR); //Lcd clear

Lcd_out(1,4,"Door Open"); //Door Open

EEPROM_Read(0x21);

w1 = 1;

Delay_ms(20);

EEPROM_Write(0X21, w1);

Delay_ms(20);

EEPROM_Read(0x21);

//move stepper motor to ON position

PORTC=0x49;

Delay_ms(500);

PORTC=0x43;

65
DIGITAL DOOR LOCK SYSTEM

Delay_ms(500);

Delay_ms(5000);

PORTC=0x06;

Delay_ms(500);

PORTC=0x2C;

Delay_ms(500);

Delay_ms(5000);

//goto L1;

//PORTC.f5=1;

//delay_ms(2000);

LCD_Cmd(_LCD_CLEAR);

Lcd_out(1,4,"Door Close");

EEPROM_Read(0x21);

w1 = 0;

Delay_ms(20);

EEPROM_Write(0x21, w1);

Delay_ms(20);

EEPROM_Read(0x21);

66
DIGITAL DOOR LOCK SYSTEM

//move stepper motor to OFF position

PORTC=0x0C;

Delay_ms(500);

PORTC=0x06;

Delay_ms(500);

PORTC=0x03;

Delay_ms(500);

PORTC=0x09;

Delay_ms(500);

Delay_ms(2000);

//goto L1;

else{

cnt++;

Lcd_Cmd(_LCD_CLEAR); //clear display

Lcd_Out(1, 1, "Wrong Password");

Delay_ms(2000);

//goto L1;

if(cnt>=3)

goto L1;

67
DIGITAL DOOR LOCK SYSTEM

}while(1);

68

You might also like