Documente Academic
Documente Profesional
Documente Cultură
1 I ntroduction
4 PCB Layout
5 Project hardware
6 Project Software
8 Future Modifications
9 Conclusion
10 Bibliography
11 Data sheets
CHAPTER 1
I NTRODUCTI ON
1. 0 I NTRODUCTI ON
Security is prime concern in our day- today life. Every one wants to be
in security chain. The micro controller based digital lock present here is an
area. The system comprises a small electronics unit with a numeric keypad,
which is fixed out side the entry door to control a magnetic lock. When an
the relay operated for a limited time to unlatched the magnetic lock so the
door can be pushed/pulled to open. At the end of present delay, the relay
reenergizes and the door gets locked again. I f the entered password is correct
the display displays that “ Code is correct – access allowed. ” And if the
entered password is wrong it gives three beep signals and display will displays
When the codehas been incorrectly entered five times, the codelock
will switch to alarm relay are turned off after entering a valid user Access
code. This function thwarts any attempt by hackers to quickly try a large
number of codes in a sequence. The secret code can be changed any time
BLOCK DI AGRAM
Motor
1&2
Relay 3
2. 1 Block Diagram Description
1. Key Pad
3. LCD display
4. Relay Driver
5. Buzzer
6. Power supply
1. Key Pad:
There are total 12 keys. These are normally open push buttons.
When button is normal i. e. not pressed then it gives logic zero. And
instruction set and pin- out. The on- chip Flash allows the program memory
3. LCD display :
This display contains two internal byte wise resisters, One for the
that can be programmed to generate any desired character that can form
using a dot matrix. To distinguish between these two data areas, the hex
00H is chosen. Port 1 is used to furnish the commandor data byte, and
bit 7 is monitored for logic high ( Busy) to ensure the display is not
overwritten.
4. Relay Driver :
Therefore to drive the relay we are using relay driver block by using
5. BUZZER:
This is output device. When wrong code is pressed then buzzer will
turn ON.
6. Power supply:
This block converts 230 Vac into + 5 volt dc and + 12 volts dc.
+ 12 Volts are required for Relay driver circuit, motor and Buzzer.
CHAPTER 3
CI RCUI T DI AGRAM
port 0, port1, port2, port 3. I n our project we are using switch to enter the
number. The switches are normally open and normally it gives logic one
output. When we press the button switch will becomeclose, and it gives logic
Relay is used to drive the motor. Actually there are two relays to
drive the motor in forward direction and in reverse direction. Normally both
relays are de- energized therefore motor is off and door remains closed.
When we press the right code then the relay1 will turn ON and supply is
given to motor, to open the door. Door will open for predefined time. After
predefined time, relay1 turns off and relay 2 turns ON. As relay 2 turns
ON the supply is given to motor, to close the door. After sometime the
When we press wrong code then the buzzer will turn on and no
PCB Layout
4. 1 PCB Layout
CHAPTER 5
PROJECT
HARDWARE
5 Project Hardware:
5. 1 Microcontroller 89C51
5. 3 Relay
5. 4 Capacitors
5. 5 Diodes
5. 8 Presets
5. 9 Transistors
5. 1 Microcontroller 89C51
standard MCS- 51 instruction set and pin out. The on- chip Flash allows
zero frequency and supports two Software selectable power saving modes.
The I dle Mode stops the CPU while allowing the RAM, timer / counters
, serial port and interrupt system to continue functioning. The Power- down
Mode saves the RAM contents but freezes the oscillator disabling all other chip
32 Programmable I / O Lines.
GND: - Ground
an output port, each pin can sink eight TTL inputs. When 1s are written
to port 0 pins, the pins can be used as high impedance inputs. Port 0
may also be configured to be the multiplexed low order address / data bus
has internal pull- ups. Port 0 also receives the code bytes during Flash
pull- ups. The port 1output buffers can sink/source four TTL inputs. When
1s are written to port 1 pins they are pulled high by the internal pull- ups
and can be used as inputs. As inputs , Port 1 pins that are externally
being pulled low will source current ( I I L) becauseof the internal pull-
ups. Port 1 also receives the low- order address bytes during Flash
ups. The port 2 output buffers can sink / source four TTL inputs. When 1s
are written to Port 2 pins they are pulled high by the internal
pull- ups and can be used as inputs. As inputs, Port 2 pins that are
internal pull- ups. Port 2 emits the high- order address byte during fetches
application, it uses strong internal pull- ups when emitting 1s. During
Port 2 also receives the high- order address bits and somecontrol signals
pull- ups. The Port 3 output buffers can sink / source four TTL inputs.
When 1s are written to Port 3 pins they are pulled high by the internal
pull- ups and can be used as inputs. As inputs, Port 3 pins that are
externally being pulled low will source Current ( I I L) becauseof the pull-
ups.
RST: - Reset input , A high on this pin for two machine cycles
ALE / PROG: - Address Latch Enable output pulse for latching the low
byte of the address during accesses to external memory. This pin is also
and may be used for external timing or clocking purposes. Note, however ,
that one ALE pulse is skipped during each access to external Data
SFR location 8EH. With the bit set, ALE is active only during a MOVX
execution mode.
to GND in order to enable the device to fetch code from external program
also receives the 12- volt programming enable voltage ( VPP) during
General Features: -
terminals are required for device of suchtypes, input ( Vin) output ( Vo) and
the current limiting resistor is also internal to the device. The main
external circuit and the minimum of external components. Fig. Shows the
the three terminal regulators offers only fixed output voltages,there are wide
variety of voltages available, both + Ve and – Ve. The output current range
from 100 m A to 3 A.
General description: -
Features:
2) NO external componentsrequired.
voltage ( I supplies)
I nput voltage 35 V
Operatingtemperaturerange 00 to 700 c
completely separate from the first. For example a low voltage battery circuit
connection inside the relay between the two circuits; the link is magnetic and
mechanical.
for a 12V relay, but it can be as much as 100mA for relays designed to
operate from lower voltages. Most I Cs ( chips) cannot provide this current
and a transistor is usually used to amplify the small I C current to the larger
value required for the relay coil. The maximumoutput current for the popular
555 timer I C is 200mA so these devices can supply relay coils directly
without amplification.
Relays are usually SPDT or DPDT but they can have many more
sets of switch contacts, for example relays with 4 sets of changeover contacts
are readily available. For further information about switch contacts and the
Most relays are designed for PCB mounting but you can solder wires
directly to the pins providing you take care to avoid melting the plastic
The coil will be obvious and it may be connected either way round. Relay
coils produce brief high voltage' spikes' when they are switched off and
this can destroy transistors and I Cs in the circuit. To prevent damage you
The animated picture shows a working relay with its coil and switch
contacts. You can see a lever on the left being attracted by magnetism when
the coil is switched on. This lever moves the switch contacts. There is one
set of contacts ( SPDT) in the foreground and another behind them, making
I f you are choosing a relay for an existing PCB you will need to ensure
that its dimensions and pin arrangement are suitable. You should find this
Coil voltage :
The relay' s coil voltage rating and resistance must suit the circuit
powering the relay coil. Many relays have a coil rated for a 12V supply
but 5V and 24V relays are also readily available. Some relays operate
perfectly well with a supply voltage which is a little lower than their rated
value.
Coil resistance
The circuit must be able to supply the current required by the relay
supplyvoltage
Relay coil current =
coil resistance
For example: A 12V supply relay with a coil resistance of 400
output current 200mA) , but it is too muchfor mostI Cs and they will
to control. You will need to check the voltage and current ratings. Note that
the voltage rating is usually higher for AC, for example: " 5A at 24V DC
or 125V AC" .
voltage ' spike' produced when the relay coil is switched off. The diagram
' backwards' so that it will normally not conduct. Conduction only occurs
continue flowing through the coil and it is harmlessly diverted through the
diode. Without the diode no current could flow and the coil would produce
a damaging high voltage ' spike' in its attempt to keep the current flowing.
switch. For switching small DC currents ( < 1A) at low voltage they are
usually a better choice than a relay. I n these cases a relay will be needed,
but note that a low powertransistor may still be needed to switch the
current for the relay' s coil! The main advantages and disadvantages of
Advantages of relays:
Relays can switch AC and DC, transistors can only switch DC.
Relays are a better choice for switching large currents ( > 5A) .
Disadvantages of relays:
Relays cannot switch rapidly ( except reed relays) , transistors can switch
Relays use more power due to the current flowing through their coil.
transistor may be needed to switch the current for the relay' s coil.
5. 4Capacitors
supplies by acting as a reservoir of charge. They are also used in filter circuits
constant) signals.
capacitors; axial where the leads are attached to each end ( 220µF in picture)
and radial where both leads are at the same end ( 10µF in picture) . Radial
capacitors tend to be a little smaller and they stand upright on the circuit
board.
are clearly printed with their capacitance and voltage rating. The voltage
rating can be quite low and it should always be checked when selecting an
electrolytic capacitor.
Unpolarised capacitors ( small values, up to 1µF)
small capacitors because there are many types of them and several different
labeling systems.
Many small value capacitors have their value printed but without a
multiplier, so you need to use experience to work out what the multiplier
should be!
5. 5 Diodes
Electricity uses up a little energy pushing its way through the diode,
rather like a person pushing through a door with a spring. This meansthat
voltage drop and is about 0. 7V for all normal diodes which are made from
the current passing through the diode so they have a very steep
Reverse Voltage
but all real diodes leak a very tiny current of a few µA or less. This can
the diode will fail and pass a large current in the reverse direction, this is
called breakdown.
Ordinary diodes can be split into two types: Signal diodes which
pass small currents of 100mA or less and Rectifier diodes which can pass
large currents. I n addition there are LED ( which have their own page)
Colours of LEDs
LEDs are available in red, orange, amber, yellow, green, blue and white.
Blue and white LEDs are muchmore expensive than the other colours.
not by the colouring of the ' package' ( the plastic body) . LEDs of all
or clear ( often described as ' water clear' ) . The coloured packages are
with two leads. Only one of the LEDs can be lit at one time and
they are less useful than the tri- colour LEDs described above.
R = ( VS - VL)
/I
VS = supply voltage
VL = LED voltage ( usually 2V, but 4V for blue and white LEDs)
permitted
resistor value which is greater, so that the current will be a little less than
you chose.I n fact you maywish to choosea greater resistor value to reduce
the current ( to increase battery life for example) but this will make the
LED lessbright.
For example
bleepers.
6V and 12V buzzers can be used with a 9V supply. Their typical current is
about 25mA.
Bleepers have wide voltage ranges, such as 3- 30V, and they pass a
Buzzers and bleepers mustbe connected the right way round, their red
lead is positive ( + ) .
5. 8 Presets
used.
made. The screw must be turned many times ( 10+ ) to move the slider
from one end of the track to the other, giving very finecontrol.
5. 9 Transistors
always partly on) . The amount of current amplification is called the current
Types of transistor
material used to make the transistor. Most transistors used today are NPN
because this is the easiest type to make from silicon. I f you are new to
( E) .
These terms refer to the internal operation of a transistor but they are not much
SYSTEM SOFTWARE
6. Program:
;*************************************************
*********************
; TI TAL : ADVANCED SECURI TY SYSTEM
;*************************************************
**********************
; P0. 0 = SWI TCH 0 = FOR DI GI T 0
; P0. 1 = SWI TCH 1 = FOR DI GI T 1
; P0. 2 = SWI TCH 2 = FOR DI GI T 2
; P0. 3 = SWI TCH 3 = FOR DI GI T 3
; P0. 4 = SWI TCH 4 = FOR DI GI T 4
; P0. 5 = SWI TCH 5 = FOR DI GI T 5
; P0. 6 = SWI TCH 6 = FOR DI GI T 6
; P0. 7 = SWI TCH 7 = FOR DI GI T 7
; P2. 0 = SWI TCH 8 = FOR DI GI T 8
; P2. 1 = SWI TCH 9 = FOR DI GI T 9
; P2. 2 = SWI TCH 10 = FOR ENTER
; P2. 3 = SWI TCH 11 = FOR PROGRAM
; P2. 4 = FORWARD MOTOR I . E OPEN DOOR
; P2. 5 = REVERSE MOTOR I . E CLOSE DOOR
; P2. 6 = BUZZER
; R0 = LSB
; R1 = NEXT TO LSB
; R2 = MSB
; R5 = I NPUT KEY
; R6 = DELAY
; R7 = DELAY
;------------------------------------------------------------------
-----------
; PROGRAM STARTS HERE:
ORG 0000H
CLR P2. 4
CLR P2. 5
CLR P2. 6
SKAGAI N:
MOV R0, # 0FFH
MOV R1, # 0FFH
MOV R2, # 0FFH
ACALL LCDDI SPLAY
ACALL SWREAD
MOV R2, A
ACALL LCDDI SPLAY
ACALL SWREAD
MOV R1, A
ACALL LCDDI SPLAY
ACALL SWREAD
MOV R0, A
UP0122: ACALL SETDI SPLAY
MOV A, P2
ANL A, # 0CH
CJNE A, # 0CH, PRGORFI X2
AJMP UP0122
PRGORFI X2:
CJNE A, # 08H, SKAGAI N
MOV A, R0
CJNE A, 30H, DENIED
MOV A, R1
CJNE A, 31H, DENI ED
MOV A, R2
CJNE A, 32H, DENIED
MOV 46H, # 00H
SETB P2. 4
CLR P2. 4
SETB P2. 5
MOV 45H, # 05H
UP_DD: LCALL DELAY
DJNZ 45H, UP_DD
CLR P2. 5
SJMP SKAGAI N
;------------------------------------------------------------------
-----------
DENI ED:
MOV A, 46H
CJNE A, # 03H, DDDD1
SETB P2. 6
YAHA: LCALL HANG
SJMP YAHA
DDDD1: I NC 46H
SETB P2. 6
MOV 45H, # 0FH
DENI ED1: ACALL DENI EDI SPLAY
DJNZ 45H, DENI ED1
CLR P2. 6
SJMP SKAGAI N
;
LOCKDI SPLAY:
MOV A, # 01H
ACALL COMMAND
MOV A, # 80H
ACALL COMMAND
MOV R0, # 05H
P225: ACALL DELAY
DJNZ R0, P225
MOV DPTR, # LINE72
LCALL DI SPLAY_LI NE
MOV A, # 0C0H
ACALL COMMAND
MOV DPTR, # LINE73
LCALL DI SPLAY_LI NE
MOV R0, # 05H
UP525: ACALL DELAY
DJNZ R0, UP525
RET
;----------------------------------------------------------
DI SPLAY_LI NE:
CLR A
MOVC A, @A+ DPTR
I NC DPTR
CJNE A, # ' $ ' , GO_TO_DISPLAY
RET
GO_TO_DI SPLAY:
ACALL DI SPLAY
AJMP DI SPLAY_LI NE
;-------------------------------------------------------------
COLLAGEDI SPLAY:
MOV A, # 01H
ACALL COMMAND
MOV A, # 80H
ACALL COMMAND
MOV R0, # 05H
P5225: ACALL DELAY
DJNZ R0, P5225
MOV DPTR, # LINE572
LCALL DI SPLAY_LI NE
MOV A, # 0C0H
ACALL COMMAND
MOV DPTR, # LINE573
LCALL DI SPLAY_LI NE
MOV R0, # 05H
UP5525: ACALL DELAY
DJNZ R0, UP5525
RET
;------------------------------------------------------------------
-----
SAVEDI SPLAY:
MOV A, # 01H
ACALL COMMAND
MOV A, # 80H
ACALL COMMAND
MOV R0, # 05H
P2251: ACALL DELAY
DJNZ R0, P2251
MOV DPTR, # LINE721
LCALL DI SPLAY_LI NE
MOV A, # 0C0H
ACALL COMMAND
MOV DPTR, # LINE731
LCALL DI SPLAY_LI NE
MOV R0, # 05H
UP5251: ACALL DELAY
DJNZ R0, UP5251
RET
;------------------------------------------------------------------
-------
ALLOWDI SPLAY:
MOV A, # 01H
ACALL COMMAND
MOV A, # 80H
ACALL COMMAND
MOV R0, # 05H
P02251: ACALL DELAY
DJNZ R0, P02251
MOV DPTR, # LINE0721
LCALL DI SPLAY_LI NE
MOV A, # 0C0H
ACALL COMMAND
MOV DPTR, # LINE0731
LCALL DI SPLAY_LI NE
MOV R0, # 05H
UP05251: ACALL DELAY
DJNZ R0, UP05251
RET
;------------------------------------------------------------------
--------
; DELAY SUBROUTI NE USED TO GENERATE DELAY OF 1 SECONDS:
;------------------------------------------------------
DELAY: MOV R7, # 0FAH
LOOP1: MOV R6, # 0FFH
LOOP: DJNZ R6, LOOP
DJNZ R7, LOOP1
RET
;------------------------------------------------------------------
-----------
; LCD DI SPLAY SUBROUTI NES
;-----------------------
LCDDI SPLAY:
ACALL DELAY
MOV A, # 01H
ACALL COMMAND
MOV A, # 80H
ACALL COMMAND
MOV DPTR, # LINE1
LCALL DI SPLAY_LI NE
UP1234: MOV A, # 0C0H
ACALL COMMAND
MOV DPTR, # LINE2
LCALL DI SPLAY_LI NE
MOV A, # 20H
ACALL DI SPLAY
MOV A, R2
ORL A, # 30H
ACALL DI SPLAY
MOV A, R1
ORL A, # 30H
ACALL DI SPLAY
MOV A, R0
ORL A, # 30H
ACALL DI SPLAY
MOV A, # 0A1H
ACALL DI SPLAY
RET
;------------------------------------------------------------------
----
SETDI SPLAY:
ACALL DELAY
MOV A, # 01H
ACALL COMMAND
MOV A, # 80H
ACALL COMMAND
MOV DPTR, # LINE11
LCALL DI SPLAY_LINE
AJMP UP1234
;------------------------------------------------------------------
-------
; COMMAND SUBROUTI NE USED TO I NI TI LI SE LCD DI SPLAY:
;-------------------------------------------------
COMMAND: ACALL READY
MOV P1, A
CLR P3. 2
CLR P3. 3
SETB P3. 4
CLR P3. 4
RET
;------------------------------------------------------------------
------
; DI SPLAY SUBROUTI NE USED TO DI SPLAY DATA ON LCD DI SPLAY:
DI SPLAY: ACALL READY
MOV P1, A
SETB P3. 2
CLR P3. 3
SETB P3. 4
CLR P3. 4
RET
;------------------------------------------------------------------
-------
; READY SUBROUTI NE USED TO CHECK THE LCD STATUS i. e. BUSY OR NOT
READY: CLR P3. 4
MOV P1, # 0FFH
CLR P3. 2
SETB P3. 3
WAI T: CLR P3. 4
SETB P3. 4
JB P1. 7, WAI T
CLR P3. 4
RET
;------------------------------------------------------------------
-----------
SWREAD:
MOV R5, # 00H
MOV A, P0
CJNE A, # 0FFH, CHECKSW
MOV A, P2
ANL A, # 03H
CJNE A, # 03H, CHECKSW1
AJMP SWREAD
CHECKSW: RRC A
JNC DOWN111
I NC R5
AJMP CHECKSW
DOWN111: MOV A, P0
CJNE A, # 0FFH, DOWN111
MOV A, R5
RET
CHECKSW1:
MOV R5, # 08H
CHECKSW11: RRC A
JNC DOWN1111
I NC R5
AJMP CHECKSW11
DOWN1111: MOV A, P2
ANL A, # 03H
CJNE A, # 03H, DOWN1111
MOV A, R5
RET
;----------------------------------------------------------------
DENI EDI SPLAY:
MOV A, # 01H
ACALL COMMAND
MOV A, # 80H
ACALL COMMAND
MOV R0, # 05H
PK02251: ACALL DELAY
DJNZ R0, PK02251
MOV DPTR, # LINE0721K
LCALL DI SPLAY_LI NE
MOV A, # 0C0H
ACALL COMMAND
MOV DPTR, # LINE0731K
LCALL DI SPLAY_LI NE
MOV R0, # 05H
UP05251K: ACALL DELAY
DJNZ R0, UP05251K
RET
;------------------------------------------------------------------
------
HANG:
MOV A, # 01H
ACALL COMMAND
MOV A, # 80H
ACALL COMMAND
MOV R0, # 02H
P22517: ACALL DELAY
DJNZ R0, P22517
MOV DPTR, # LINE7217
LCALL DI SPLAY_LI NE
MOV A, # 0C0H
ACALL COMMAND
MOV DPTR, # LINE7317
LCALL DI SPLAY_LI NE
MOV R0, # 02H
UP52517: ACALL DELAY
DJNZ R0, UP52517
RET
;*************************************************
*****************************
COMM1: DB 3CH, 0EH, 06H, 01H, ' $ '
LI NE1: DB ' SECURI TY SYSTEM. $ '
LI NE2: DB ' ENTER CODE =$ '
LI NE72: DB ' SECURI TY ACCESS $ '
LI NE73: DB ' CONTROL SYSTEM. $ '
LI NE572: DB ' GOVT. POLY. KARAD. $ '
LI NE573: DB ' TY EE PRESENTS$ '
LI NE721: DB ' NEW PASSWARD $ '
LI NE731: DB ' SAVED. $'
LI NE0721: DB ' CODE I S CORRECT. $ ' LI
NE0731: DB ' ACCESS ALLOWED $ ' LI
NE11: DB ' PRESS EN2FI X/PRG$ '
LI NE0721K: DB ' CODE I N- CORRECT. $ '
LI NE0731K: DB ' ACCESS DENI ED. $ '
LI NE7217: DB ' System is Hanged$'
LI NE7317: DB ' Press Reset. $ '
CHAPTER 7
APPLCATI ONS
AND
ADVANTAGE
7. 1 Applications:
Digital card accessin telephone exchange.
Locker in bank.
7. 3 Advantages:
Too little space is required for it to set for any operation at any
location.
LCD display which makes very easy to understand the operation taking
place.
Moderate price.
CHAPTER 8
FUTURE
I n future from our point of view we will not make use of password
instead of that we shall be able to make use of detecting finger print or again
CONCLUSI ON
9. 0 CONCLUSI ON
I t was are pleasure that we deal with our project “ 89C51 Micro-
Thus we can say that with this project we can automatically control the lock
just by giving the password, for security purpose. So only the user can
BI BLI OGRAPHY
10. 0 BI BLI OGRAPHY
- Kenneth J. Ayala
- I ntel
DATA SHEETS