0% found this document useful (0 votes)
10 views59 pages

Security

The document outlines a project focused on developing an enhanced password security system using the AT89S8252 microcontroller. It details the hardware and software components, including a keypad interface, USB connectivity, and real-time logging features for user access. The project aims to improve security and usability by allowing multiple user codes and tracking entry times, making it suitable for various secure environments like universities and hospitals.

Uploaded by

soodsahil54
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views59 pages

Security

The document outlines a project focused on developing an enhanced password security system using the AT89S8252 microcontroller. It details the hardware and software components, including a keypad interface, USB connectivity, and real-time logging features for user access. The project aims to improve security and usability by allowing multiple user codes and tracking entry times, making it suitable for various secure environments like universities and hospitals.

Uploaded by

soodsahil54
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

SYPERVISED BY

DR.: MANSOUR AL-ZUAIR


PERPARED BY
ABDULLAH ALI ALMUKSHAMI
Table of content
Introduction .
80C51 microcontroller and DB-51 microcontroller.
Previous project description .
Current project description .
Hardware .
Software .
problem .
System demonstration and result .
Conclusion .
References .
Introduction :
Today , it is important to use security systems
in our life for many purposes and many places .
security systems are improving day by day.
Many companies have contended to provide
high accurate security system .
Generally , we will talk about password
security system which is completion of the
previous project . In this project we
development previous project and we addition
electric lock and real time software in order to
be more secure .
Project goal’s
The target of this project is to design hardware and write
software to make following operation :
• Hardware .
1. Keypad interface .
2. USB interface to transfer entry record's .
3. Real lock interface .
4. Add LED interface .
• Software .
1. Add time of the day .
2. Record a time stamp to each entry .
3. Add " load record " function to the administrator .
The summary of Previous project :

• system operation :
1. Receive the unique code .(password)
2. Make the verification operation .
3. Display the result on 7-segment .

• Type of user :
1. Administration password .
2. Normal user’s .

• System modes :
1. Programming mode .
2. Verification mode .
Project description :

In this project, a device that is used on doors or


main entrances to have secure access to a place is to
be designed and implemented. This device also keeps
track of those allowed to enter and record the time
they entered and exit. It is programmable so that
many different codes could be programmed, one per
user.

THIS DEV
ICE ARE
USED IN O
UR
PROJECT
CURRENT SYSTEM :

The current system is a password security


system. After reading the previous project, I want to
improve that system in order to be more secure and
easy to be handle where the administrator (boss) can
decode the password and inter to the system. The
password differs from one user to another and more
than one user can handle\use the system. Also, the
administrator or the official can download from the
system to PC using USB that is connected to the
computer. This is for more protection and security
where one can know when users get in and out from
the sites .By doing all these procedures, one can
guarantee knowing those who are inside the building
or laboratories (labs) at that time.
Security services and beneficial places

Searching centre
Universities
Hospital's
Ministries
Libraries
Laboratories
Airport's
Companies
80C51 microcontroller family
The processing unit in our project is AT89S8252 , which is
one of the 8051 family , there are many type of
microcontroller that is compatible with it . This type of
microcontroller have extra feature more than any one .
Pin configuration :

The 8051 chip may be


one of the following IC’s
package :
• PDIP package with 40 pin
•PLCC package with 44 pin
Block diagram of 8051 microcontroller

EXTERNAL
INTERRUPTS

On-chip
Interrupt flash
ETC
control On-chip TIMER 0
COUNTER
INPUTS
RAM TIMER 1

CPU

OSC BUS CONTROL 4 I/0 PORTS SERIAL


PORT

TXD RXD
P0 P2 P1 P3

ADDRESS/DATA
Fundamental operation of Microcontroller
A typical micro-controller system has the following
configuration.

Clock Micro-controller RAM for data and


oscillator e.g. AT89S8252 program
i.e.
16.42MHz
/reset
ROM for storing startup
program
Switch

Peripheral IO devices,
GND e.g. 8255, 8253 real time
clock, etc.
AT89S8252 features :

The most important features of AT89S8252 are:


Compatible with MCS 8051 products .
8K bytes flash memory .
2K bytes EEPROM .
4V to 6V operation range .
fully static operation : 0 Hz to 24 MHz .
three – level program memory lock .
256x8 bit internal RAM .
32 programmable I/O lines .
three 16-bit timer/counter .
nine interrupt sources .
Type of memory :
The microcontroller has three general types of memory :
 On-chip memory .
 External code memory .
 External RAM .

On- chip memory: refers to any memory (code, RAM) that


physically exists on the microcontroller itself.
External code memory: is code (or program) memory
that resides off-chip. This is often in the form of an external
EEPROM.
External RAM: is RAM memory that resides off-chip.
This is often in the form of standard static RAM or flash
RAM.
On chip memory :
On-chip memory have 256 byte is really one of two type :
• internal RAM
• SFR memory
1 - The 128 byte of Internal RAM is subdivided into :
a) register bank
b) bit memory
00h Reg. Bank0
R0 R1 R2 R3 R4 R5 R6 R7
08h Reg. Bank1
10h R0 R1 R2 R3 R4 R5 R6 R7
Reg. Bank2
18h R0 R1 R2 R3 R4 R5 R6 R7 Reg. Bank3
20h
R0 R1 R2 R3 R4 R5 R6 R7
28h Bits 00-3Fh
30h 00 08 10 18 20 28 30 38
Bits 40-6Fh
40 48 50 58 60 68 70 78
7Fh General
80h General user RAM & stack space IRAM
Special function register SFRs
SFRs
FFh
On chip memory

2) the second 128 byte is represent the SFR :


special function register (SFR ) are area of memory that control special
functionality of microcontroller .

80H P0 SP DPL DPH PCON 87H


88H TCON TL0 TL1 TH0 TH1 8FH
90H P1 97H
98H SCON SBUF 9FH
A0H A7H
P2
A8H AFH
IE
B0H B7H
B8H P3 BFH
C0H IP C7H
C8H CFH
D0H T2CON RCAP2L RCAP2H TL2 TH2 D7H
D8H DFH
PSW
E0H E7H
E8H EFH
F0H F7H
F8H FFH
B
Addressing mode :
immediate Addressing .
direct addressing .
indirect addressing .
external direct .
NOTE :the MOVX is used with the external memory; in the opposite MOV
is used with internal memory.
Execution time
Address width mnemonic operation
(µsec)
Read external
8 bits MOVX A,@Ri 2
RAM @Ri
write external
8 bits MOVX @Ri,A 2
RAM @Ri
Read external
16 bits MOVX A,@DPTR 2
RAM @DPTR
Write external
16 bits MOVX @DPTR,A 2
RAM @DPTR
Timer

The microcontroller operates depend on an external crystal .


This is an electrical device which , when energy is applied , emits
pulses at a fixed frequency 24 MHz is the maximum frequency
which the AT89S8252 can be used .

SFR of timer names and it’s description :


SFR Description SFR address

TH0 Timer 0 high byte 8CH


TL0 Timer 0 low byte 8AH
TH1 Timer 1 high byte 8DH
TL1 Timer 1 low byte 8BH
TH2 Timer 2 high byte CDH
TL2 Timer 2 low byte CCH
TCON Timer control 88H
TMOD Timer mode 89H
T2CON Timer 2 control C8H
Interrupts
An interrupt is some event , which interrupts normal program execution . The
microcontroller offers two levels of interrupt priority low and high .interrupt
priority are controlled by IP SFR(B8 h) . The figure show below is illustrate
IP_SFR format :
Bit Name Bit address Function
0 PX0 B8H External 0 interrupt priority
1 PT0 B9H Timer 0 interrupt priority

2 PX1 BAH External 1 interrupt priority

3 PT1 BBH Timer 1 interrupt priority


4 PS BCH Serial interrupt priority
5 - - Undefined
6 - - Undefined
7 - - Undefined
HARDWAER
Block diagram and chip description :

Here we explain how to pervious system is work and the


addition partition in this project .

NTERFACE
MUC UNIT
AT89s89 To port1 PA and PB Keypad
(PPI)
52 switches

USB DEVICE

Activated from P3 (11xxxxxx)

Relay device

Electrical lock
IC’s description
The following are the major units of the system:
1. AT89S8252; The microcontroller used as the processing unit in the
System, it is derivative of the 8051microcontroller and compatible
With it.
2 .8255 parallel peripheral interface (PPI): this chip is used as an
interface
Between Inputs (output) devices and the microcontroller.
3 .Seven segment display: this chip accept seven-segment code and
displays it.
4 .Relay device (12 v) .
5 .amplifier ( 2n2222) .
6 .connect to the system external supply 12v to operate electric lock .
7 .switches to enter the code into the system .
Addressing mode

The AT89S8252 use multiplexed address in port 0 so for 16 bit address (64 k )
The 8bit low address is issue thought port 0 , and after that latched using the
ALE / signal . The figure show below is illustrate that :

Memory or PPI
AT 89S8252 Latch
74LS373
Port0 low address 8bit
11110001
11110001

OE/

ALE/

High address 8bit 00011111


Port2
00011111
IC’s connection :
The following is the most important connection in our board .
1. The PPI is part of the external Data memory space ,this 64k
and can be accessed using RD\and WR\signals ,so, this
signals should be connected to RD\and WR\ of PPI.
2. Reset of all chips must be connected to the reset switch.
3. The port 0 of the microcontroller should be connected to the
latch .
4. The PSEN\pin is used to access the External Code Memory
space ,because our program is stored in the internal flash
memory this pin should be left unconnected .
Note :
• Port 0 and port 1 could not be used as I/O ports because the MUC to read the
data from PPI
• the EA/ pin must be connected to VCC because the program store in FLASH
System units

The following three section will describe the system


hardware unit :
 input unit .
 output unit .
 processing unit .
Input unit

Since all the I\O ports of the microcontroller are occupied we


have to use external PPI as interface between the switches and
the microcontroller ,this PPI will be part of External Data
Memory Space and can be accessed by the microcontroller for
reading or writing .
MICROCONT
ROLLER
AT89s8252 SWITCH
P FLIP
P FLOP
DATA I DATA (7474) DATA

WR/ RD/

clear

Note : the pin P1.7 (97H) of part1 is used for clearing the flip flop (97H)
Output unit :

Since the microcontroller has I/0ports that are ready to use


without any External interface, we use one of this ports
(port 1) for the output unit. There are 7-segment chips used
to display the output, every chip is Connected to the port 3
through a latch
MICROC
ONTROL LA 7-
LER TC SEG
(AT89S82 DATA FROM P1 HE MEN
52) DATA
S T

6 CONTROL LINE FROM PORT 3 (11xxxxxx)


Memory organization :
I – program memory
the AT89S8252 microcontroller has separate address spaces for
program memory and data memory . The program memory can be
up to 64KB long .
FFFF
External

2000

1FFF
Internal
Flash
(8kb)
0000

Note : the memory organization is valid when the EA/ pin is


connected to VCC .
Memory organization :
II- Data memory :
The AT89S8252 can directly address up to 64Kbyte of data
memory external to the chip . The MOVX instruction accesses
the external data memory .
FFFF

We use the data memory and program


memory spaces as the following : EXTERNAL

1. the internal flash will be used to save 0800


the program . 07FF
INTERNAL
2. the internal EEPROM memory will be (EEPROM
used to save the user’s codes . MEMORY)
(2 K byte)
0000
Storing the code in RAM and EEPROM :
RAM EEPROM

NUMBER OF USER 0000H


- 00H
-
- -
- -
- -
-
30H
-
DIGIT 0=0 -
DIGIT1=0 31H - 30h is the first
DIGIT2=0 32H
DIGIT 0=0 30H address of first digit
DIGIT3=0 33H
DIGIT1=0
of
- 31H ADMINISTRATION
- DIGIT2=0
- 32H password
NUMBER OF USER 55H DIGIT3=0 33H

Next user
password
-
X 60H -
X 61H -
Temporary -
X 62H
storage X
-
63H -
-
- -
-
-
-
-
How determine the address of PPI (8055)

B B B B B B
B B B B B B B B B B
A1 A1 A1 A1 A1 A1
A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
4 4 3 2 1 0
P2 P2 P2 P2 P2 P2 P2 P2 P0 P0 P0 P0 P0 P0 P0 P0
ADDRESS .7 .6 .5 .4 .3 .2 .1 .0 .7 .6 .5 .4 .3 .2 .1 .0 PPI SELECTION AND
OF PPI G2 DATA TRANSFER
G1 A C B A A1 A0
N DONT
DONT CARE
CARE
DEC DEC SELECT PPI
SELECT PPI CS/ MODE

8060H 1 0 X X X X X X X 1 1 0 X X 0 0 READ PORT A

8061H 1 0 X X X X X X X 1 1 0 X X 0 1 READ PORT B

8062H SEND DATA TO


1 0 X X X X X X X 1 1 0 X X 1 0
PORT C

8063H
1 0 X X X X X X X 1 1 0 X X 1 1 CONTROL PORT
How to activate the latches that connects to 7-segment :

P3.7 P3.6 P3.5 P3.4 P3.3 P3.2 P3.1 P3.0

1 1 0 0 0 0 0 1 C1H SELECT 7-SEG1

1 1 0 0 0 0 1 0 C2H SELECT 7-SEG2

1 1 0 0 0 1 0 0 C4H SELECT 7-SEG3

1 1 0 0 1 0 0 0 C8H SELECT 7-SEG4

1 1 0 1 0 0 0 0 D0H SELECT 7-SEG5

1 1 1 0 0 0 0 0 E0H SELECT 7-SEG6


Physical access system
The project can be extended to work with many
applications ;one of these applications is the physical
access system .
The following devices will be used:
1. Relay: it is device acting like a switch. When the input to this
device is 12V the output will be switched from 0 V to 110 V.
2. (74LS02) IC: This is the IC number of the NOR gate, it will be
used to generate the input to the relay.
3. Amplifier : (2n 2222) or (2n1711) this device is rise the voltage .
4. External supply: 12v (1000mA) connect with the relay device
5. register 10K : connect with the output of NOR gate .
6. Diode (1n4007)or (1n4004) connect parallel with the coil of relay
, to prevent ante return current to the system board
Physical access system
SOFTWARE
System initialization :

When the reset switch is pressed the following


steps will be executed :
1. Initialize PPI to mode 0
2. Initialize EDIT-FLAG ,ADD-FLAG ,DELET-FLAG,
END-FLAG , COUNTER-HR , COUNTER-MIN ,
VALUE ,AND R7 TO ZERO .
3. Make clear FLAG-HRL , FLAG-MINL,FLAG-
MINH,TIME-FLAG,CLOCK-RUN, MINCOUNT-NEW
and HRCOUNT-NEW .
4. Make setting to one of TIME-ADJ and FLAG-HRH .
5. Save 0000 at the beginning of the user area (30 h).
Input routine
Input routine starts after the first message “time adjust ” that represent by
“t i n e a t ” after there message appear second message after 2
second , this message display “ HH - - MM”, after we input the hour and
minute , after that message appear –CODE – message .
The following steps explain this routine .
1. Input time by using input buttons .
2. after appear message – CODE- enter the administrator code .
3. Recognize what value entered .
4. save the recognized input

This routine is based on the polling technique , the polling technique is based
on checked the I/O port , if there is no input , then jump to check the I/Oport
again , until an input is occurred .
Output routine :
This routine will displays the output on six 7-segment chips . The block
diagram of the 7-segment chip used is shown in this figure :

Example :
The following two codes is
are examples of the 7-
segment :
E EQU 10000110b
A EQU 10010000b

The main routine for displaying the output will display one of the following :
“-ADDED”,”EDITED”,”DELETD”,”-PASS-”, “-FAIL-”,”-ERROR” and
“TINEDT”
Operation on user’s database :

the following five sections will describe how to add , edit


and delete codes of users from the user's database .and
another function such as adjust time and show time , the
previous operations are associated with the administrator .
there are two important variable that must be used by the
various routines :

Base Address : This variable holds the beginning address of the


database, it points to the memory location that hold the first digit of
administrator' password , which initially set to zero .
Users Counter: This variable holds the address for the memory location
that holds the number of users currently in the database .
Adding user :
Adding users can be done by saving the four digit password at
the end of the database .first , the next empty location in the
database must be found . this can be done by adding the address
to (4 x user counter) .Second , this address is used to save the
four digit password .
User
ADD-FLAG set to one if : counter

1 - the user enter the 4


ADMIN password
correctly . Base address (30
h)

2 – the user chooses 0


when “CHOOSE” Next empty
location
message is appear as
output

Base Address + ( 4 x user counter ) = the address of the next empty location ;
Editing user’s
Editing a user information means changing his password .
There are two flags associated with editing user's code . this flags are :
• EDIT_FLAG1
• EDIT_FLAG2
The flag EDIT_FLAG1 is set to one if :
1. the user enters the administrator password correctly .
2. the user chooses "1" when "CHOOSE" message appears as an
output

If the above conditions are satisfied , the next code will be


edited using the editing routing . there is another flag which
EDIT_FLAG2 and is set to one if the entered password to be
edited is founded in the database
Deleting user’s
There is one flag associated with deleting users this flag is
DELET_FALG , this flag is set one if :
the user enters the Administrator's Password correctly .
the user choose 2 when "CHOOSE" message appears as
output.
Whenever the DELET_FLAG is founded one , the routine for
deleting user will be entered .

The following steps , explain this routine :


1. jump to verification mode routine .
2. search the entered code; if it is not founded , then jump to display
"-FAIL-".
3. replace the founded 4-digit code with the last 4-digit code in the
database .
Adjust time and show time :

Adjust time :
1. The user chooses 4 when “CHOOSE” massage appears as output .
2. This message “HH - - MM” is appear as output “
3. Enter the adjust time or real time .

show time :
1. The user chooses 5 when “CHOOSE” massage appears as output .
2. The real time is appear as output “
3. Press switch 3 allow to exit to normal operation..
Method of clocking :

There are two method to solve clocking :


1. Hardware .
2. Software .

Note :
• Here we using second method , because this method is less part of
board .
• Using real time programming or multitasking . (pipeline ),
Timing by using software :
Another unit of this project is to add real time in order to use
it and display it when user password is recognized and PASS is
displayed . this time is recorded with each entry in EEPROM ,
the administration can display all successful accesses with the
time of each access . In this actual project we will concentrate to
create a real time running with the following conditions:
After reset the time must be displayed the format “ HH-
MM” for correct time. When the password of user is
recognized, the time must be displayed for some seconds before
PASS is displayed to indicate access time. In the menu
CHOOSE if SW4 is pressed , the actual time will be displayed
for 2 sec and pass to setting time display.
When SW5 is pressed in the menu CHOOSE the time will be
continuously displayed for any change by administrator . The
SW3 (END) switch allow to exit to normal operation.
Time- base operation :
Time delay 10 ms

Increase 10 msec counter 1

Counter 1msec
equal 100

Increase 1sec counter2

Reset counter1

NO
Counter 2 1sec
equal 60

Increase 1min counter3

Reset counter2

NO Counter 3 1min
equal 60

Increase 1hour counter4

Reset counter3

NO Counter 4 1hour
equal 24

Reset counter4

NO END Sub Routine


Technique to display number (binary ) in a 7-seg

Number in binary

Conversion to BCD

Digit high Digit low


(in BCD) (in BCD )

7-segment code 7-segment code


conversion conversion

Select related 7 segment Select related 7-segment


Send data (in 7-seg code) Send data (in 7-seg code )
What operation that used to calculate 1sec :

MOV 77h,#26
MOV 76h,#205
This delay is gives approximate 10 m sec
TT1: DJNZ 76h,TT1
DJNZ 77h,TT1 Execution time of any instruction is equal
2usec
Calculation 1 m sec :
(26*205)*2 u sec+2 u sec + 2 u sec = 0.010664 u sec=10.664 m sec
Calculation 1 sec :
10.664 m sec * 100 = 1 sec
Calculation 1 min :
1 sec * 60 = 1 min
Calculation 1 hour :
1min * 60 = 1 hour
Percentage of Error :
10 m 10 m
sec sec

Ideal
-----------
Theory
Time
10 m 10 m
sec After code sec

Practice
50 code delay
delay instruction
Time

Call time_base
Call time_base
After code = 50*2usec = 100usec

20 instruction ( in time -base) = 20 *


2u sec = 40 u sec

Total stopped time = 140usec maximum


Percentage of Error :

Clock stopped time


% of error = Clock running time

140usec
= = 0.014
10msec

= 1.4 %

We note the percentage of error is less equal 1.4 %


System demonstration :
1 – the first massage that appear on a 7-segment :

2 – after that is appear this massage ,


3- after enter the hour and minutes , this massage will be appear :

4- after that press enter to display massage –CODE-

5 – enter the administrator code then press enter


6- press switch “0” the code “-CODEA” will be appear .

7- enter the code to be added then press enter , the massage “ADDED”
will be display .

8 – press switch 1 the code “-CODEE” will be display


9- enter the code to be edited then press enter and enter new code the enter ,
the massage “EDITED” will be appear .

10- press switch 2 the code “-CODED” massage will appear .

11- enter the code to be deleted then press enter , the massage “DELETD”
will be appear .
12- press switch 4 the be make adjust time :

13- press switch 5 to display real time .


Conclusion :

What is achieved ?
1. We built the circuit that operate the electric lock
using amplifier , relay and diode.
2. connect LED into board and write program to
operated .
3. Written software for timing clock .
4. Learning write language of microcontroller .
Conclusion :
What is not achieved and why ?
1. Keypad interface .
2. Download information into USB .

Problem :
1. one of great problem that I have faced is time
, this no enough time .
2. The previous project take along time so ,
didn‘t have enough time to absorb ,
understand and handle completely the
present project .
3. didn’t have softcopy of previous project .
References :

1. The Intel microprocessor . by Barry.B


Brey 5th editions .
2. Intel's web site : www.intel.com
3. Atmel's web site : www.Atmel.com
4. 8052 web site : www.8052.com
5. CEN433 notes : by DR.:mohammed
Arafah.
6. AT89C8252 data sheet .
7. DB51 data sheet .
Any question ?

You might also like