MIDDLE EAST COLLEGE
Knowledge Oasis Muscat, Muscat, Oman
January, 2017
A PROJECT-1 REPORT
ON
PIC Microcontroller based Electronic Lock
By
* Sami Mohammed Fadhil Al AAmri 14F12846
* Shabib Salim Hamed Al Mamri 14F13193
* Qais Said Khami Al Sadairi 15F14552
* Yousuf Mohammed Harib Saif Al Suqri 15F14838
Guided by
Mr. Madhav Prabhu
A PROJECT REPORT
ON
PIC MICROCONTROLLER BASED ELECTRONIC LOCK
By
* Sami Mohammed Fadhil Al AAmri 14F12846
* Shabib Salim Hamed Al Mamri 14F13193
* Qais Said Khami Al Sadairi 15F14552
* Yousuf Mohammed Harib Saif Al Suqri 15F14838
January, 2017
DECLARATION
We, “By Sami Mohammed Fadhil Al AAmri, Shabib Salim Hamed Al Mamri, Qais Said Khami Al Sadairi, Yousuf Mohammed Harib Saif Al Suqri ”, hereby declare that the work presented herein is genuine and has not been copied in part or in whole from any other source except where duly acknowledged. As such, all use of previously published work (from books, journals, magazines, internet, etc.) has been acknowledged within the main report to an item in the references or bibliography lists.
Copyright Acknowledgement
We acknowledge that the copyright of this project and report belongs to MEC.
Student Name Student ID Signature
* Sami Mohammed Fadhil Al AAmri 14F12846
* Shabib Salim Hamed Al Mamri 14F13193
* Qais Said Khami Al Sadairi 15F14552
* Yousuf Mohammed Harib Saif Al Suqri 15F14838
APPROVAL FORM
The project report entitled PIC Microcontroller based Electronic Lock submitted by Mohammed Fadhil Al AAmri (14F12846), Shabib Salim Hamed Al Mamri (14F13193), Qais Said Khami Al Sadairi (15F14552), Yousuf Mohammed Harib Saif Al Suqri (15F14838) is approved in the project of Microcontroller of Engineering in Electronics and Telecommunication.
_________________________
Supervisor
Full name:
Department:
Date:
_______________________
Examiner
Full name:
Department:
Date:
ACKNOWLEDGEMENT
We have strived hard towards the successful completion of the project work. We would like to thank the Middle East College Electronic Department Faculties for their constant support in guiding us towards every stage of the project work.
We take this occasion to express our appreciation towards our module guider Mr.Madhav Prabu, who has always guided us and encouraged us throughout the course since the commencement of the project work till its completion. The valuable suggestions, novel ideas and guidance rendered by his brought us to achieve the completion of the project work in a good way.
We would also like to express our gratitude towards the helpful hand of our seniors of Middle East College from Electronics Department through which we are able to achieve this endeavor.
We also encourage the team work without which it would not have been attained. We are also indebted to our parents who always have their hope towards us and encourage us throughout the project work. At last, we thank everyone behind the moral support of us in doing the project work.
ABSTRACT
Electronic Security systems using microcontroller are used in various security applications like access control, surveillance, and monitoring systems etc., Security is one of the major concerns in our daily life. Access control system for doors is an essential security system for homes, enterprises, lockers etc. It enables only the authorized persons to enter into the room thus providing security. In the PIC microcontroller based electronic lock system, the user can have the access to the door only if he enters the correct code provided to him. Otherwise, the access is denied. The administrator can change this secured code if needed. It provides better security over the traditional method of lock and key as keys can be duplicated.
Nowadays microcontrollers are used anywhere from simple computer accessories like printers, mouse etc., to complicated control mechanisms in machinery, aircraft, robots, satellite applications etc., A microcontroller consists of all the features required for interfacing and computing like in built ROM, peripherals, timers, ADC etc., with less or no external components. They can be easily programmed by the user with high level language like C. The advantages of microcontroller are low power, small size, low cost, high speed, improved performance and others. The PIC microcontrollers employ RISC architecture which stands for Reduced Instruction Set Computer. The major advantage of RISC technology is its speed and user-friendliness. The PIC microcontroller based electronic lock system consisting of both hardware and software modules is designed and implemented
TABLE OF CONTENTS
Contents
DECLARATION iii
APPROVAL FORM iv
ACKNOWLEDGEMENT v
ABSTRACT vi
TABLE OF CONTENTS vii
LIST OF FIGURES ix
LIST OF TABLES x
LIST OF ABBREVIATIONS xi
LIST OF SYMBOLS xii
1. INTRODUCTION 1
1.1 Background of the Project 1
1.2 Project Objectives 2
1.3 Project Limitations 2
1.4 Overview of the Report 2
2. LITERATURE REVIEW/THEORY 3
3. BUDGETING AND PROJECT MANAGEMENT 4
3.1 Budget 4
3.2 Schedule 4
3.3 Risk Management 5
4. DESIGN AND ANALYSIS 7
4.1 System Initial Design 7
4.2 Technical Requirements 8
4.3 Schematic Diagaram 9
4.3.1 Schematic Diagram of Simulation Circuit 9
4.3.2 Schematic Diagram of Hardware Circuit 10
4.4 Hardware Components and their description 11
4.4.1 Swithc Pad and its interface 11
4.4.2 LCD and its interface 12
4.4.3 Clock Circuitry 14
4.4.4 5V Relay 15
4.4.5 Driving Circuit for relay and microcontroller protection 15
4.5 PIC Microcontroller 16
4.6 Flow Chart of the Program and C Coding 18
4.7 Software Simulation Results 23
4.8 Hardware Implementation 24
4.9 Analysis 25
5. CONCLUSION 25
REFERENCES 25
APPENDIX A 25
LIST OF FIGURES
Figure 4.1 Simulation Circuit of PIC Microcontroller Based Electronic Lock 9
Figure 4.2 Hardware Circuit of PIC Microcontroller Based Electronic Lock 10
Figure 4.3 4 x 3 Switch Pad ------------------------------------------------------------- 11
Figure 4.4 16 x LCD ------------------------------------------------------------- 12
Figure 4.5 Clock Circuit ------------------------------------------------------------- 14
Figure 4.6 5 V Relay ------------------------------------------------------------- 15
Figure 4.7 PIC Microcontroller 16F877A --------------------------------------- 16
Figure 4.8 Flow Chart of the Program --------------------------------------- 18
Figure 4.9 Proteus Simulation Results --------------------------------------- 19
Figure 4.10 Hardware Implementation Results ---------------------------------- 20
LIST OF TABLES
Table 3.1 Budget Estimate of the Project -------------------------------- 4
Table 3.2 Project Schedule -------------------------------- 5
Table 3.3 Risk Management Assessment -------------------------------- 5
Table 4.1 Pin Configuration of 16 x 2 LCD -------------------------------- 12
Table 4.2 Important Preset Commands of LCD -------------------------------- 13
LIST OF ABBREVIATIONS
IC Integrated Circuit
LCD Liquid Crystal Display
PIC Peripheral Interface Controller
ROM Read Only Memory
EPROM Erasable Read Only Programmable Memory
ADC Analog to Digital Converter
GSM Global System for Mobile Communications
LED Light Emitting Diode
EN Enable
SPST Single Pole Single Throw
SPDT Single Pole Double Throw
DPDT Double Pole Double Throw
RS Register Select
R/W Read/Write
SPI Synchronous Serial Port
I2C Inter-Integrated Circuit
CCP Compare/Capture/Pulse Width Modulator
USART Universal Asynchronous Receiver Transmitter
LIST OF SYMBOLS
D0-D7 Data Lines of LCD
RD0-RD7 Port D lines of PIC 16F877A
RB0-RB7 Port B lines of PIC 16F877A
Vss Ground
Vdd Power Supply
D1, D2 PN junction diode
Q1 Transistor
mA Milli ampere
MHz Mega Hertz
Chapter 1
1. INTRODUCTION
In this chapter, the background and significance of the project is specified. The project objectives are stated. The limitations are identified and the necessary enhancements are recommended. An overview of the report is given.
Background of the Project:
An electronic lock based on PIC microcontroller is proposed and implemented in this project. A 4-digit security password is stored inside the microcontroller. If the user accesses the system using the same password, access is granted and the door is opened. Otherwise, access is denied and the door remains closed. The major components of the system include the switch pad to enter the security code, PIC microcontroller for interfacing and computing, LCD display to display the status and relay to actuate the door. The administrator can change the password if needed. The system provides better security feature and can be implemented in both homes and organizations (Norman, 2014; Joseph et al, 2013). The circuit is simple and easy to construct with commonly available components. The power consumption is also less. By providing necessary enhancements to the circuit and software, it can be extended for other applications like security and monitoring systems through remote access.
Project Objectives:
The main objective of the project is to provide security in homes, offices, banks etc., by providing access control to enter into the room
There are two modules in the project.
Hardware implementation - The circuit comprises of the switch pad, PIC microcontroller 16F877A which stores the security code in its EPROM, LCD display and relay.
Software implementation – The software to be programmed into the PIC microcontroller consists of the modules of keypad interfacing, LCD interfacing, operation of relay and computation for matching of the password. Simulation is also done using Proteus Professional edition.
1.3 Project limitations:
The major limitations of the project in its current provision include
The circuit has the limitation of operating remotely from far distances
In the situation that the password is forgotten, the user will not have access to the system and he will not be able to enter into the room.
Provisions to overcome the limitations can be incorporated in the circuit by additional components and software.
(Anon. (2011) Basics of Microcontrollers - Electronic Circuits and Diagram-Electronics Projects and Design. http://www.circuitstoday.com/basics-of-microcontrollers)
1.4 Overview of the Report:
In this report, in the first part, a brief description of the project is given with the limitations. Then a literature of the past and current related works is analyzed. In the next section, the block diagram of the PIC microcontroller based electronic system is given with explanation. The components of the system are explained in brief. An overview of the Proteus Professional software is given. The algorithm of the software part is explained with necessary diagram. The hardware circuit and the simulation results are given. A detailed conclusion with analysis and future work is specified.
Chapter 2
2. LITERATURE REVIEW
This chapter provides a brief literature of the past and current innovations related to Microcontroller based Electronic lock system. Microcontroller Based Home Security
System with GSM Technology which has its major module as Electronic lock system is developed using Atmega 16 microcontroller (Raqibull Hasan et al, 2015). The password is entered through the android mobile phone which is transmitted to the microcontroller via blue tooth. If the password entered by the user is authorized, a pulse signal is sent by the microcontroller which activates the servo motor. The servo motor is connected to the magnetic switch placed at the door. On verifying the password, the servo motor rotates and the magnetic contacts separate. The door is opened and the status is displayed in the LCD. If the password entered by the user is not authorized, the microcontroller sends alarm signal to activate the buzzer and the status is displayed in the LCD. Also, the access denied status is sent to the mobile phone. A similar project of Password door security using PIC microcontroller 16F887A has been developed in which the output of the PIC microcontroller activates the magnetic lock used to open or close the door (Mehmood & Khawaja, 2009; Anon, Password Door Security – RobotShop. www.robotshop.com/media/files/pdf/details-description-pr9.pdf;
Anon, PIC Microcontroller Based Electronic Lock
http://microcontrollerprojects00.blogspot.in/2012/03/pic-microcontroller-based-electronic.html?m=1). An electronic lock which can be unlocked by swiping the user’s debit card is implemented (Rawat et al, 2016) to provide secured door locking system in ATM cabins using RFID. Chattoraj, 2016 developed the door locking system using Arduino microcontroller which matches the finger print of the user and access is granted if the finger print matches. If it is not matches, the access is denied and the authorized user got an SMS alert through GSM.
Chapter 3
3. BUDGETING AND PROJECT MANAGEMENT
In this chapter, the budget incurred for the implementation of the project is evaluated. The schedule of the project work is given with an analysis of the risk management.
3.1 Budget
The budget incurred in meeting the expenses of the purchase of the components is given in Table 3.1.
Table 3.1 – Budget Estimate of the project
S.No. Name of the Component Quantity Approximate Cost (OMR)
1. PIC Microcontroller IC16F877A 1 1.13
2. 16 x 2 LCD Display 1 1.13
3. 4 x 3 Matrix keypad 1 1.02
4. 5 V Relay 1 0.29
5. Miscellaneous items including diodes, transistor, resistors - 0.57
6. Bread board, Soldering iron, lead and PCB making charges - 1.42
Total 5.56
The approximate budget of the project is 6.0 OMR.
3.2 Schedule:
The major modules of the project are Hardware implementation and software simulation.
The project schedule is given in Table 3.2.
Table 3.2 Project Schedule
S.No. Nature of Work Duration
1. Identification of the Project and confirmation of the title 1 week
2. Literature Survey 1 week
3. Circuit diagram prototyping 4 days
4. Code development using microC PRO compiler for PIC 1 week
4. Simulation of the circuit and output verification using Proteus Professional edition 1 week
5. Hardware implementation by PCB making of the circuit 10 days
3.3 Risk Management
The assessment of Risk Management is specified in Table 3.3
Table 3.3 Risk Management Assessment
S.No. Nature of Risk Consequences of Risk Handling of Risks Level of risk
1. Soldering of electronic components Due to mishandling, burns may occur Wearing gloves, shoes and keeping first aid Medium
2. Working with PIC microcontroller Overloading may occur and results in failure of the system Rating of the components should be carefully followed and standby components should be kept Medium
3. Program codes may be deleted Loss of important data and extra time and effort incurred in developing the code Backup for the code and date should be maintained Low
4. Electrical shock Burns may occur Ground and insulation have to be checked properly Low
5. Poor Time Management Mental stress occurs Group work and consulting with supervisor should be followed Low
Chapter 4
4. DESIGN AND ANALYSIS
In this chapter, the design of the project PIC Microcontroller based Electronic Lock is given. The operation of the circuit is explained and description of the components used in the project is given. Also, the schematic diagrams of both the simulation and the hardware circuits are given.
4.1. System Initial Design
The 8 bit PIC microcontroller 16F877A is used in the project. The microcontroller has 8Kbytes of ROM as the program memory. The password is stored in the EPROM of the microcontroller. The user enters the password in the keypad available in the system. If it matches the password stored in the EPROM, the relay gets ON and the door is opened. If the password entered does not match, access is denied.
LCD is interfaced to Port B of the microcontroller and the keypad is interfaced to Port D of the controller. The ‘*’ key is used to initialize the system and once this key is pressed, the user is enabled to enter the password. The key ‘#’ is pressed to turn off the system and the relay. The user can use the remaining keys to enter the security code. The three columns of the keypad are connected to the lower significant bits of Port D (RD0-RD2) and the four rows of the keypad are connected to the most significant bits of Port D (RD4-RD7). Similarly, the LCD data lines (D4-D7) are connected to the most significant bits of Port B (RB4 to RB7). In the beginning, the string ‘Initializing’ is displayed on the LCD screen. Then the string ‘Press *’ is displayed. After pressing the * key, the string ‘Enter Code’ will be displayed. Next, the four digit security code has to be entered in the keypad. If it matches the stored password in the ROM, ‘Access Granted’ will be displayed. Also, the relay will be activated and the door is opened. If the entered password does not match the stored one, ‘Access Denied’ will be displayed and the door remains closed.
4.2. Technical Requirements
The requirements for the project include the following components
PIC microcontroller 16F877A
4 x 3 Matrix keypad
16 x 2 LCD
5V relay with driving transistor
Diode to prevent reverse flow of current
Crystal oscillator and capacitors for clock circuit of microcontroller
Pull down resistors for keypad switches
4.3 Schematic Diagram
Schematic Diagram of Simulation Circuit
(Electronic Code locking system using PIC 16F877 Mircocontroller – Gadgetronicx. http://www.gadgetronicx.com/electronic-code-locking-system-pic-microcontroller)
Figure 4.1 – Simulation Circuit of PIC Microcontroller Based Electronic Lock
4.3.2 Schematic Diagram of Hardware Circuit
Figure 4.2 –Hardware Circuit of PIC Microcontroller Based Electronic Lock
4.4 Hardware Components and their description
4.4.1 Switch pad and its interface
Figure 4.3 - 4 x 3 Switch Pad
The resistors R1-R7 are used as the pull down resistors which are connected to the rows (A, B, C and D) and columns (1, 2, 3) of the 4x3 matrix keypad. The rows and columns are connected to the Port D of the microcontroller PIC16F887A. In interfacing the keypad to the microcontroller, initially there is no contact between the rows and columns since all the switches are in released position. First logic 0’s are written into all the rows and logic 1’s are written into all the columns. The press of akey is sensed by using a software routine. The columns of the keypad are scanned continously. If a logic ‘0’ is detected in any of the columns, then a key would have pressed in that column. For example, the columns 1, 2 and 3 are made high. If the key in the second row, second column, that is, B2 is pressed, it shorts the column 2 with the row B and hence the column 2 will go low. Then, a logic ‘1’ is written into the rows sequentially until the column 2 goes high. Now since the key B2 is pressed, when the row B is given logic ‘1’, the column 2 goes high. Thus it is able to detect now that the key B2 is pressed.
4.4.2 LCD and its interface
Figure 4.4 - 16x2 LCD
LCD is interfaced to Port B of the microcontroller. The pin configuration of 16x2 LCD is given in Table 4.1.
Table 4.1 – Pin configuration of 16x2 LCD
Pin No. Pin Name Usage
1 Vss Ground
2 Vdd Power
3 Vee Contrast Adjustment
4 RS (Register Select) 1 = Data Input (Data Register)
0 = Command Input (Instruction Register)
5 R/W 1 = Read from LCD
0 = Write to LCD
6 EN (Enable) Transition from 1 to 0 = Data is written to LCD
7 - 14 DB0 – DB7 Data bus lines
15 LED+ Backlight
16 LED-
To display a character or data in the LCD, EN=1; RS=1; and R/W=0
To send command to the LCD, EN=1, RS=0; and R/W=1
Table 4.2 - Important Preset Commands of LCD
Command Operation
0FH LCD is switched on. The cursor is blinking
01H The screen is cleared
02H Return to home position
04H The cursor position is decremented
06H The cursor position is incremented
0EH The display and cursor are ‘on’
80H The cursor is forced to the beginning of the first line
(8 stands for the first line and 0 stands for the first position)
C0H The cursoris forced to the beginning of the second line
(C stands for the second line and 0 stands for the first positon)
38H 5x7 matrix is used for displaying the character and 2 lines are used (8 bit mode)
3CH Second line is activated
83H, C1H The cursor is positioned at first line position 3 and second line position 1 respectively
Programming the LCD consists of the following steps.
Initialize the LCD
Send command to the LCD
Write the data to be displayed
(Anon. Interfacing LCD and Keypad with PIC16F877A Microcontroller
http://www.gadgetronicx.com/interfacing-lcd-and-keypad-pic16f877a)
4.4.3 Clock Circuitry
Figure 4.5 Clock Circuit
The clock circuitry provides clock signal to the microcontroller. A crystal oscillator is used to generate the clock signal. It is connected to the Clock In and Clock Out pins of the PIC microcontroller. The capacitors are used to sustain the oscillations in the circuit.
4.4.4 5V Relay
Figure 4.6 – 5V Relay
The 5V relay is used in the circuit to control the opening of the door. The relay is activated by the microcontroller if the user is authenticated by the password match. Relay is an electromagnetic device which isolates two circuits electrically and makes a connection between them magnetically. The relay switch consists of two parts – input and output. If the small voltage of approximately 5V is sent by the microcontroller, it generates a magnetic field in the relay and it gets energized. The output section of the relay consists of contactors which connect or disconnect mechanically. These contactors function to open or close the door. The different available relay configurations are Single Pole Single Throw (SPST), Single Pole Double Throw (SPDT), and Double Pole Double Throw (DPDT) etc (Anon. (n.d.) Relay Switch http://www.engineersgarage.com/
electronic-components/relays).
4.4.5 Driving Circuit for relay and microcontroller protection
The relay driver circuit provides the necessary current typically ranging from 25mA to 70mA to energize the relay coil as the PIC microcontroller produces only 5Volts and is not able to provide such large current. The transistor BC547 Q1 in the circuit is used to provide the driving current to energize the relay coil. Also, the relay is turned OFF by writing a logic ‘0’ on the port pin of the microcontroller. The diode connected across the relay coil D2 is used as protection circuit for the transistor and the microcontroller. When the transistor is turned OFF, back emf is generated in the relay’s inductive coil which may damage the transistor and the microcontroller. Hence the diode D2 is connected across the relay coil to prevent them. The Master Clear Pin External Reset ((MCLR) ̅) pin of PIC16F877A should be made high during normal operations by connecting it through a resistor to the power supply.
4.5 PIC Microcontroller
Figure 4.7 – PIC Microcontroller 16F877A
Peripheral Interface Controller (PIC) Microcontroller was developed by Microchip (Bates, 2011; PIC Microcontroller Architecture and Advantages | CPU, RAM and ROM http://www.electronicshub.org/pic-microcontroller-architecture). The features of PIC microcontroller include
Harvard architecture i.e separate address spaces for the program and data
Program memory of 8Kx14 bytes
256 bytes data EEPROM
368 bytes RAM registers
14 bit instruction length
8 bit data bus
8 – input channel 10 bit ADC
Synchronous Serial Port (SPI) Interface
Inter – Integrated Circuit (I2C) bus and Universal Asynchronous Receiver Transmitter (USART)
Two 8-bit timers and one 16-bit timer
Two Capture/Compare/Pulse Width Modulator Peripherals (CCP PWM)
Operating voltage of 2.0V – 5.5V and 40 – pin IC
20MHz crystal oscillator
Power up timer, Power-on reset, brown out reset, in-circuit debugger and low voltage programming
Watchdog Timer
(Verle, 2009; Wilmshurst, 2007)
4.6 Flow chart of the Program and C coding
Figure 4.8– Flow Chart of the Program
unsigned short key;
char usr_code[10] ,stored_code[4];
char dspmsg1[20] = "Initializing......",dspmsg2[12] = "Enter Code";
char dspmsg3[15] = "Permitted ",dspmsg4[15] = "Not Permitted";
char dspmsg5[15] = "Enter new Code";
int i=0,j,cnt;
// Keypad switches connected at Port D
char keypadPort at PORTD;
// LCD module connections at Port B
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
//Sense the key pressed and display it in LCD
void code_enter()
{
key = 0;
do
key = Keypad_Key_Click();
while (!key);
switch (key)
{
case 1: key = '1'; break; // 1
case 2: key = '2'; break; // 2
case 3: key = '3'; break; // 3
case 5: key = '4'; break; // 4
case 6: key = '5'; break; // 5
case 7: key = '6'; break; // 6
case 9: key = '7'; break; // 7
case 10: key = '8'; break; // 8
case 11: key = '9'; break; // 9
case 13: key = 42; break; // *
case 14: key = 48; break; // 0
case 15: key = 35; break; // #
}
usr_code[i] = key;
Lcd_Chr(2, i+1, usr_code[i]);
i++;
}
void delay_20ms()
{
Delay_ms(20);
}
//Read the stored security code from EEPROM
void code_read()
{
delay_20ms();
stored_code[0] = EEPROM_Read(0x00);
delay_20ms();
stored_code[1] = EEPROM_Read(0x01);
delay_20ms();
stored_code[2] = EEPROM_Read(0x02);
delay_20ms();
stored_code[3] = EEPROM_Read(0x03);
delay_20ms();
}
//Write the new security code into EEPROM
void code_write()
{
delay_20ms();
EEPROM_Write(0x00,usr_code[0]);
delay_20ms();
EEPROM_Write(0x01,usr_code[1]);
delay_20ms();
EEPROM_Write(0x02,usr_code[2]);
delay_20ms();
EEPROM_Write(0x03,usr_code[3]);
}
//To change the security code
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();
code_read();
}
//Main Program
void main()
{
ADCON1 |= 0x07;
TRISA = 0x00;
PORTA.B0 =1;
Keypad_Init();
Lcd_Init();
code_read();
// Store the default code as 1234
if(stored_code[0] == 0xFF && stored_code[1] == 0xFF && stored_code[2] == 0xFF && stored_code[3] == 0xFF )
{
EEPROM_Write(0x00,'1');
delay_20ms();
EEPROM_Write(0x01,'2');
delay_20ms();
EEPROM_Write(0x02,'3');
delay_20ms();
EEPROM_Write(0x03,'4');
}
code_read();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 1,dspmsg1 );
Delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
cnt=0;
do
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2, 3, "Press *");
i = 0;
code_enter();
if(usr_code[0] == 42)
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1,dspmsg2);
//delay_ms(500);
i = 0;
code_enter();
code_enter();
code_enter();
code_enter();
code_enter();
if(usr_code[0] == '1' && usr_code[1] == '2' && usr_code[2] == '3' && usr_code[3] == '4' && usr_code[4] == '5')
{
code_enter();
if(usr_code[5] == 35)
{
change_code();
}
}
if(cnt<3 && usr_code[0] == stored_code[0] && usr_code[1] == stored_code[1] && usr_code[2] == stored_code[2] && usr_code[3] == stored_code[3] && usr_code[4] == 35) //compare the code entered by the user and the stored code in EEPROM and display messages
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, dspmsg3);
PORTA.B0 =0;
Delay_ms(2000);
PORTA.B2=0;
Delay_ms(3000);
PORTA.B0 =1;
}
else
{
cnt++;
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1,dspmsg4 );
}
if(cnt>=3)
{
do
{
PORTA.B2=1;
}while(1);
}
}
}while(1);
}
4.7 Software Simulation Results
Figure 4.9 – Proteus Simulation Results
4.8 Hardware Implementation
Figure 4.10 – Hardware Implementation Results
4.9 Analysis
With the use of PIC microcontroller for electronic lock system, the power consumption is less and the programming using the MICRO C PRO compiler is easier. Also, the simulation of the circuit using Proteus professional edition greatly simplifies the prototyping and the debugging becomes easier with less development time. The budget incurred is also less with high applications for the system.
5 Conclusion
The PIC microcontroller base electronic lock is designed and implemented. The system can be used as a successful access control system for doors in homes, enterprises, lockers etc. It allows only the authorized persons to enter into the room and prevents unauthorized persons from entering into the room thus providing security. The PIC microcontroller which uses RISC architecture and having all computing and interfacing components like ROM, peripherals, timers, ADC etc., is used in the project. The system is both hardware implemented and simulated using Proteus software. The performance of the system is verified by simulating the circuit and then implemented in hardware.
References
Norman, T.L. (2014) Integrated security systems design a complete reference for building enterprise-Wide digital security systems. Waltham, MA: Butterworth-Heinemann
Verle, M. (2009) Pic microcontrollers: Programming in C: Mikroelectronika
Bates, M. (2011) PIC microcontrollers: an introduction to microelectronics. Oxford: Newnes
Wilmshurst, T. (2007) Designing embedded systems with PIC microcontrollers: principles and applications. Oxford: Newnes
N., N.P., I., N.I., and Joseph, E.C. (2013) “Design and Implementation of Microcontroller Based Security Door System (Using Mobile Phone & Computer Set)”. Journal of Automation and Control Engineering1 (1), 65–69
Hasan, R., Khan, M.M., Ashek, A., and Rumpa, I.J. (2015) “Microcontroller Based Home Security System with GSM Technology”. Open Journal of Safety Science and Technology05 (02), 55–62
Mehmood, M.O. and Khawaja, A. (2009) “Firmware and hardware design of a novel door locking system”. IEEE Southeastcon 2009
Rawat, S.S., Saidulu, S., and Ranjan, R. (2016) “Secure ATM Door Locking System Using RFID”. Advances in Intelligent Systems and Computing Innovations in Computer Science and Engineering1–8
Chattoraj, S. (2016) “A Biometric Solution for Door Locking System using Real time Embedded System and Arduino as the Microcontroller”. IOSR Journal of Electrical and Electronics Engineering11 (04), 01–05
Anon. (n.d.) Password Door Security – RobotShop. www.robotshop.com/media/files/pdf/details-description-pr9.pdf
Anon. (n.d.) PIC Microcontroller Based Electronic Lock
http://microcontrollerprojects00.blogspot.in/2012/03/pic-microcontroller-based-electronic.html?m=1
Anon. (2011) Basics of Microcontrollers - Electronic Circuits and Diagram-Electronics Projects and Design. http://www.circuitstoday.com/basics-of-microcontrollers
Electronic Code locking system using PIC 16F877 Mircocontroller – Gadgetronicx. http://www.gadgetronicx.com/electronic-code-locking-system-pic-microcontroller
Anon. (n.d.) Relay Switch http://www.engineersgarage.com/electronic-components/relays
PIC Microcontroller Architecture and Advantages | CPU, RAM and ROM http://www.electronicshub.org/pic-microcontroller-architecture
Anon. (n.d.) Interfacing LCD and Keypad with PIC16F877A Microcontroller
http://www.gadgetronicx.com/interfacing-lcd-and-keypad-pic16f877a
Appendix A
PIC 16F877A data sheet from Microchip
Matrix Keypad Datasheet
16 x 2 LCD Data sheet
BC 547 Data sheet
5V Relay (OMI–SH-105D)Data sheet