Documente Academic
Documente Profesional
Documente Cultură
Declaration
No portion of the work referred to in the dissertation has been submitted in support of an
application for another degree or qualification of this or any other university/institute or other
institution of learning.
MEMBERS NAME
NUMAN ABDULLAH
DDP-SP14-BEE-025
MUHAMMAD HASEEB
DDP-SP14-BEE-026
TASHEEN JAVAID
DDP-SP14-BEE-045
1|Page
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
Acknowledgements
We would like to thank my parents who kept backing me up at all the times both financially and
morally.
We would also like to thank Sir Nounam Naeem and Sir Muzzam Ali for their guidance and
encouraging me to work hard and smart. I have found them very helpful while discussing the
optimization issues in this dissertation work. Their critical comments on my work have certainly
made me think of new ideas and techniques in the fields of optimization and software simulation.
I am grateful to the Allah Almighty who provides all the resources of every kind to us, so that we
make their proper use for the benefit of mankind. May He keeps providing us with all the
resources and guidance to help the humanity.
2|Page
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
Abstract
3|Page
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
Table of Contents
Declaration................................................................................................................1
Acknowledgements...................................................................................................2
Abstract.....................................................................................................................3
Introduction...............................................................................................................5
Literature Review......................................................................................................6
Project Design...........................................................................................................7
Design Description....................................................................................................8
Implementation..........................................................................................................9
Evaluation................................................................................................................14
Conclusions & Future Work....................................................................................15
4|Page
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
Introduction
Traditional lock systems using mechanical lock and key mechanism are being replaced by new advanced
techniques of locking system. These techniques are an integration of mechanical and electronic devices and
highly intelligent. One of the prominent features of these innovative lock systems is their simplicity and high
efficiency. Such an automatic lock system consists of electronic control assembly which controls the output
load through a password. This system demonstrates a password based door lock system wherein once the
correct code or password is entered, the door is opened and the concerned person is allowed access to the
secured area. Again if another person arrives it will ask to enter the password. If the password is wrong then
door would remain closed, denying the access to the person. This output load can be a motor or a lamp or any
other mechanical/electrical load. All of this is done on STM32F04 where the seven segment display is
attached along with the buttons on the microcontroller .
5|Page
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
Literature Review
The main component in the circuit is STM controller. In this project 43 keypad is used to enter the
password. The password which is entered is compared with the predefined password. If the entered
password is correct then the system opens the door by rotating stepper motor and displays the status of
door on LCD. After 10 sec the door will close again and LCD will display door is closed. If the password
is wrong then door is remain closed and displays password is wrong on LCD.
Project Design
Architecture Overview
LCD
KeyPad
STM
Microcontroller Motor
Driver
Stepper
Moter
Schematic Diagram
6|Page
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
Design Description
Initially declare the PORT E to LCD data pins and control pins to PB0,PB1,PE7 and declare
PORT D to keypad.
Declare of Stepper Moter on port A pin (4-7)
Initially display enter password on LCD.
Now read the four digit password from the user.
Compare the entered password with stored password.
7|Page
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
If password is correct, then make pin PA4,PA5,PA6 ,PA7 respectively high to a open the door.
After that, display Door Openedon LCD.
After some time the make pin PA7,PA6,PA5 ,PA4 respectively to close the door and after this
display Door Closed on LCD.
If the password is wrong then display Wrong Passwardon LCD.
After some delay again ask to enter password.
.
Implementation
#include <stdio.h>
#include <stm32f4xx.h>
void lcd_ini(void);
void lcd_data(char j);
void lcd_cmd(char i);
char keypad(void);
void stepper(int xw);
void SetDirection(void);
char code[6]="12345";
unsigned long LCDDATA=0;
unsigned long op=0;
int count=0,time=0,Steps=0;
8|Page
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
int Direction=1;
/*----------------------------------------------------------------------------
MAIN function
*----------------------------------------------------------------------------*/
int main (void) {
GPIOA->MODER = 0xA800000;
GPIOA->OTYPER = 0xA8000000;
GPIOA->OSPEEDR = 0xA800AAAA;
GPIOA->PUPDR = 0xA8000000;
GPIOB->MODER = 0x04400005;
GPIOB->OTYPER = 0x00000003;
GPIOB->OSPEEDR = 0xAAAAAAAA;
GPIOB->PUPDR = 0x00000000;
GPIOC->MODER = 0x00000000;
GPIOC->OTYPER = 0x00000000;
GPIOC->OSPEEDR = 0xAAAAAAAA;
GPIOC->PUPDR = 0x00000000;
GPIOD->MODER = 0x00005110;
GPIOD->OTYPER = 0x00000000;
GPIOD->OSPEEDR = 0xAAAAAAAA;
GPIOD->PUPDR = 0x00000000;
GPIOE->MODER = 0x55555555;
GPIOE->OTYPER = 0x0000FF00;
GPIOE->OSPEEDR = 0xAAAAAAAA;
GPIOE->PUPDR = 0x00000000;
while(1)
9|Page
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
{
lcd_ini();
lcd_cmd(0x80); // line 1
lcd_data(' ');
lcd_data('E');
lcd_data('n');
lcd_data('t');
lcd_data('e');
lcd_data('r');
lcd_data(' ');
lcd_data('P');
lcd_data('a');
lcd_data('s');
lcd_data('s');
lcd_data('w');
lcd_data('o');
lcd_data('r');
lcd_data('d');
lcd_data(' ');
lcd_cmd(0xC1);
while(count<5)
{
char key=keypad();
if(key!=20)
{
lcd_data('*');
if(code[count]==key)
{
time++;
}
}
else
{
continue;
}
count++;
}
if(1)
{
lcd_ini();
lcd_data(' ');
10 | P a g e
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
lcd_data(' ');
lcd_data('D');
lcd_data('o');
lcd_data('o');
lcd_data('r');
lcd_data(' ');
lcd_data('i');
lcd_data('s');
lcd_data(' ');
lcd_data('O');
lcd_data('p');
lcd_data('e');
lcd_data('n');
lcd_data(' ');
lcd_data(' ');
Delay(5000);
lcd_ini();
lcd_data(' ');
lcd_data(' ');
lcd_data('D');
lcd_data('o');
lcd_data('o');
lcd_data('r');
lcd_data(' ');
lcd_data('i');
lcd_data('s');
lcd_data(' ');
lcd_data('C');
lcd_data('l');
lcd_data('o');
lcd_data('s');
lcd_data('e');
lcd_data(' ');
Delay(500);
}
11 | P a g e
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
else{
lcd_ini();
lcd_data('I');
lcd_data('n');
lcd_data('v');
lcd_data('a');
lcd_data('l');
lcd_data('i');
lcd_data('d');
lcd_data(' ');
lcd_data('P');
lcd_data('a');
lcd_data('s');
lcd_data('s');
lcd_data('w');
lcd_data('o');
lcd_data('r');
lcd_data('d');
Delay(500);
}
}
}
void lcd_ini(void)
{
Delay(10);
lcd_cmd(0x38);
lcd_cmd(0x0C);
lcd_cmd(0x01);
Delay(10);
}
void lcd_cmd(char i)
{
unsigned long r=0;
char loop=0;
r |= i;
for(loop=0;loop<=7;loop++)
{
r = r << 1;
}
GPIOB->BSRRH = ((1 << 1) );
LCDDATA = r;
GPIOE->ODR &= 0x000000FF;
12 | P a g e
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
GPIOE->ODR |= LCDDATA;
GPIOE->BSRRL = ((1 << 7) );
Delay(100);
GPIOE->BSRRH = ((1 << 7) );
}
void lcd_data(char j)
{
unsigned long r=0;
char loop=0;
r |= j;
for(loop=0;loop<=7;loop++)
{
r = r << 1;
}
GPIOB->BSRRL = ((1 << 1) );
LCDDATA = r;
GPIOE->ODR &= 0x000000FF;
GPIOE->ODR |= LCDDATA;
GPIOE->BSRRL = ((1 << 7) );
Delay(100);
GPIOE->BSRRH = ((1 << 7) );
}
/////////////////////////////////////
char keypad(void){
char key_pressed= 20;
14 | P a g e
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
key_pressed = 9 ;
Delay(100);
GPIOB->IDR = 0x00000000;
}// End if( bt =(1UL << 1))
/*Row 4 = 1 & scanning of Col 1 , Col 2 , Col 3*/
GPIOD->BSRRH = ((1 << 7) );
GPIOD->BSRRH = ((1 << 6) );
GPIOD->BSRRH = ((1 << 4) );
GPIOD->BSRRL = ((1 << 2) );
if((GPIOD->IDR & 0x00000002) == 0x00000002) {
key_pressed = 10 ;
Delay(100);
GPIOD->IDR = 0x00000000;
}// End if( bt =(1UL << 1))
else if((GPIOD->IDR & 0x00000008) == 0x00000008) {
key_pressed = 0 ;
Delay(100);
GPIOD->IDR = 0x00000000;
}// End if( bt =(1UL << 1))
else if((GPIOB->IDR & 0x00000008) == 0x00000008) {
key_pressed = 11 ;
Delay(100);
GPIOB->IDR = 0x00000000;
}// End if( bt =(1UL << 1))
return key_pressed;
}
Key Components
The key components used in this experiment are LCD, Stepper Moter and STM32
15 | P a g e
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
A LCD, is a form of electronic display device for displaying string values LCDs are widely used
in digital clocks, electronic meters, and other electronic devices for displaying information
Evaluation
Each module in the application was tested while being developed to confirm its adherence to the related
requirements. Once the circuit is designed and drawn on a piece of paper, the next step is to write and
compile the code. Here we select the Kiel Vision software to write the program in C language.
Prior to writing the code, general steps needs to be followed like creating a new project and selecting the
target device or the required microcontroller. Once the code is written, we saved it with .c extension and
then added it to the source file group under the target folder. The code is then compiled by pressing F7
key.
16 | P a g e
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
Results
After the successful working of the project, it can be concluded that this project is suitable for secured
door mechanisms also for the numerous applications mentioned earlier .There can be further up gradation
in the project which could lead to the development of a much better system for communication some of
the possible up gradation that can be made is the device can be made voice controlled or the device can be
synced with the owners mobile phone for the remote access . .
Applications
This simple circuit can be used at residential places to ensure better safety.
With a slight modification this Project can be used to control the switching of loads through
password.
17 | P a g e
.
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY LAHORE
Reference
2. Graham, R.M. Calibration Techniques for Stopwatches and Timers. Proc. 2003
National Conference of Standards Laboratories (NCSLI), 6 pages, August 2003.
3. Anderson, R.J., and G.L. Harris. Specifications and Tolerances for Field Standard
Stopwatches. Natl. Inst. Stand. Technol. Handbook 105-5, October 1997.
4. http://www.electronicshub.org/password-based-door-lock-system-using-8051-
microcontroller/
5. https://prezi.com/ca1avcduyk5i/password-based-door-lock-system/.
18 | P a g e