project14 final paper (DOC)

Document Sample
project14 final paper (DOC) Powered By Docstoc
					    Telephone Activated Lock


               By



    Drew Handler and Joey Ko

ECE 445, SENIOR DESIGN PROJECT

          FALL 2010




        TA: Sarah Shiffer

        7 December 2010

         Project No. 14
                                           ABSTRACT

Almost everyone has been in the situation where they are locked out of their house and it would
be helpful if there is a way for them to lock or unlock the door without using a key. This paper
explains the design of a deadbolt lock that is controlled through the phone line and can be locked
or unlocked remotely from anywhere. This project consists of circuit to pick up a phone call and
determine the keys pressed by the user at the other end of the telephone line as well as the
software to verify an input password and ultimately control the lock. The paper details the steps
it took to create the final design of the project, the problems encountered, and the final results. It
also examines the estimated cost of manufacturing this product.




                                                  ii
                      TABLE OF CONTENTS


1   INTRODUCTION…………………………………………………………………………….1
    1.1 Features/ Benefits…………….………………………...………………………………...1
    1.2 Subprojects……………………………………………………………………………….1
     1.2.1 Call Pick Up Circuit...………………….……………………..……………………1
      1.2.2 DTMF Decoder …………………………………………….……………………...1
      1.2.3 Password Verification ………………………………….………………………….1
      1.2.4 Servo Controlled Lock ……………………………………….……………………2

2   DESIGN PROCEDURE ………………………………………………….…………………..3
     2.1 Call Pick up Circuit………………………………………………………………………3
     2.2 DTMF Decoder…………………………………………………………………………..3
     2.3 Password Verification……………………………………………………………………4
     2.4 Servo Controlled Lock…………………………………………………………………...4

3   DESIGN DETAILS…………………………………………………………………………...5
     3.1 Call Pick Up Circuit ……………………………………………………………………..5
     3.2 DTMF Decoder…………………………………………………………………………..5
     3.3 Password Verification……………………………………………………………………6
     3.4 Servo Controlled Lock…………………………………………………………………...6

4   DESIGN VERIFICATION……………………………………………………………………7
     4.1 Call Pick Up Circuit ……………………………………………………………………..7
     4.2 DTMF Decoder…………………………………………………………………………..7
     4.3 Password Verification………………………………………………………………..…..7
     4.4 Servo Controlled Lock…………………………………………………………………...7

5   COST……………………………………………………………………………………...…..8
     5.1 Parts……………………………………………………………………………………...8
     5.2 Labor…………………………………………………………………………………......8

6   CONCLUSIONS……………………………………………………………………………...9
     6.1 Results……………………………………………………………………………………9
     6.2 Improvements ……………………………………………………………………………9
     6.3 Future Work...……………………………………………………………………………9
     6.4 Acknowledgements …………………………………………………………………...…9

    REFERENCES……………………………………………………………………………....10

    APPENDIX – Figures ……………………………………………………………………….11




                              iii
                                              1. INTRODUCTION

        Nearly everyone has, at one time or another, forgotten to lock their door, forgotten whether or
        not they locked their door or been locked out of their own home. Our project aims to provide a
        single simple solution for anyone that finds themselves in one of these situations. Since almost
        everyone has a cell phone with them at all times these days, using them to control the lock
        seemed to be the obvious choice to solve the problem. Our project, the telephone activated lock,
        will allow someone to “call” their door lock and either lock or unlock the door remotely.

        1.1 Features/Benefits
        This project is a circuit connecting to any landline telephone lines and to a deadbolt lock. The
        circuit picks up the phone call by the user automatically and the call is connected for 15 seconds.
        During the time the call is connected, the user needs to input the preset password, and then it will
        allow the user to lock or unlock their door as well as changing the stored password. The circuit
        allows users to communicate with the lock through the telephone line using any phone.

           Benefits
               Prevent someone from being locked out of their home
               Help to prevent burglaries because of doors left accidentally unlocked
               Provide reassurance for anyone that forgets whether or not they locked their door
               The ability to open your door for someone even if you are not there

           Features
               Servo to turn the lock
               Circuit to store and recognize the password to lock/unlock door
                   Ability to change the password

        1.2 Subprojects
        The following is the list of subcomponents of the project as well as a simple description of the
        functionality and features of the components. See Figure 1.1(all figures appear at the end of the
        report) for the component block diagram.

1.2.1   Call Pick Up Circuit
        Usually picking up a phone call is a manual operation of a person physically picking up the
        phone off the hook. This circuit does exactly this job for us. Taking the analog signal from the
        telephone line, it recognizes when an incoming call is being made and automatically connects the
        call for 15 seconds before disconnecting the call automatically.

1.2.2   DTMF Decoder
        After the call has been connected, the DTMF (Dual Tone Multi Frequency) decoder recognizes
        which key the caller presses on the other end of the line.

1.2.3   Password Verification
        This circuit consists of a microcontroller that acts like a state machine. Taking inputs from the
        DTMF decoder, i.e. the password and the commands to lock or unlock, the password verification
        circuit is the security feature for the project. It verifies that the input password is correct before
        giving the user access to control the lock and to change the stored password.

                                                          1
1.2.4   Servo Controlled Lock
        This is a standard deadbolt lock that can be found on any front door. Attached to the lock is a
        standard servo that can turn the lock to either lock or unlock.




                                                         2
                                   2. DESIGN PROCEDURE

The following sections examine different approaches to the design and how we chose the final
design of these components as well as the steps we took to create the final design.

2.1 Call Pick Up Circuit
There are 3 different states of any given telephone line with different signals:
      When no calls are being made there is a 50V DC signal on the line
      When there is a incoming call and the phone is ringing there is a 90V AC signal
      When call is connected, there is a signal voltage of about 25V DC
We first used the bridge-connected rectifier to block out the negative voltages of the AC signal.
But the voltage of 90V is still too high for the rest of the circuit, so we used resisters to lower the
rectifier output voltage. To lower the voltages, we used the voltage divider rule. Using the ratio
of the resistances, we figured out what the output voltage will be with different resistor values.
After the signals on the telephone line goes through the rectifier circuit described above, the
voltages in the 3 states should have different voltages with the “ringing” voltage at the highest
value, followed by the “idle” voltage, and the “connected” voltage should have the lowest value.
We want to be able to distinguish between when we want to have the call connected and when
we want to disconnect the call, so we feed these voltages into a voltage comparator with the
reference voltage right in between the ringing voltage and the idle voltage. The reference voltage
is outputted from a potentiometer. This comparator circuit will output logic 1 for any input
voltage higher than the reference voltage, and logic 0 for any input voltage lower than the
reference voltage.
We wanted to have the circuit connect the call when the comparator outputs logic 1 and
disconnect the call when it outputs logic 0, but the problem lies with the output voltage when the
phone line is in the “connected” state. Since the connected voltage is the lower than the reference
voltage, when the call is connected, the comparator will output logic 0, which will then
disconnect the call. At first we use a capacitor keep the call connected, but since there is no
signal to tell the circuit when the caller disconnects the call from the other end, the circuit will
have no way to know when to disconnect the call.
Our solution to this problem was to put us a D flip-flop with its clock driven by a PIC
microcontroller. The microcontroller and the flip-flop take the output from the comparator and
are able to keep the comparator output at logic 1 for a predetermined period of time before it
goes back to logic 0. This solves the problem of both picking up the call and disconnecting it.
After knowing that we should connect the call at logic 1 and disconnect the call at logic 0, we
need to build the part that actually connects the call. On a telephone line, to pick up a call, a
resistive load of about 680Ω is placed across the phone line to drop down the phone line voltage
to its connected voltage. We use a relay switch that closes and opens with the high and low
digital outputs of the flip-flop to connect and disconnect this load from the phone line.

2.2 DTMF Decoder
Each button on a telephone is represented on a telephone line by a unique combination of two
different frequencies. In order to figure out which button is being pressed on the other side of
the phone line, we used a DTMF decoder chip. The DTMF decoder chip that we chose was the
MT8870. We chose this chip because it was the most common and there was plenty of
information about the chip online. The datasheets for the MT8870 explain the different possible
configurations for the passive components attached to the different inputs and control signals.

                                                  3
For the input from the telephone line we connected it to the operational amplifier inside of the
DTMF decoder chip in a differential amplifier configuration. This configuration was slightly
more complicated and had more components than the single ended input configuration, but
allowed us to reduce the noise on the telephone line and amplify the signal that we wanted

2.3 Password Verification
In order to verify whether or not the user has entered the correct password and if they want to
lock, unlock or change the password we used the PIC 16F877A. We chose this PIC because it
was available in the lab and we did not have any special requirements that this PIC could not
satisfy. We connected the 4-bit output from the DTMF decoder along with the “new button
pressed” signal to five inputs on the PIC and connected the servo’s control wire to one of the
outputs of the PIC.

2.4 Servo Controlled Lock
We chose to use a servo attached to a normal dead-bolt lock so that our circuit could be easily
applied to any normal door. We also chose this configuration over other forms such as a
solenoid lock so that we would have more control of the state that the lock was in without having
to continually use power. A solenoid lock would have a resting position of either locked or
unlocked and we would have to send a current to the lock for the entire duration of time that we
want the lock in the other position and this would be a waste of power. The servo on the other
hand would lock or unlock and then stay in that position without any power being drawn.




                                                 4
                                     3. DESIGN DETAILS

The following sections go over the design of each sub system in detail and explain the output
data expected for each of the components.

3.1 Call Pick Up Circuit
Figure 3.1 shows the complete schematic of this call pick up circuit with the values of each
component shown on the schematic. As stated in the design procedure, there are 3 states of the
phone line each with a different voltage signal. After the signals are fed through the rectifier, the
signals become all DC voltage signals and the voltages become the following:
       Idle Voltage ≈ 0.5 V
       Ringing Voltage ≈ 0.7 V
       Connected Voltage ≈ 0.2 V
To distinguish the idle and the ringing voltage, we choose the reference voltage for the
comparator (LM339N) at 0.6V, so the idle voltage will become logic 0 at the output and the
ringing voltage will give us logic 1. We used the 16F877A PIC microcontroller to output the
clock for the D flip-flop. The flip-flop takes its input from the comparator and the output updates
only on the rising edge of the clock. The PIC takes the input also from the comparator and
outputs the clock pulses depending on the input. When the output of the comparator to the PIC is
0 (meaning the phone line is idle and it is waiting for a call), we want to update the output
relatively regularly in order to detect when the input becomes a 1(when there is a incoming call).
Therefore, we make the PIC output a clock with its period of 1 second. When the input of the
PIC becomes 1, we want to keep the value at high for a period of time to keep the call connected,
so make the PIC outputs 0 for 15 seconds and then we output a 1 for 0.5 seconds. This way we
have a delay of 15 seconds before the next rising edge, so that the D flip-flop delays 15 seconds
before the next time it updates its output and we are able to keep the phone connected at for 15
seconds. The reason we chose 15 seconds is because we thought it was just about enough time
for the user to input the password and then send out a command to lock or unlock the door.

3.2 DTMF Decoder
The complete schematic for the DTMF decoder is shown in Figure 3.2. Pins 7 and 8 are
connected to a 3.579545 MHz oscillator/crystal. Pins 1 through 3 are for the op-amp inside of
the MT8870 chip. Our configuration has a gain of about 150k/56k = 2.6786 V/V. The amplified
signal gets passed through a “Dial Tone Filter” to separate the two frequencies into a high
frequency and a low frequency. To calculate the specific frequencies the number of zero
crossings are counted for a specific span of time, which is one of the reasons that the oscillator is
needed. The two diodes, D5 and D6, are a limiter circuit which protects the chip from large
voltage swings. C1 and C2 are decoupling capacitors. Pin 4 outputs the reference voltage which
is nominally VDD/2. EST (pin 16) is a logic one when a valid tone pair (number) is detected and
returns low when the signal stops. This is connected to the steering input (pin 17) so that the
new tone pair is registered and the output latch (Q1-4) is updated. When the voltage at pin 17
falls below VTSt, the device is ready to accept a new tone pair. This amount of time is simply an
RC time constant determined by R17 and C4. Pin 17 also acts as an output (GT) which resets the
time constant whenever necessary. When the latch is updated and a new number is stored, STD
(delayed steering, pin 15) goes high and returns to logic low when the voltage on St/GT falls
below VTSt. TOE (pin 10) enables the output pins 11-14 and is pulled up internally. Pin 5
inhibits the recognition of the tones for A, B, C and D, but since we are using a phone these
                                                  5
should not appear anyways. If pin 6 gets logic high then it will power down the circuit,
otherwise it is internally pulled down so we don’t need to worry about it.

3.3 Password Verification
For the password verification circuit we used pins 20, 21, 22 and 23 (RD1, RD2, RD3, RD4) for
the 4-bit output from the DTMF decoder (Q1, Q2, Q3, Q4). We connected the control wire for
the servo to pin 40 (RB7). We connected the “new button pressed” signal form the DTMF
decoder to pin 16 (RC1). Whenever a new button is pressed pin 16 goes high and the PIC stores
the 4-bit number at pins 20 through 23 in memory. Once 4 numbers are stored, they are
compared to the password stored in memory. If the 4 keys pressed by the user match the
password, then the PIC waits for two more buttons to be pressed. If the next two buttons pressed
are “**,” then the lock will lock. If the next two buttons pressed are “##”, then the lock will
unlock. If the next two buttons pressed are “#*” or “*#”, then the PIC will wait for four more
number to be pressed and replace the four numbers stored in memory as the password with these
four numbers. If the first four numbers pressed don’t match the password or the next two
numbers are not one of the three combinations mentioned, then the PIC will do nothing and just
wait until the correct four-digit password is entered. See Figure 3.3 for flow chart of the program.

3.4 Servo Controlled Lock
In order to make the servo unlock the lock we made pin 40 (connected to the control wire of the
servo) high for 2.4 ms and low for the next 17.6 ms. This is how we sent 2.4 ms pulses to the
servo every 20 ms. In order to lock the lock we made pin 40 high for .6 ms and low for 19.4 ms.
Again, this meant we were sending .6 ms pulses every 20 ms. We had to send 50 of each of
these pulses to the servo in order to lock or unlock the lock.




                                                 6
                                 4. DESIGN VERIFICATION

After building the circuits and writing the codes in each of the subsystems, we needed to make
sure that they were functioning correctly. Here we explain the testing done to each of the parts to
make sure that they worked properly.

4.1 Call Pick Up Circuit
Testing the call pick up circuit was more than just seeing if it can pick up a call. Since there are
many components to this circuit, we needed to make sure that each of them is working as
expected. We measure and tested the voltages of the inputs and outputs of each components
separately starting from the rectifier. We followed the signal path all the way from the rectifier to
the relay. After all the voltage testing, the circuit should be working flawlessly. Due to
fluctuations on the telephone line signals, an important thing to check if the circuit does not pick
up a call is whether or not the reference voltage coming out of the potentiometer is between the
idle voltage and the ringing voltage. Because the logic value that determines when to connect the
call depends on the reference voltage that goes into the comparator. For easy checking and
verification, we also added a LED to the output of the PIC, monitoring the clock input to the flip-
flop. The LED should blink at 1 Hz when the circuit is waiting for a call, and it should be turned
off when the call is connected.

4.2 DTMF Decoder
To test the DTMF decoder we attached LEDs to the outputs and the “new button pressed” signal.
Before connecting the circuit to the phone line we connected it to the speaker of a phone so that
we could just press the buttons on that phone to test the circuit. We used this method and made
sure that the proper value was outputted for the buttons that we pressed and that the “new button
pressed” signal went high every time we pressed a new button. When this worked, we connected
the circuit to the phone line and verified that circuit worked correctly when we actually called
our circuit and pressed buttons on the phone we called from.

4.3 Password Verification
To test the password verification circuit we connected switches to the input of the PIC to
simulate the outputs from the DTMF decoder. Then we attached LEDs to output pins so that we
could see what was stored in memory and make sure that the numbers we entered were being
stored correctly. Then we had an LED light up when the numbers entered matched the password
stored in memory.

4.4 Servo Controlled Lock
We first tested the code for controlling the servo without any password verification. We made
the PIC output the pulse lengths that we calculated from information in the datasheet to make
sure that it turned the lock to the correct angle. We then made sure the PIC is sending enough
pulses to finish turning the lock through the entire angle. Once this was finished we combined
the code for the password verification and the code for the servo. Then we tested the
combination with the switches (to simulate the output from the DTMF decoder) to make sure
that the servo turned the lock correctly depending on whether or not we entered the password
correctly and what two digit code we entered after the password.




                                                 7
                                         5. COST

5.1 Parts
Part                                Price     Qty    Total Price
PIC microcontroller 16F877A          $6.32     2          $12.64
Rectifier Diode D1N4002              $0.10     4            $4.00
Capacitors              470uF        $0.70     1            $0.70
                      0.01uF         $0.29     2            $0.58
                       0.1uF         $0.21     1            $0.21
Resistors               20kΩ         $0.09     1            $0.09
                       30kΩ          $0.09     1            $0.09
                       10kΩ          $0.09     1            $0.09
                       910Ω          $0.09     1            $0.09
                       120Ω          $0.09     2            $0.18
                         1kΩ         $0.09     2            $0.18
                       560Ω          $0.09     1            $0.09
                       56kΩ          $0.09     4            $0.36
                       47kΩ          $0.09     1            $0.09
                       68kΩ          $0.09     1            $0.09
                      150kΩ          $0.09     1            $0.09
                      330kΩ          $0.09     1            $0.09
                      100kΩ          $0.09     1            $0.09
Voltage Comparator LM339N            $0.50     1            $0.50
Potentiometer                        $1.30     2            $2.60
D Flip Flop 74LS175N                 $0.88     1            $0.88
Relay Switch                         $1.50     1            $1.50
20MHz Crystal Oscillator             $1.46     2            $2.92
Fast Switching Diode 1N4148          $0.10     3            $0.30
3.579545MHz Crystal Oscillator       $0.61     1            $0.61
Green LED                            $0.15     1            $0.15
Standard Servo                       $6.00     1            $6.00
Deadbolt Lock                       $15.00     1          $15.00

                                             TOTAL        $49.61

5.2 Labor
Labor: ($35/hr)*(200hr)*(2 people)*(2.5) = $35,000




                                             8
                                       6. CONCLUSIONS

6.1 Results
Every subsystem of the entire project functions correctly separately. The call pick up circuit can
be connected to the DTMF decoder, and they can pick up a call and output the key pressed as a 4
bit binary number. The password verification circuit can be connected to the servo controlled
lock and with the input password and a command, the deadbolt lock is able to turn either to lock
or unlock. The only problem with the project at this point is that the connection between the
DTMF decoder and the password verification circuit cannot be established. When the outputs of
the DTMF decoder are connected to the inputs of the password verification circuit, the PIC pulls
down the voltages of the outputs of the DTMF decoder. Therefore, even if the outputs are high,
it will appear to be low to the microcontroller when the two parts are put together. We tried
solving this problem by putting relay switches between VCC and the inputs of the PIC and let
the output of the DTMF decoder drive the relay switches. We also tried pull up resistors, op
amps, and even combinational logic. However, none of these were able to give us the desired
result.

6.2 Improvements
First of all we need to fix the connection between the DTMF decoder and the password
verification circuit because without it, the project cannot be considered complete. Secondly, it
would be desirable to add the ability to send information back to the user through the phone line.
This would enable the user to know the current state of the lock (locked or unlocked).

6.3 Future Work
This project can be utilized as a remote switch for anything in a household, not just for a lock. It
can be used to turn on and off lights or changing the temperature of the house. Also if the above
described feature of sending information back to the user is implemented, it will be useful to
know if the lights at home are currently on or off or the temperature reading on the thermostat.

6.4 Acknowledgements
We would like to thank Professor Swenson for good advice and ideas on this project; our TA,
Sarah, for all the help she has given us throughout the semester (even during thanksgiving break);
Mark Smart for the 2 PCBs he made (even though they did not work at the end due to our
soldering mistakes); Dan Mast for helping us pick a servo; Wally Smith for helping us locate
components in the part shop and looking for the phone number of the phone in the senior design
lab; and the ECE machine shop for connecting the servo to the lock.




                                                  9
                                       REFERENCES


[1] http://www.wire-your-phones.com/

[2] http://www0.fh-trier.de/~berres/Datenbl%E4tter/TEXAS/sloa067.pdf

[3] http://pdf1.alldatasheet.com/datasheet-pdf/view/77085/MITEL/MT8870.html

[4] http://www.siongboon.com/projects/2005-07-18_dtmf_circuits/

[5] http://www.pitt.edu/~sorc/robotics/Lukas%20PIC%20Tutorial.doc




                                            10
         APPENDIX – Figures




 Figure 1.1: Component Block Diagram




Figure 3.1: Call Pick up Circuit Schematic


                   11
 Figure 3.2: DTMF Decoder Schematic




Figure 3.3: Password Verification Flow Chart




                 12

				
DOCUMENT INFO