Microcontroller Based Code Locking System with Alarm
Diarah Reuben Samuel, OsuekeChristian.O, Egbune Dickson (Electrical and Information Engineering, College of Science and Engineering/ Landmark University Omu-Aran, Nigeria) (Mechanical Engineering, College of Science and Engineering/ Landmark University Omu-Aran, Nigeria (Electrical and Information Engineering, College of Science and Engineering/ Landmark University Omu-Aran, Nigeria)
Abstract : The need for strict security measures has been necessary since the beginning of time. Access to certain places and items need strict restrictions to only the privileged few. This restricted zone can vary from strong holds and safes in financial institutions to doors leading to restricted areas. The various innovations in security access system include; code based lock, keycard lock, thumb print scan, retina scan. They come in handy in security systems. Code based locking system is best suited in most applications because of its simplicity and reliability. Since the code based locking system is always resident in the area to be protected, there are fewer chances of security breaches unlike the keycard lock system in which the access card can fall into unauthorized hands. Furthermore, in the issue of maintenance, the access code can easily be changed at will with lesser cost unlike in the case of keycard system where a new set of access cards are required. The design and operational principles of a microcontroller based code locking system is the subject of the thesis.The project is made of a keypad unit for entering the access code, a dynamic display unit that displays different messages at specific time, a door controller section made up of a H-bridge driver IC that controls the movement of the motor attached to the door and an alarm system that triggers when the conditions are bridged. The whole system is controlled by an 8051 based microcontroller (89s51). Keywords :Debugging,Hardware, Microcontroller, programming, software.
I. Introduction O OC O CCcOsOCC C c1O CO C1O cC C1 scC a CCCc OO c1 OOCOO C11CC C OO COOC C CC CC1 OaO COOOC- CO 1 cO ccC- cCc CCCO1 cO 1C C OO_ EcO Oc1 O O C1CcOCC C O1 CcC sc C OO c sCc ac1c CCsCC- 1O1O CCCO O C1CC1 OO O css11 sCc scC C CC O cCC 1c C cCO OC- OcO Ccc OC a CCsCc _E cCC c1 OC a aCCC C O C-1 aC OCOcCOc O1OC scC -cC css11 O O1 OcCC- 1sOOO cO c - CC1CsO1_ lC O1 c1-C O cO CCCc O O1 C a CO ccOc cCc 1COOc OC aC- caCOO O C O CCsO_ E ccOc sCCCCCO1 c 1CCCO sCCcCcO c aO O *EL_ sCsCCOCCC sC OC O CC-cC- CcC-Oc- Oc1 O1c OC CC-c O sC_ E1 Oc1 cc cO cOsC- O cO C CC -cC COcCs COC 1OsOc cc1 1Os c1 C 1 Cs1 COC1 Os_ O1 CCsO scC cC1C a CCCOc C 1OCC- CCc1 cCc 1c1 O1c C CcCscC C1OOOOCC1_ CO O1O O O1 sCc ac1c CCsC O 1COC c1 C OCC1O cCc OO OCc1CCcaC OO 1 COCc CC O1 c sCc OC CCC c cCC OC OO c scC CccCCsC O cCC CCCC1 1c CCO-_ * sCsCC OCCCac1c sCc ac1c CCsC 1 O1c C1OCO C -CO 1OsOc OCC1 C C1OOOOCC1_ OO C c sCc ac1c CCsCC- 1O1O Microcontroller Based Code Locking System With Alarm www.iosrjournals.org 10 | Page scC a CCCOc C 1c1 cCc 1OCC- CC1 _ LC OO O1 sCc ac1c CCsCC- 1O1O O C CacaCOO C CC-cC COcCs 1 OO CCO ascO 1 CCCO O CCCC OO O -O sCc scC cO css11 Os 1 cC ccOcCOc- CO O CCcC CCsC1 C CO1 Os scC a CCCc OO c c1O CO_E1 CcCCCsO 1 sC sCCOCCCc ac 1c cc cO 1sOOO_ E sCsCCOCCC 1 O cC CCcOC C O1 CCsO O sCCOCC1 C 1O CcO C O sCCCsOCC CC O aCcc_ lO 1 CC Oc aO c _ OCCO1 *s 1OC cCOC OcC1C O s c sCCOOc OC c _OCCO s OO O CC C c sO O sOCO 1 cc 1Oc-O OO O CC C c scCcsOC_ EC O sOCO 1 cOsc OC c OCCO OO c OCCOc- 1OcaCO c Cc c CcC scCcsOC J__ O CcC 1Oc-OC1 O sOCO cO cOsOCC_ * OI ccO1 C 1O 1OOs1 c O1 c c1 O CO Ccc_ E sCsCCOCCC 1scC1 O CO- O COCcc OC CCCO O C11c CO1_ *C ccO C 1OC 1-CO c1CCcO 1 O1c OC c1CC cO O C11c CO1 OC c COc sO1OcC c1C CcO 1 O1c OC CcscO O sCCcOCC C O 1O 1O_ LC CC1 C cCCO CCO C O sC sC COCCC OCC a sCCCsOc OC v*L cCc O Cc1O CCO OCC a O1c OC sCCCsO OC O tac- c O OcO OCC CCO O COC OcO OCC CCC O cCC_ *CC sCCCsOCC1 OC O sCsCCOCCC O cCC OO c 11OC sCCCsOc OC O_ ___ -CsO 1CsscOCC 1lLELvv*L *L* * vl. LmLE*1 c11O1 c - cO C 1sOOO_ E cC sCCCCCO 1 O sCsCCOCCC Os c1 sCc1 OcO c aO Cc COC O Os OC1 C sCCOCC1 O OCsOCC cCOO C O1 c1-C_ O1 CcO1 C O c1-C c c E CCO 1OCCCO OCO a L1O 1OOs1 s E cCC c tac- cO v-O *OOC- Cc1 Jv* v
c E CCO 1OCCCO OCO J-LC sCC11O1 C c OcC1C c sO c scCcsOC c OCCOc- -OCcOC cCc c CcC scCcsOC_ lO CCcOs1 _ O Os O sCsCCOCCC cCc 1C CO sC CCCCO1 cC1 O1 C_ LC CO sCCCCCO1 CC O COC O1c aO O cCC Cc1 __O 1C O s CCCsOCC C CCO 1OCCCO 1 aC O OCCOc- -OCcOC_ a * OI 1O 1OOs cOO 1 O1c c1 O COCcc_ s E cCC Oc1 c1-Cc OO c O OcO 1 C OC O 1 CCC O cCC 1 CCsCc cCc Os O1c_ c E CcO OCO c1 O 1CC cOOO OC CO O COC Os OOC1 O -cO CCC cCc sCC1 _ E v 1CO1 O CcOsOCc sCCcOCC1 C cCC O OCC 1O1O_ E v*1 c O C COa OO cC O c1-C C COcsOO OC O cCC 1 CC Microcontroller Based Code Locking System With Alarm www.iosrjournals.org 11 | Page sCc C CCC OC c OCC- sCc 1 COc cCc OC O OCC- CO Oc1 COc_ tccOc 1Oa1O1O E c1-CO 1 cc OC C O CcOC1 Cc CO __ OCcc OCO _ 1CCcO OCO I_ CCOCC OCO _ -CO 1OCCCO OCO _ CC sCCOCC OCO _ *Cc 1O1O __-CO 1OCCCO OCO E c cCO OOC1 C CCO 1OCCCO_ 1C1O c c1-Cc OC sCCOO - OCCOc- * cC1 C sOsOO OC c 1OOcaC CCO OCCOc- 1OCCCO C CsOCCs1 ssOO1 cCc CO cOs1_ * CCO 1 OCCCO scC aO aCCC cCOC COC c 11 C aCCsC1 cs C Os CC1 c CcOsOCc OCsOCC_
EcC1C 1OC1 cCOC - OCCOc- * cC1 OC CCO OCCOc- *_ LsO sCCOO1 * OC aOO O COOCOO 1 OcOC-_ LCCOC- 1CCO1 O C OcOC- -cOCO OC c 1cCC CCC_ L-OCcOC CCcO1 CCC aO 1OOC- COOCOO OC c Oc OCCOc-_
-O___ EcC1C1 _ LsO _ cCcsOC _ L-OCcOC E -OCcOc COOCOO 1 OO 1CCO OO CC CCC_ lO 1 1OOcaC C cCC CsOCCs ssOO 1_
2.2 DISPLAY UNIT: the display unit consists of 16*2 liquid crstal display that dispays the position of the intruder as well as the condition of the alarm system. The lower data bus of the LCD is connected to port 2 of the microcontroller while RS and EN pins are connected to port 3_0 and port 3_1 respectively.
2.3 Key pad unit Keypads are assembled in a matrix form as illustrated below:
Fig 2.3 4x3 matrix key pad Microcontroller Based Code Locking System With Alarm www.iosrjournals.org 12 | Page The above diagram shows 4x3 keypad 12 switches in a default state (all switches open) there is no connection between the rows and columns. When the switch is pressed a connection between the switchs columns is made.
KEYPAD DECODER Many keypads are built with an onboard decoder that scan the keypad, and if a key is pressed, returns a number identifying the key. The decoder has 7 inputs; the 4 x inputs are connected to the 4 keypad columns while the y inputs are connected to the 3 keypad rows. How the keyboard is scanned. The steps are Scan row 1 Scan row 2 Scan row 3 Scanning a row is achieved applying 0V to the port pin for that row and 5V to the other three rows, then scanning each individual column to see if one of them is low. If it is, then the key at the junction between the current row and column being scanned is the pressed key. Clear row 1, set other 3 Scan column 1 Scan column 2 Scan column 3 Clear row 2, set other 3 Scan column 1 Scan column 2 Scan column 3 Clear row 3, set other 3 Scan column 1 Scan column 2 Scan column 3
For example, lets say the key being pressed is key 6. When scanning the first row, P1.0 will be cleared while the other 3 rows (P1.1, P1.2, and P1.3) are set. Since no key in this row is closed, there is no path for current through any of the pull up resistors and all 3 columns (on P1.4 to P1.6) are high. Therefore the key pressed was not found while scanning row 1. - Scanning row 2 (with 6 still closed) in this case, column 3 is connected through the closed switch to row 2. Since row 2 is low, column 3 is low The keypad is initialized in the main program all rows are cleared. Therefore when a key is pressed, since all rows are LOW, then one of the columns (the one containing the key that has been pressed) will be connected to 0V.
2.4 Microcontroller unit: The AT89C51 is a low power, high performance cmos 8-bit microcontroller with 4Kbytes of flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmel`s high density nonvolatile memory technology and is compatible with the industry standard MCS-51 instruction set and pinout. The on-chip flash allows the program memory to be reprogrammed in system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer, which provides a highly flexible and cost effective solution to many embedded control application.The AT89C51 is designed with static logic for operation down to zero frequency and support two software selectable power saving modes. The idle 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 functions until the next hardware reset. . Microcontroller Based Code Locking System With Alarm www.iosrjournals.org 13 | Page
Fig. 3.22: Pin configuration of AT89S51 Features of AT89S51 Programmable serial channel Compatible with MCS-51TM product 4Kbytes of in-system Reprogrammable flash memory - Endurance: 1,000 write/Erase cycles Fully static operation:0Hz to 24MHz Three-level program memory lock 128 x 8-bit internal RAM 32 programmable I/O lines Two 16-bit timer/counters Six interrupt sources Low-power idle and power-down modes.
2.5 Alarm unit This consists of an LED, which connects from the P0.7 of the micro controller, which in turn connects to 1K resistor, which finally connects to the VCC. The LED indicates on the alarm is set to slow. P3.7 of the micro controller connects to the resistor (1K), through the base of the transistor (NPN C945) and the collector to the ground, while the emitter terminal is connected to the negative terminal of the alarm speaker, and the positive to the Vcc. The remaining terminal of the resistor to Vcc, as shown in the figure 3.4
1k vcc M I C R O - C O N T R O L L E R
A T 8 9 C 5 1 C945 GND VCC VCC Buzzer 4.7k 2k or NPN Transistor P2.7 P2.6 28 27
Fig. 3.4 Micro controller interface with alarm unit Microcontroller Based Code Locking System With Alarm www.iosrjournals.org 14 | Page 2.5.1 Door control segment: The door control segment consists of an H-Bridge driver IC that guarantees the clockwise and the anti clockwise movement of the electric motor attached to the door system. The H-Bridge driver IC L293D is designed to control 2 DC motors. There are 2 input and 2 output pins for each motor. The 2 pairs of input determine the behavior of electric motor attached to it. The chip has two enable pins that must be high (+5V) for operation.
The behavior of motor for various input conditions are as follows: A B Stop Low Low Clockwise Low High Anti clockwise High Low Stop High High Table 3.5: H-bridge motor control
II. Design Process: A micro-controller based project design process is characterized by the following; Definition of task Requirements Factor that influence choice In defining a task, every design comes from an idea or a problem that requires a solution. Questions may be generated on what exactly that is required to be achieved and the feasibility of the ideas as regards to the implementation. If these questions are analyzed critically with tangible solutions to the problem, a development of this idea into a reality is the next step. Requirements for design process have to be considered once an idea has been established. The need to determine whether or not the idea requires a PC or not, depending on the complexity of the circuitry, or whether the circuits to be designed needs to make a complex decision or deal with complex data. The compare these factors with topic with ICs (AND gates) which two inputs when high logic changes outputs. Preferably, a micro-controller will be the best option based on the circuits to be designed with less hardware connections and flexibility. Writing a program that performs a desired function accesses the ability of the micro-controller. However, it came to our thought that among all the components used here the one that consumes the highest power is the Light Emitting Diodes (LEDs), which need as much as 15-volt to glow and draw as maximum as 2-ampere of current. As a result if this, I decided to use 15-volts, 2-ampere rated transformer for this design. After the voltage is stepped down 15-volts using a transformer, a full wave rectifier circuit was designed using four Diodes (IN4001). This value of Diodes is used here because from the specification of voltage/Diode rectifying data book, this value is adequate for lower voltages, say 0-24 volt. The load current of the rectifier is given as follows; Idc = 21m/3.1
When 1m = maximum current = 2 amp Idc = load current which is in dc form after recification. Hence idc = 2*3 / 3.14 =4/3.14, idc = 1.27 amps Therefore 1.27amps is the maximum load current that can be drawn in the whole system. Also it is known that after rectification, the same voltage (15-volts) continues to flow into the filter. As a result the load voltages 15- volts Thus Vdc = Load voltage = 15volts. And Vdc = 21m*RL / 3.14 RL = Load resistance RL = 47.13/4 RL = 11.78* 3.14 = 1.78 From this, it is obvious that V = IR = 1.27 * 1.27
Microcontroller Based Code Locking System With Alarm www.iosrjournals.org 15 | Page III. System Block Diagram
Figure 4.1 Block Diagram of Microcontroller Based code based locking system
4.2 System Flowchart
Fig 4.2 system flow chat
Microcontroller Based Code Locking System With Alarm www.iosrjournals.org 16 | Page 4.3 CIRCUIT DIAGRAM
Fig 4.3 circuit diagram
IV. Software Design Software, are computer programs; instructions that cause the hardware, the machines to do work. Software as a whole can be divided into a number of categories based on the type of work done. The two primary software categories are operating systems (system software), which control the workings of the computer, and application software, which addresses the multitude of tasks for which people use computers.
Fig .5.1 Software Design
Microcontroller Based Code Locking System With Alarm www.iosrjournals.org 17 | Page 5.2 Program #include "at89x51.h" #define LCD_en P3_1 #define LCD_rs P3_0 #define LCD_DELAY 2000 /* Delay for 1 ms */ #define LCD_clear() LCD_command(0x1) /* Clear display LCD */ #define LCD_origin() LCD_command(0x2) /* Set to origin LCD */ #define LCD_row1() LCD_command(0x80) /* Begin at Line 1 */ #define LCD_row2() LCD_command(0xC0) /* Begin at Line 2 */
} } } } V. Conclusion This paper microcontroller based code locking system with alarmhas successfully presented a functional and an easy way to combat crime and theft using a low cost device, and can be remotely applied everywhere security is needed.
REFERENCES [1]. Belone Schilling, Electronic Circuits: Discrete and Integrated, McGraw-Hill, New York,1979. [2]. B.L Theraja and A.K Theraja, A Textbook on Electrical Technology, 2003, 23 rd Edition, Pp 1887 Pp 1888. [3]. Paul Horowitz and Windfield Hill, The Art of Electronics, 1989, 2 nd Edition, Pp 7- Pp 8, Pp 55 Pp 58, Pp 614 Pp 622. [4]. Atmel Corporation Data Sheet on AT89C51, 0285D-B-12/97 [5]. NTE Electronics Inc., ECG Data Book, January 2002, 10 th Edition. [6]. Giorgio Rizzoni, Principles of Electrical Engineering, 2003, 3 rd Edition