Microcontroller Based Digital Lock System
Microcontroller Based Digital Lock System
Microcontroller Based Digital Lock System
Engineering is not only a theoretical study but it is an implementation of all we study for creating something new and making things more easy and useful through practical study. It is an art, which can be gained with systematic study, observation and practice. In the college curriculum we usually get the theoretical knowledge of industries and a little bit of implementation knowledge that how it works? But how can we prove our practical knowledge to increase the productivity or efficiency of the industry? To overcome such problem I the student of Govt. vit(east),jaipur am supposed to deliver a project on Microcontroller Based Digital Lock
System.
-1-
INTRODUCTION
Security is a prime concern in our day-to-day life. Everyone wants to be as much secure as possible. The building security is being designed to reduce the amount of stolen equipment from the building. As we know that theft and robbery are increasing day by day because manual lock are quit safe and easily be broken by the thief. So a new approach is needed to overcome the problem. It makes use of password for user authentication along with a locking system on the doors to allow entry authentication along with a locking system on the doors to allow entry only to authorized person. The doors open from the inside without authentication for compliance with fire codes and for an acceptable level of usability. For ease of application the authentication is transmitted wirelessly throughout the building from door unit to authentication unit. Digital lock is one of a way to solve this kind of problem. The microcontroller based digital lock for doors is an access control system control system that allows only authorized persons to access a restricted area. The system is fully controlled by the 6bit microcontroller AT89C51 which has a 4KB of ROM for the program memory. The password is stored in the microcontroller so that we can change it at any time. The person who wants to enter has to enter the correct password. Digital lock which incorporates a digital programmable micro processing interface capable of user programming whereby a programmed combination opens the lock. According to one embodiment of the lock, there can be as many as approximately 720 possible different combinations which may be entered by the user. The operation of the lock is driven by an electrical signal derived from the combination and that electrical signal is sent to a motor assembly inside the lock body in response to which there is a disengagement of a set of locking bar assistance of a springing mechanism causes the locking device to open automatically. The doors open from the inside without authentication for compliance with fire codes and for n acceptable level of usability.
-2-
-3-
Block Diagram
-4-
Overview of Project
In our project (Microcontroller Based Digital Door Lock) we are going to lock the door digitally in which a digital programmable micro processing inter face capable of user programming where by a programmed combination opens the lock. Here we use assembly language for coding in microcontroller IC 89C51. by using this circuit and coding we can also control the electrical equipments to turn ON and OFF for a fixed time. This project has two control sections which are microcontroller section and relay section.
Microcontroller Section:This section includes the coding of the circuit in which the codes or password is already stored in it which is known by the owner. This section also provides the delay timing and number of attempts which can further be changed any time in the programming.
Derive Section:This section includes a motor driven IC L293D. It will drive the motor in clockwise or in anticlockwise direction so that the door will open and closed respectively with the motion of the motor.
-5-
Circuit Diagram
-6-
Working
Power supply should always on for this device & connection of alarm is also required. Firstly enter the valid 6 bit digital codes with the help of 4X3 matrix keyboard. The LCD will not show the digit which will enter by the owner in place of the 6 bit code it will display (******), so can no one will see the code entered.
If we press a wrong digit then * button is there in the 4X3 matrix keyboard to change this particular digit. After entering the perfect code press # key which work as enter key to give the code. If the code is correct as the password stored in the microcontroller IC then the motor will turn on and this motor will rotate anticlockwise and hence the door will open. After a specific delay time the door will automatically closed.
If we dial a code which is not fully matched with code stored in the microcontroller IC, the LCD will display wrong code and a alarm will ringing. Near the micro controller one reset switch (a tactile switch) is given which will reset all the systems in digital door lock system or we say that a digitalized security system
-7-
-8-
Details of Components
(1) Microcontroller IC 89C51
DESCRIPTION The 89C51/89C52/89C54/89C58 contains a non-volatile FLASH program memory that is parallel programmable. For devices that are serial programmable (In System Programmable (ISP) with a boot loader), see the 89C51RC+/89C51RD+ datasheet. Both families are Single-Chip 8-bit Microcontrollers manufactured in advanced CMOS process and are derivatives of the 80C51 microcontroller family. All the devices have the same instruction set as the 80C51.
FEATURES
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20.
80C51 Central Processing Unit On-chip FLASH Program Memory Speed up to 33 MHz Full static operation RAM expandable externally to 64 k bytes 4 level priority interrupt 6 interrupt 8-bit I/O ports Full-duplex enhanced UART Framing error detection Automatic address recognition Power control modes Clock can be stopped and resumed Idle mode Power down mode Programmable clock out Second DPTR register Asynchronous port reset Low EMI (inhibit ALE) 3 16-bit timers Wake up from power down by an external interrupt
-9-
- 10 -
- 11 -
PIN DISCRIPTION
Ground: 0 V reference. Power Supply: This is the power supply voltage for normal, idle, and power-down operation. Port 0: Port 0 is an open-drain, bidirectional I/O port. Port 0 pins that have 1s written to them float and can be used as high-impedance inputs. Port 0 is also the multiplexed low-order address and data bus during accesses to external program and data memory. In this application, it uses strong internal pull-ups when emitting 1s. Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. Port 1 pins that have 1s written to them are pulled high by the internal pull-ups and can be used as inputs. As inputs, port 1 pins that are externally pulled low will source current because of the internal pull-ups. T2 (P1.0): Timer/Counter2 external count input/clock out (see Programmable Clock-Out). T2EX (P1.1): Timer/Counter2 reload/capture/direction control. Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. Port 2 pins that have 1s written to them are pulled high by the internal pull-ups and can be used as inputs. As inputs, port 2 pins that are externally being pulled low will source current because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses. In this application, it uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses port 2 emits the contents of the P2 special function register. Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. Port 3 pins that have 1s written to them 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 because of the pull-ups. Port 3 also serves the special features of the 89C51/89C52/89C54/89C58, as listed below: RxD (P3.0): Serial input port TxD (P3.1): Serial output port INT0 (P3.2): External interrupt INT1 (P3.3): External interrupt T0 (P3.4): Timer 0 external input T1 (P3.5): Timer 1 external input WR (P3.6): External data memory writes strobe RD (P3.7): External data memory read strobe
- 12 -
Reset: A high on this pin for two machine cycles while the oscillator is running, resets the device. An internal diffused resistor to VSS permits a power-on reset using only an external capacitor to VCC. Address Latch Enable: Output pulse for latching the low byte of the address during an access to external memory. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency, and can be used for external timing or clocking. Note that one ALE pulse is skipped during each access to external data memory. ALE can be disabled by setting SFR auxiliary.0. With this bit set, ALE will be active only during a MOVX instruction. Program Store Enable: The read strobe to external program memory. When executing code from the external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory. PSEN is not activated during fetches from internal program memory. External Access Enable/Programming Supply Voltage: EA must be externally held low to enable the device to fetch code from external program memory locations 0000H to the maximum internal memory boundary. If EA is held high, the device executes from internal program memory unless the program counter contains an address greater than 0FFFH for 4 k devices, 1FFFH for 8 k devices, 3FFFH for 16 k devices, and 7FFFH for 32 k devices. The value on the EA pin is latched when RST is released and any subsequent changes have no effect. This pin also receives the 12.00 V programming supply voltage (VPP) during FLASH programming. Crystal 1: Input to the inverting oscillator amplifier and input to the internal clock generator circuits. Crystal 2: Output from the inverting oscillator amplifier.
- 13 -
- 14 -
- 15 -
Description
The L293D is a 16-pin chip with a little notch cut out of the front of it (that last bit is for you non-experts). Orient the chip so its notch matches the notch in the shape of the chip on the PCB. Carefully drop the chip into the gold-plated (pretty uptown, eh?) pads, and solder it into place from the other side. To avoid any nasty punctures, clip off any excess pins that poke through the pads on the solder side.
Usage
So you want to know how to use it? It aint too difficult. Heres the long and short of it: Red Vcc (+) Blue - Gnd (-) (on the opposite side of the cable) Orange & Green - D1 & D2 (direction power flow of motor outputs) Yellow - Enable (turns the chip off - connect to gnd to turn it off). Connect the red (+) and blue (-) to power. Leave the yellow line alone, unless if you want to turn the chip off, or pulse it to slow the motor down (a technique called Pulse Width Modulation). Connect D1 to 5V, D2 to gnd, and the motor will turn one way. Connect D1 to gnd, and D2 to 5V, and the motor turns the way. Connect D1 D2 to either 5V or gnd, and the motor is in brake mode (try turning it - hard to do, eh?). Connect the yellow line to gnd, and it doesnt matter what D1 and D2 are connected to, as the motor is in coast mode, as if it werent connected to the motor driver board at all!
- 16 -
SGS Thompson Datasheet Characteristics Logic / Motor supply maximum voltage . . . . . . . . . . . . . . . . . . . . . . 4.5V to 36V Input & enable line voltage range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7V Peak output current (no repetitive), t <=100S (per 2 channels) . . . . . . . . . 2.4A Continuous output current (per 2 channels) . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2A Total continuous heat dissipation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4W Maximum switching frequency (ie: PWMapplications). . . . . . . . . . . . . . . . 5kHz
- 17 -
- 18 -
Features
1. Output Current up to 1A 2. Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V 3. Thermal Overload Protection 4. Short Circuit Protection 5. Output Transistor Safe Operating Area Protection
- 19 -
- 20 -
Crystal Specifications
The reference frequencies for Chrontel's products are derived from an on-chip Pierce oscillator with an external crystal. The oscillator has been designed to function reliably with crystals that conform to the following specifications:
- 21 -
Pullability and Cs
Most crystal manufacturers do not specify Cs explicitly. However, one can measure Cs indirectly by measuring the change in frequency for a given change in load capacitance. Cs is related to the crystal pullability by the following equation. One can reduce the frequency of oscillation by adding external capacitance to C1 and C2 in equal amounts. The oscillation frequency is given by equation 2. Again, by increasing the value of C1 and C2, power dissipation of the crystal increases according to (4).
- 22 -
BRIDGE RECTIFIER
OUTPUT WAVEFORM
- 23 -
Smoothing
Smoothing is performed by a large value electrolytic capacitor connected across the DC supply to act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The diagram shows the unsmoothed varying DC (dotted line) and the smoothed DC (solid line). The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output.
OUTPUT WAVEFORM Note that smoothing significantly increases the average DC voltage to almost the peak value (1.4 RMS value). For example 6V RMS AC is rectified to full wave DC of about 4.6V RMS (1.4V is lost in the bridge rectifier), with smoothing this increases to almost the peak value giving 1.4 4.6 = 6.4V smooth DC. Smoothing is not perfect due to the capacitor voltage falling a little as it discharges, giving a small ripple voltage. For many circuits a ripple which is 10% of the supply voltage is satisfactory and the equation below gives the required value for the smoothing capacitor. A larger capacitor will give fewer ripples. The capacitor value must be doubled when smoothing half-wave DC. Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output voltages. They are also rated by the maximum current they can pass. Negative voltage regulators are available, mainly for use in dual supplies. Most regulators include some automatic protection from excessive current ('overload protection') and overheating ('thermal protection'). Many of the fixed voltage regulator ICs has 3 leads and look like power transistors, such as the 7805 +5V 1A regulator shown on the right. They include a hole for attaching a heatsink if necessary.
- 24 -
The transistor performs two basic functions. It acts as a switch turning current on and off. It acts as a amplifier. This makes an output signal that is a magnified version of the input signal. Transistors come in several sizes depending on their application. It can be a big power transistor such as is used in power applifiers in your stereo, down to a surface mount (SMT) and even down to .5 microns wide (I.E.: Mucho Small!) such as in a microprocessor or Integrated Circuit. NPN Transistor: Bipolar junction perform the function of amplifications where a small varying voltage or current applied to the base (the lead on the left side of the symbol) is proportionately replicated by a much larger voltage or current between the collector and emitter leads. Bipolar junction refers to sandwich construction of the semiconductor, where a wedge of "P" material is placed between two wedges of "N" material. In this NPN construction a small base current controls the larger current flowing from collector to emitter (the lead with the arrow). The useful dynamic range extends to 100 mA as a switch and to100 MHz as an amplifier.
- 25 -
Electrical Characteristics
- 26 -
Description
Once you add a keyboard for your system, you allow the user to input information to the microcontroller in real time. In this tutorial, you will learn how to connect a keyboard to your microcontroller and the basic principle to decode keyboard input. In general, keyboards are organized as a matrix of rows and columns; two side of this matrix are connected to Vcc through resistors while the third side is connected to the microcontroller port and configured as an output; and the last side is connected to the microcontroller port and configured as an input as shown in fig. 1. Microcontroller keep scanning the keyboard, when all inputs are high ("ones") that mean no key is pressed; if one bit is low ("zero") that mean there is a pressed key. System designer setup a Look-Up Table contain the ASCII code for each key, in this project we will use 16 keys to represent the hex number from 0 to F arranged according to keyboard arrangement. To detect which key is pressed; microcontroller ground all rows, then reads all columns, if all the columns=1's no key is pressed, if one columns=0 it's indicate that a key is pressed. To
- 27 -
identify the exact pressed key, microcontroller will start with the top row by grounding it; then read the columns. If the data read is all ones, no key that row activated, and the process will move to the next row, until reach the row that has a pressed key. At this stage, microcontroller knows the row that has a pressed key, and can setup the starting address in the look-up table for that row. The last step is finding the column that has a pressed key by rotating the columns bits; one bit at a time to locate a low bit, the most efficient way is rotating column bits through the carry flag by using RRC instruction. When the 0 bit found, microcontroller pulls the corresponding code from the look-up table. To be sure that no key is still down from the previous session, microcontroller send 0's to all rows at on time and check the columns, if all columns are high then the normal scanning start, otherwise, it will wait until all columns become high. At the left, you will find the assembly code for scanning 4x4 keyboards, assuming that the input data will be a hex number form 0 to F, ports P1.0 to P1.3 of the 8051 microcontroller connected to rows, P2.0 to P2.3 connected to columns. The pressed key ASCII code will be stored in A. At the right is the flowchart that describes the code
- 28 -
- 29 -
Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Symbol GND Vcc VEE RS R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7
I/O I I I/O I/O I/O I/O I/O I/O I/O I/O I/O
Description Ground +5V power supply Contrast control command/data register selection write/read selection Enable The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus
Vcc, Vss, and VEE While Vcc and Vss provide +5V and ground, respectively, VEE is used for controlling LCD contrast. RS - register select: There are two very important registers inside the LCD. The RS pin is used for their selection as follows. If RS = 0, the instruction command code register is selected, allowing the user to send a command such as clear display, cursor at home, etc. If RS = 1 the data register is selected, allowing the user to send data to be displayed on the LCD. R/W - read/write:
- 30 -
R/W input allows the user to write information to the LCD or read information from it. R/W = 1 when reading; R/W =0 when writing. E - enable: The enable pin is used by the LCD to latch information presented to its data pins. When data is supplied to data pins, a high to low pulse must be applied to this pin in order for the LCD to latch in the data present at the data pins. This pulse must be a minimum of 450 ns wide. D0 D7: The 8 bit data pins, D0 D7, are used to send information to the LCD or read the contents of the LCDs internal registers. To display letters and numbers, we send ASCII codes for the letters A Z, a z, and numbers 0 9 to these pins while making RS = 1. There are also instructions command codes that can be sent to the LCD to clear the display or force the cursor to the home position or blink the cursor. Table below lists the instruction command codes. Code (hex) 1 2 4 5 6 7 8 A C E F 10 14 18 1C 80 C0 38 Command to LCD Instruction Register Clear display screen Return home Shift cursor to left Shift display right Shift cursor to right Shift display left Display off, Cursor off Display off, Cursor on Display on, cursor off Display on, cursor blinking Display on, cursor blinking Shift cursor position to left Shift cursor position to right Shift the entire display to the left Shift the entire display to the right Force cursor to beginning of 1st line Force cursor to beginning of 2nd line 2 lines and 5x7 matrix
We also use RS = 0 to check the busy flag bit to see if the LCD is ready to receive information. The busy flag is D7 and can be read when R/W =1 and RS = 0, as follows: if R/W =1, RS =0. When D7 = 1(busy flag = 1), the LCD busy taking care of internal operations and will not accept any new information. When D7 = 0, the LCD is ready to receive new information. Note: It is recommended to check the busy flag before writing any data to the LCD.
(9)
- 31 -
Resistors
There are three resistors of ceramic type is used in this system i.e. 8.2K, 4.7K & 1K. According to the circuit requirements we used these resistors in the circuit. One with Microcontroller in the reset mechanism. A preset of 10K is also used in the circuit which is used to control the intensity of the words display on the LCD display. A resistor array is used with the output port of the microcontroller used in the LCD data cable is used to make low signal high at the output. This array is of 10K i.e. 10K resistance each.
(10) Capacitors
In this system we used two types of capacitors one is ceramic type and another is electrolytic type. In ceramic type we used two 33pf and two .01f capacitors. .01f capacitors are used with regulator IC as standard circuit components. 33pf capacitors are used with Crystal Oscillator. In electrolytic type we used 10f and 1000f capacitors. 1000f capacitor is used as filter capacitor. 10f capacitor is used with microcontroller IC.
(11) Transformer
In this circuit we used a transformer which is step down type of 12Vpp (i.e. -6V 0 6V). Because we used a mains power supply for our project so that we need 12V dc to operate our project, so thats why we used this transformer.
(12)
- 32 -
Geared Motor
Specifications
High efficiency, high quality low cost DC motor with gearbox for robotics applications. Very easy to use and available in standard size. Nut and threads on shaft to easily connect and internal threaded shaft for easily connecting it to wheel.
Features
45 RPM 12V DC motors with Gearbox 5kgcm torque 3000RPM base motor 6mm shaft diameter with internal hole 125gm weight Same size motor available in various rpm No-load current = 60 mA(Max), Load current = 300 mA(Max)
(13) Buzzer
It is simple buzzer which is used in vehicles as a side indicator. It is look like as follows And operates at 5V via transistor output.
- 33 -
- 34 -
- 35 -
- 36 -
- 37 -
FEATURES
1. You can control up to 14 devices. It may be any electric or electronic appliances or devices with simple to heavy appliances. Each device is given a unique code. 2. It makes accurate switching; any false switching will not open the door. 3. This circuit require microcontroller IC, so any one with little knowledge of programming can construct this circuit. 4. This system reads the entered password which is already present in programming of microcontroller IC and than open the door. 5. This circuit switches OFF after a delay time (you can change this Time in programming of IC). 6. Before changing the state of the device we can confirm the present status of the device. 7. This circuit gives an acknowledgement tone after switching ON the devices to confirm the status of the device. 8. You can control devices from local telephone. It can also be controlled by mobile.
- 38 -
ADVANTAGES
1. THERE IS NO NEED OF ANY TYPE OF HARMFUL RADIATIONS. 2. NO NEED OF LIGHT SOURCE LIKE AS LASER. 3. THERE IS NO PROBLEM OF RANGE. 4. THER IS NO NEED OF SPECIFIED PHONE , WE CAN USE EITHER MOBILE OR BASIC PHONE. 5. BY USING THIS WE CAN ALSO DETECT THE STATUS OF CONNECTED DEVICES. 6. HERE WE USED DIFFERENT KEYS FOR SIGNALING PURPOSE BY WHICH WE CAN TRANSMIT ADDITIONAL INFORMATION. 7. THERE IS NO NEED OF EXTERNAL CLOCK BECAUSE THIS HAS IN BUILT CLOCK. 8. HERE WE HAVE DISPLAY UNIT ALSO. 9. BY USING THIS WE CAN SAVE MONEY.
DRAWBACKS
1. Easily accessed by person who knows the password of lock which is already present in the programming. 2. This is entirely depend on mobile or telephone network. 3. Power supply for local control circuit should always on either circuit is in working condition or not.
- 39 -
CONCLUSION
This project is very useful in organizations where a particular device or system is needed to be confined to only a few people so that the security of the organization is maintained. Our project which enables the users to prevent the misuse of the device or system. This project is made for users and one administrator; parting them no one else will be able to use the device of 220V. User has his own password. The device is always available for authentic user. users can enable the system. Now when a user wishes to make a device run, he will have to give the particular password accepting which the system will enable him to make a use. In case the user gives a wrong password three times, the system will display access denied and start buzzing so user will know that someone is trying to misuse the device. The administrator only can change the password. This project is also useful at homes where one does not want their children or servants to unnecessarily use the device of 220V.
APPLICATION
Used for security of high professionals computer. This device can also used for security of person by attaching this device at home. This device can provide security of any system or instrument which work on 220v (ac). It can be used in the homes also for locking of television so that children cannot use it without permission
- 40 -