You are on page 1of 24

Electronic Door Lock

Project #15 By: Joseph Petrovic Robert Sanfor !": Jon Benson Dec# $% 1&&&

"BS!R"'!
The goal of this project was to design and develop an electronic door lock, which is controlled by a 4-digit password entered by the user. The password is entered using a standard 16-button keypad, which is mounted on the door. asically, the functionality of this device can be seen once the correct

password is entered. The user then has a choice between unlocking the door and changing the current password. y unlocking the door, the locking mechanism remains open for about !" seconds. #nce the

!"-second time interval elapses, the door lock automatically returns to the locked position. $pon changing the current password, the new password is valid immediately. The main features of this electronic door lock are its high reliability, low operating power consumption, and ease of use. Thus, this electronic locking mechanism definitely possesses marketable potential.

ii

!able of 'ontents
1. %ntroduction..............................................................................................................................................1 !. &esign 'rocedure.....................................................................................................................................(
!.1 )eypad %nput.......................................................................................................................................................................( !.! *+& &isplay........................................................................................................................................................................4 !.( ,,, Timer............................................................................................................................................................................4 !.4 -icro controller...................................................................................................................................................................4 !., *ocking -echanism............................................................................................................................................................,

(. &esign &etails...........................................................................................................................................
(.1 16- utton )eypad................................................................................................................................................................ (.! )eypad +ncoder................................................................................................................................................................... (.4 ,,, Timer............................................................................................................................................................................/ (., 0olid 0tate 1elay................................................................................................................................................................./ (.6 0olenoid and 0pring............................................................................................................................................................2

4. &esign 3erification................................................................................................................................1"
4.1 -icro controller Test.........................................................................................................................................................1" 4.! 0olid 0tate 1elay Tests......................................................................................................................................................11 4.( 'ower Tests.......................................................................................................................................................................11

,. 'arts and *abor 4osts............................................................................................................................1! 6. 4onclusion.............................................................................................................................................1( 5ppendi67 8igures.....................................................................................................................................1, 1eferences..................................................................................................................................................!1

iii

1# (ntro )ction

8igure 1 9all figures appear at the end of the report: shows the block diagram of our device. #ur device utili;ed the -otorola 6/<41! micro controller to control all of the inputs and outputs for the system. The micro controller essentially acts as the brain of our design and reads in all of the inputs entered by the user. The keypad is connected to a 16-key encoder by which all 16 keys are encoded so that the micro controller can recogni;e which key is pressed. =hile entering the 4-digit password, the micro controller accepts one digit at a time and subse>uently compares each digit to the stored password. #nce the correct password is entered, the micro controller sends an output signal to one of the *+&s to inform the user that he or she may proceed with unlocking the door or changing the password. %f the user opts to change the current password, the micro controller sends an output to a different *+& signaling to the user that they are in the change password mode. Therefore, the micro controller accepts the ne6t four numbers entered by the user and replaces the stored password with these numbers. #nce the user enters the correct password and decides to unlock the door, the micro controller sends an output pulse to trigger the solenoid lock. 5nother output is sent to the *+& signaling that the lock is in its unlocked position so that the user is now able to open the door. =hen the ,,, Timer in our circuit receives the output pulse from the micro controller, it preserves this voltage for about !" seconds, thereby allowing the door to remain unlocked for !"-second intervals. This electronic door lock design is intended to have low operating power consumption. =ith this in mind, we designed the door lock to retract or unlock only when , volts are applied to it. Thus, the door lock consumes power only when it is unlocked for those !"-second intervals. This design is also useful in the event of a power outage in that you can be assured that your door will remain locked, which is particularly comforting when you may be asleep or on a trip away from home. #ne design

specification that was reformulated in our final design was the use of a solid state relay in place of the simple amplifier we had originally proposed.

*# Desi+n Proce )re

*#1 ,eypa (np)t 8or user input there were a couple of implementations that could have been used. #ne way would be to use a transmitter and receiver so that the door could be unlocked remotely. <owever, only a person with the proper transmitter could unlock the door, which means only a couple people would be able to unlock the door. 8or additional people to be able to unlock the door, additional transmitters would have to be purchased. This would cost money and would be a hassle. 8urthermore, the transmitter would have to use a battery to power it. This would work fine until the battery died, in which case the user would be locked out. Therefore, our device uses a keypad for user input. This will allow any number of people to unlock the door. 'lus, the password can easily be changed if someone who should not know the password discovers it. The keypad allows for a cheap, yet effective means for inputting all important information into the device. The keypad is used for the following7 inputting the password, unlocking the door, and changing the password. This means that the keypad needs at least twelve keys. Ten are used to represent digits ;ero through nine for inputting the password. #ne button is used to unlock the door and another for changing the password. Therefore, using a twelve-button keypad would have been the best. <owever, twelve-button keypads are e6tremely rare, so the common si6teen-button keypad was used instead. The keypad is connected to a keypad encoder. This encoder then outputs to the micro controller. <ow the keypad is connected to the encoder and what information is outputted to the micro controller is discussed in the chapter ( of this paper.

*#* LED Display The *+& display is used to output information to the user. %t consists of three *+&?s, with each turning on to tell the user in which state the device is. 8igure ! shows the *+& display, as the user would see it. The top *+& is on when the door is unlocked. The middle one is on when the door is locked. The bottom *+& is on when the device is in the change password mode. =hen the device is in this mode, the user must type in a new password.

*#- 555 !i.er =e incorporated the ,,, Timer to control the amount of time the door lock was to remain unlocked. The main design issue here was adjusting the resistance and capacitance values to hold the input for a predetermined time interval. This time interval was determined by the following e>uation7 T @ 1.1 6 1 6 4 91:

5n alternative approach to controlling this time interval would be to implement it with the micro controller. This approach, however, took away processing time from the micro controller so that it could not process any more inputs until the door was locked again. Therefore, the use of e6tra hardware, in this case the ,,, Timer, was justifiable. #ur design allowed the ,,, Timer to retain the input signal sent from the micro controller, in effect, freeing up the micro controller to process other tasks such as user inputs to change the password even while the lock remains unlocked.

*#/ 0icro controller =e also incorporated the -otorola 6/<41! micro controller. 8igure ( shows the flow diagram of the micro controller programming. This particular micro controller was chosen based on the fact that we had previously worked with the 6/<41! and were already somewhat familiar programming with the <41!. 5n alternative would have been to use the -46/<421! (!, the micro controller card that was

also available. This device has the same functionality as the <41!, only not as bulky. Thus, the micro controller card would have been the better alternative due to the many applications and small overhead of our door lock design. %nitially, we began our design using the micro controller card, but unfortunately due to a defective protoboard, the card was destroyed. Thus, we were forced to use the micro controller bo6, which increased the overall area of the device.

*#5 Lockin+ 0echanis. The locking mechanism consists of an aluminum bar, a spring, and a solenoid. %t is powered by 1!" 3ac at 6" <;, so using a normal electrical outlet will suffice. 4ontrolling whether the locking device is in the locked or unlocked state is accomplished using a solid state relay, which will be discussed in more detail in chapter (. 8igure 4 shows the locking device in the locked position. %n the locked state the aluminum bar is in both the wall and the door, thereby locking the door. The solenoid is not powered so it is not e6erting any force on the bar. The spring is in its e>uilibrium position. Thus, it will resist any force e6erted on the bar, such as someone trying to force open the lock. =hen 1!" 3ac

appears across the inputs of the solenoid, the solenoid attracts the bar into it. This compresses the spring and pulls the bar out of the door. This causes the door to unlock as seen in fig. ,. The lock will stay in this position until the power to the solenoid is turned off. The spring will then return to its e>uilibrium position and push the bar into the door, locking the door. The solenoid that is used in the device re>uires 1!" 3ac and draws about (.2 5. #riginally, a smaller, less powerful solenoid was to be used. This solenoid only needed 1! 3dc and drew .26/ 5, so it would have consumed only about !.,A of the power that the larger solenoid consumes. <owever, it would also have significantly less pulling force, so the spring used in the locking device would have to be weaker. This would make it easier for someone to force open the lock. Thus, although our solenoid

consumes much more power, it is much more powerful, which is more important when dealing with a security device such as a door lock.

-# Desi+n Details

-#1 112B)tton ,eypa The keypad itself consumes no power. %t works by simply making connections between wires. The keypad has eight inputs7 one for each of the four rows of buttons and one for each of the four columns of buttons. =hen a button is pressed, a connection is made between the input for the row and the input for the column in which the button is located. 8or e6ample, suppose the input for the first column is grounded and a voltage is applied at the input for the first row. %f no button is pressed no current will flow through any input. Bet, if button C1,C which is located in the first row and first column, is pressed, a connection is made between the two inputs mentioned above and current flows through each input. This will only happen if button C1C is pressed. =ith this configuration it would have been possible to connect the keypad directly to the microprocessor, and have it look for a connection across two inputs. <owever, there is an encoder designed specifically for this type of keypad. Therefore, the encoder, which is discussed below, was used.

-#* ,eypa Enco er The --.442!! keypad encoder implements all the logic necessary to interface a keypad to a digital system D(E. The encoder finds if any connections are being made in the keypad and outputs five bits corresponding to the state of the keypad. #ne of the output bits, the C&ata 5vailableC bit, is high when a button is being pressed and low when no button is being pressed. The other four output bits are data bits which output a number depending on which of the si6teen buttons is being pressed. 8igure 6 shows a detailed diagram of how the encoder is used. The eight inputs from the keypad are connected directly to the encoder. The C&ata 5vailableC bit and the data bits are on the right side of the diagram. The C&ata 5vailableC bit is also connected to an inverter whose output is connected to #+ or C#utput
.

+nableC pin of the encoder. This logic is used to ensure that the data bits output a number only when a button is being pressed. The two capacitors located at the ) - and #04 pins of the encoder are used for eliminating key bouncing. 8igure . shows the debounce period versus the capacitor value at the ) - input in microfarads. $sing this graph, a capacitor value of 4..8 was chosen. This gives a debounce period of around ".",s, which will eliminate all key bouncing but is not so large that it re>uires the user to hold the button down a long time before the encoder recogni;es the input. 8inding the value of the capacitor at the #04 pin is just a matter of dividing the capacitance of the ) - capacitor by 1". Therefore, a capacitor with a value of .4.8 is used.

-#/ 555 !i.er 8igure 2 shows a diagram of the timer circuit. The ,,, Timer incorporated a ((k#hm resistor and a 4." micro 8arad capacitor. The resistor and capacitor are placed in parallel to produce a delay of !" seconds. 5ccording to e>uation 91:, the time delay is found by multiplying 1.1 times the resistor value times the capacitance. 3arying the capacitance and resistor values allows us to easily adjust the time delay. Therefore, the amount of time the door lock remained unlocked could be easily changed to suit the particular application.

-#5 Soli State Relay 5 relay was used to control whether the solenoid was on or off, thereby controlling if the door was locked or unlocked. The =61!,&0F-1 solid state relay was used for this purpose. This relay has a very wide control voltage range 9(-(!3dc:, which ensures that the relay will function even if large amounts of noise are introduced. 0ince the solenoid, which is controlled by the relay, re>uires 1!" 3ac

to power it, we needed a heavy-duty relay that could take such a large voltage. The =61!,&0F-1 relay can handle any voltages between !" 3ac and 14" 3ac. 5nother concern with the relay was heating. Therefore, a relay with a current rating well above the device?s operating current was necessary. 0ince the solenoid operates at around (.2 5, a relay with a !, 5 current rating, which is the current rating of the =61!,&0F-1, would be sufficient. #f course a trade-off of using a relay with such e6cellent characteristics is the high cost of the relay. Gevertheless, it is necessary to spend a few more dollars to ensure that our device works properly and to ensure that our device does not cause a safety ha;ard because of e6cessive heating.

-#1 Solenoi an Sprin+ 5s mentioned in the Clocking mechanismC section of chapter !, our locking mechanism needed to be sturdy and hard for someone to force open. This re>uires a strong spring, which in turn re>uires a powerful solenoid to compress it. Therefore, the device uses a solenoid which needs 1!" 3ac, draws (.2 5, and consumes 46/ =. =ith such a powerful solenoid, there was much fle6ibility in choosing the right spring. 8igure / shows a graph of the pull force of the solenoid versus stroke in inches. $sing this graph, a spring was found that would fit within this force range.

/# Desi+n 3erification

/#1 0icro controller !est -uch of the testing with this project involved debugging the micro controller code and interfacing the micro controller with the wired hardware. The debugging entailed positioning various print statements throughout the code to see e6actly which opcodes were e6ecuted. #ftentimes, it was difficult to determine if a problem was rooted in the hardware wiring or in the micro code. =e used the computer monitor to e6plicitly output the code e6ecuted and the oscilloscope to diagnose any potential hardware problems. The biggest hurdle we had to overcome was making sure that each input was sent to the right port of the micro controller. This was ensured with numerous compare statements within the micro code. Therefore, if the micro controller read signals different than those e6pected, this could be easily detected when the program was stuck in an endless loop outputting error statements. #nly when the micro controller recogni;ed a valid input did it jump to the ne6t loop. -aking sure that the micro controller output the correct signals was also important. This was verified using a number of test *+&s placed in appropriate locations within in our circuit. %f an *+& was erroneously triggered, we first traced it back to the micro code to see if any of the instructions interpreted the inputs incorrectly. Ge6t, we looked at how the particular component was wired and determined if it was behaving correctly based on the signal sent to it by the micro controller. $ltimately, this was how many of our debugging problems were rectified. 5s a result, interfacing the micro controller with the rest of our circuit proved to be a long and iterative trial and error process.

1"

/#* Soli State Relay !ests #ne of the tests we performed on the relay was to find the actual control voltage range of the input. The control voltage range to was rated to be (-(! 3dc. =hen tested, the minimum voltage was found to be 1.! 3dc, which is even below the rated ( 3dc. Go tests were performed to find the actual upper limit to avoid ruining the relay. <owever, voltages as high as 1, 3dc were tested and the device still performed as e6pected. 0ince the only voltage that should appear at the input is , 3, a range of 1.!1, 3dc is a sufficient control voltage range.

/#- Po4er !ests 0ince most of our device was digital logic, power consumption was not really a concern, especially considering that our device would be powered using an electrical outlet. <owever, power consumption did play an important role in testing the solenoid and the relay, because with those components, large power consumption might cause the device to overheat and start a fire. 0everal tests were run on the solenoid, and it consistently consumed around 46/ =. This is pretty high for power consumption. Gevertheless, our solenoid is only drawing power when the door is unlocked. 0ince our device would mostly be in the locked state and would only be unlocked for !" s intervals, the solenoid would never have a chance to heat up. Therefore, the 46/ = is an acceptable value. Tests similar to the one performed on the solenoid were performed on the relay. The ma6imum power the relay consumed was 6.!4 =, and the average power was ,.1( =. 0ince the relay is drawing power only when the door is unlocked like the solenoid and since ,.1( = is so small, there is little chance the relay will cause any safety ha;ards.

11

5# Parts an Labor 'osts


Table 1 is an itemi;ed list of all the parts needed for one device. 8rom this list the total parts cost is found to be7 Total 'arts 4ost @ H1(2."! The total labor costs are found as follows7 I hours J desired salary J !., 6, J H(" J !., @ H4/.,Kperson Total *abor 4osts @ H2.," y adding the total parts cost and the total labor costs the total project cost comes to7 Total 'roject 4ost @ H2//2."! 9!:

1!

1# 'oncl)sion

#ur electronic door lock performed as e6pected. =e were able to implement all of the functions specified in our proposal. The biggest hurdle we had to overcome with this project was interfacing the micro controller with the hardware components. =e feel that this electronic door lock is very marketable because it is easy to use, comparatively ine6pensive due to low power consumption, and highly reliable. This door lock is therefore particularly useful in applications such as hotel room door locks, residential housing, and even office buildings. There are always changes one can make to potentially improve a designLs performance or marketability. 0ome of the modifications that might have been useful for our electronic door lock include adding an automatic shut-off switch, utili;ing a 1#- chip instead of a 15- chip, and also adding a manual override. The automatic shut-off switch could have been implemented as a cautionary measure in the event of a micro controller malfunction. %n this instance, the automatic shut-off switch would disconnect any power source to the solenoid and subse>uently protect against any potential fire ha;ard. This automatic shut-off switch could also be connected to a temperature sensor and turn off the power if the temperature of the system rose above a particular threshold temperature. $tili;ing the 15- chip instead of a 1#- chip would also have improved our design by ensuring that the password was preserved once the power to the circuit was cut off. This would avoid the hassle of reinitiali;ing the password once power was restored. 5lso, the addition of a manual override would have added marketability to our electronic door lock. 8or instance, if the power happened to go out, the door would remain in its locked position. Therefore, if one needed to unlock the door, especially in an emergency, the manual override would account for this contingency. #ne of the main issues we considered in determining the design of the solenoid locking mechanism was safety. $ltimately, our locking mechanism unlocked only when power was applied to it

1(

and otherwise remained locked. This was important in the event of power outages. %f the power went out in the middle of the night or while nobody was home, for e6ample, we wanted to ensure that the door remained locked. %f we had designed the locking mechanism to lock only when power was applied, inevitable power outages would leave the door unlocked and the house or building would then be vulnerable to burglars. This electronic door lock is evidently appropriate for those who feel they have had enough of the hassles of dealing with losing or forgetting keys, duplicating keys, or even changing door locks. The electronic door lock definitely eliminates the need for conventional keys or key cards and is indeed the perfect solution to many homes, businesses, and hotels that lack a reliable and easy to use electronic security door lock.

14

"ppen i5: 6i+)res

*+& &isplay

-icro 4ontroller

Timer

)eyboard +ncoder

0olid 0tate 1elay 'ower #utlet *ocking -echanism


8ig. 1. &evice lock &iagram.

16- utton )eypad

*+&?s

8ig.!. *+& &isplay.

1,

%nitiali;e password

=ait for input

Go input

%ncorrect password

4heck password 4orrect password

=ait for ne6t instruction

Go input

#pen lock

4hange password M set *+& 8ig. (. 8low &iagram of micro controller program.

0tore new password

16

0olenoid &oor =all

0pring
8ig.(. *ocking -echanism in locked position.

%nputs

0olenoid &oor =all

0pring
8ig.4. *ocking -echanism in unlocked position.

%nputs

1.

!o .icroprocessor Data "vailable

8ig. 4. &iagram of keypad and keypad encoder.

8ig. ,. Nraph of debounce period versus capacitor value at ) - input of encoder.

1/

8ig. 6. Nraph of pull force of solenoid versus stroke.

8ig. O. &iagram of timer circuit.

12

'art 0olid 0tate 1elay -icro 4ontroller 16- utton )eypad ,,, Timer %nverter Nate 16-)ey +ncoder 1esistors *+& 0olenoid 4apacitors

'art Gumber =61!,&0F-1 6/<41!

4ost per part H(/."" H16."" H1!.," 1 1 1 1 1 1 1 ( 1 (

Puantity

Total cost H(/."" H16."" H1!.," H1."" H".," H,."" H"."! H1.," H6(."" H1.," H1(2."!

-414,,'1 &-.45*0"4 --.442!!

H1."" H".," H,."" H"."! H".," H6(."" H".,"

Total Table 1. 'arts cost list.

!"

References
<elp for The ,,, Timer 4hip, http7KKwww!.ebtech.netKQpaisK,,,RTimerR<elp.html. --.442!!, --.442!( 16-)ey +ncoder, Neneral -anual, 1222. -otorola 6/<41! -icro 4ontroller 1eference -anual, http7KKebus.mot-sps.comKmcuKdocumentationKpdfKcpu1!rmr1.pdf.

!1

You might also like