alternative house security system

49
Alternative House Security System By Jerry Shim Qi Zhao Rachit Saini Final Report for ECE 445, Senior Design, Spring 2014 TA: Michelle Ansai 5 May 2014 Project No. 21

Upload: others

Post on 05-Dec-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Alternative House Security System

By

Jerry Shim

Qi Zhao

Rachit Saini

Final Report for ECE 445, Senior Design, Spring 2014

TA: Michelle Ansai

5 May 2014

Project No. 21

Abstract

Our team designed and fabricated an alternative, keyless home security system that is suitable to many residents’ budgets. Our system uses four types of identification which verifies the user before activating the lock. As our first design, we created a security system for only one occupant where the calibration of the pass-code and identification information is also possible.

i

Contents 1. Introduction ............................................................................................................................................. 1

1.1 Purpose ................................................................................................................................................ 1

1.2 Functions and Features ....................................................................................................................... 1

1.2.1 Functions ...................................................................................................................................... 1

1.2.2 Benefits ........................................................................................................................................ 1

1.2.3 Features ........................................................................................................................................ 1

1.3 Block Diagram .................................................................................................................................... 2

1.4 Block Descriptions .............................................................................................................................. 2

1.4.1 Power Supply ............................................................................................................................... 2

1.4.2 Doorknob Vibration Detection Module ....................................................................................... 3

1.4.3 Weight Detection Module ............................................................................................................ 3

1.4.4 Height Detection Module ............................................................................................................. 3

1.4.5 Eye-blink Detection Module ........................................................................................................ 4

2. Design ....................................................................................................................................................... 4

2.1 Power supply ....................................................................................................................................... 4

2.2 Doorknob ............................................................................................................................................ 5

2.2.1 Vibration Sensor Circuit .............................................................................................................. 5

2.2.2 Impulse Detection Circuit ............................................................................................................ 6

2.2.3 Counter (4-Count) Circuit ............................................................................................................ 7

2.2.4 Comparison/Calibration Circuit ................................................................................................... 8

2.2.5 555 Timer Clock .......................................................................................................................... 8

2.3 Weight Detection ................................................................................................................................ 9

2.3.1 Weight Scale ................................................................................................................................ 9

2.3.2 Amplifier Circuit .......................................................................................................................... 9

2.3.3 Microcontroller .......................................................................................................................... 10

2.4 Height Detection ............................................................................................................................... 10

2.4.1 IR Obstacle Detection Sensors ................................................................................................... 10

2.4.2 555 Timer Clock ........................................................................................................................ 10

2.4.3 Counter ....................................................................................................................................... 10

2.4.4 DFF and MUX ........................................................................................................................... 11

2.4.5 Switches ..................................................................................................................................... 11

ii

2.5 Eye-Blink Detection Module ............................................................................................................ 12

3. Design Verification ................................................................................................................................ 12

3.1 Doorknob Module ............................................................................................................................. 13

3.1.1 Vibration Detection Circuit ........................................................................................................ 13

3.1.2 Impulse Detection Circuit .......................................................................................................... 14

3.1.3 Counter Circuit ........................................................................................................................... 14

3.1.4 Comparison/Calibration Circuit ................................................................................................. 14

3.2 Weight Module ................................................................................................................................. 14

3.3 Height Detection Module .................................................................................................................. 15

3.3.1 Power ......................................................................................................................................... 15

3.3.2 IR Obstacle sensors .................................................................................................................... 15

3.3.3 555 Timer Clock ........................................................................................................................ 15

3.3.4 Counter ....................................................................................................................................... 15

3.3.5 DFF and MUX ........................................................................................................................... 15

3.3.6 Switch memory .......................................................................................................................... 15

3.4 Eye-Blink Detection Module ............................................................................................................ 16

3.4.1 Eye-Blink Detection Sensor ....................................................................................................... 16

3.4.2 JK flip-flop ................................................................................................................................. 16

3.4.3 Counter and SR latch and NAND gate ...................................................................................... 16

3.4.5 Clock .......................................................................................................................................... 16

3.4.6 Shift register ............................................................................................................................... 16

4. Cost Analysis ......................................................................................................................................... 17

4.1 Labor ................................................................................................................................................. 17

4.2 Parts .................................................................................................................................................. 17

4.3 Grand Total ....................................................................................................................................... 18

5. Conclusion ............................................................................................................................................. 18

5.1 Accomplishment ............................................................................................................................... 18

5.2 Ethical Considerations ...................................................................................................................... 18

5.3 Future Work/Alternatives ................................................................................................................. 18

5.4 Failure Mode ..................................................................................................................................... 19

5.5 Safety ................................................................................................................................................ 19

References .................................................................................................................................................. 20

Appendix A - RV Table ............................................................................................................................ 21

iii

Appendix B - Arduino Code ..................................................................................................................... 40

iv

1. Introduction We were able to build a practical, keyless security system for a home of a single resident. The system was made to be conveniently used by the user. Using four modules for identification, our design should successfully provide a secure system for any average house entrance.

1.1 Purpose Our project is an alternative, personal home security system that require nothing but the residents themselves to activate the lock and enter their home. This system will also prevent the users from being locked out if they forget to grab their keys before they leave. Moreover, this system will be able to replace other expensive (biometric) security methods used for a residential home. Other keyless, security systems in the market like iris recognition, fingerprint recognition, voiceprint recognition, and even keypads are too expensive to be used widely, and we hope change that with the existing technology we have available today.

1.2 Functions and Features Goal - To make a low-cost, keyless security system that only requires the actual user(s) for identification.

1.2.1 Functions The security system will consist of four identification modules that will be used to verify the resident before activating the lock.

● Doorknob vibration detection ● Height detection ● Weight detection ● Eye-blink detection ● Unlocking the door if all identifications match

1.2.2 Benefits ● Easy to use/perform and calibrate ● Lower cost than other keyless, biometric ID methods

1.2.3 Features The following features will help the identification process simple and convenient for the users:

● IR obstacle detection sensors ● Wire connections between modules ● LED indication ● Sound indication ● Switches to calibrate ● Door lock Simulator

1

1.3 Block Diagram

Figure 1 Block Diagram for the Whole Project

1. Start signal 2. Power and clock from MCU 3. Parallel load from shift register of door knob circuit and verification 4. Power and clock from MCU 5. Parallel load from shift register of weight detection circuit and verification 6. Power and clock from MCU 7. Parallel load from shift register of height detection circuit and verification 8. Power and clock from MCU 9. Parallel load from shift register of eye-blink detection circuit and verification 10. Signal for unlocking the door

1.4 Block Descriptions

1.4.1 Power Supply The power supply provides a constant 5V-DC to the whole security system. This voltage will be converted from a 120V-AC power adapter that will be connected to a normal house outlet. We need to use a power supply that will not die, so batteries won’t be sufficient for this system.

2

1.4.2 Doorknob Vibration Detection Module

Figure 2 Block Diagram of the Doorknob Vibration Detection Module

The Doorknob Vibration Detection Module uses a vibration detection circuit to detect vibrations made from the “jiggling” of the locked doorknob. The vibrations are detected as impulse signals by the impulse detection circuit. The impulses will be used as a 4-bit sequence (0s for no vibrations made, 1s for vibrations made) using the 4-count circuit. The sequence will be stored and compared with the calibrated values in the calibration/logic circuit. After the 4-bit sequence match has been confirmed, it will send a pass/HIGH signal to the microcontroller.

1.4.3 Weight Detection Module

Figure 3 Block Diagram of the Weight Detection Module

The Weight Detection Module will start with the weight scale which will “read” the weight from the person by the load sensors. The weight will be interpreted as a small voltage value signal that will be amplified by the amplifier circuit. The amplified voltage signal will then be passed to the MCU to be compared to the stored/calibrated value which will output a HIGH signal to the next module if the match has been verified.

1.4.4 Height Detection Module

Figure 4 Block Diagram of the Height Detection Module

3

The Height Detection Module is used to detect the height of the user and then compare to the data which is mechanically stored in the switches, and send a HIGH or LOW signal to the microcontroller according to the user’s height. This Module consists 8 IR obstacle sensors, a counter, a MUX, D flip-flops, and other TTL chips which include XOR, AND and NOT gates. The sensors are used to detect the height and the rest of the circuits are logic circuits which is used to compare the height.

1.4.5 Eye-blink Detection Module

Figure 5 Block Diagram of the Eye-blink Detection Module

On receiving the signal from height detection circuit, the microcontroller activates the eye blink detection circuit and glows an LED to indicate the same. The eye needs to be placed at the adequate distance from eye blink detection sensor. In order to ensure this, we use two additional sensors with buzzers. These buzzers beep if the face of the user is either too far or too close to the sensor. A buzzer associated with the clock for eye blink detection circuit starts beeping after a certain delay to indicate passing of the code by blinking the eye in response to the beeps that continue for 8 seconds. The code is a 4-bit sequence. The eye-blink passes as value ‘1’ and no blink passes as value ‘0’. After that, the code passed into the sensor is compared with the code stored using the switches to power (4.75V - 5.25V) and ground. If there is a match, the door unlocks, otherwise, the system shuts down.

2. Design Our design consisted of five main parts including the Power Supply, Doorknob Vibration Detection Module, Weight Detection Module, Height Detection Module, and Eye-blink Detection Module. These parts were used for identifying the resident. We created a security system that verified only one user for this project. A calibration system was also created where the person could easily pre-set their identification information including 4-bit sequences code for doorknob & eye-blink module, the weight, and the height.

Note: The design for Doorknob Module and Eye-blink Module are similar.

2.1 Power supply

Figure 6 Schematic for Power Supply Using 7805 Voltage Regulator

4

A 120 V-AC to 9V-DC power adapter was used as a power supply. We then used a 7805 voltage regulator to bring the voltage down from 9V to 5V DC. The power supply provides a power source for each module used in our project. The power supply will be turned on when the user presses a “start button” to start the system. Figures 1 and 2 show the components we used to create our actual power supply.

Figure 7 & 8 120V-ac to 9V-dc adapter with 9V to 5V Voltage Regulator

2.2 Doorknob After the user presses the switch to start the system, an LED glows to indicate that the doorknob circuit is activated and ready for detection. This module consists of four main parts including the Vibration Sensor Circuit, the Impulse Detection Circuit, the 4-Count Counter Circuit, and the Comparison/Calibration Circuit which will be necessary to identify the user. It takes in a 4-bit sequence of 1s and 0s from the user and uses it to compare with a pre-set/stored value. If the identification of this module verifies a match between the stored 4-bit sequence and the inputted 4-bit sequence, it will send a “HIGH”/1 signal to activate the next module (weight module).

2.2.1 Vibration Sensor Circuit

Figure 9 Doorknob Vibration Sensor Circuit with Calculations [1]

5

The vibration of turning/ “jiggling” the locked doorknob will be detected by the vibration circuit (Figure 9). The piezo speaker acts as a vibration sensor and the circuit will output a “HIGH”/1 if it detects a vibration, and a “LOW”/0 if it doesn’t. The 1M ohm potentiometer was adjusted to 0.5M ohms / 0.5M ohms giving the non-inverting input (V+) of the op-amp a threshold of 2.5V so that the piezo speaker will be able to detect and tolerate a normal turn/ “jiggle” of the locked door handle of an average person (see calculations above). When a vibration is made, the resistance of the piezo speaker is around 6M ohms and provides about 1.97V to the inverting input of the op-amp (V-). Since V+ (2.5) is greater than V- (1.97V), the vibration circuit outputs a Vout = 5V, indicating that a vibration was detected. On the other hand, if no vibration was made, the resistance of the piezo speaker is around 0.9M ohms and provides about 4.06V to V-. Since V+ (2.5V) is less than V- (4.06V), the vibration circuit outputs Vout = 0V. The Vout signal is then passed on to the Impulse Detection Circuit.

2.2.2 Impulse Detection Circuit

Figure 10 Impulse Detection Circuit

Figure 11 Impulse Detection Simulation

6

This circuit consists of a JK flip-flop, and a 4-bit shift register. The JK flip-flop has inputs taken from an inverted 0.5 Hz (one second for HIGH and one second for LOW) clock signal and the Vout from the vibration circuit. During the high level clock signal, this gives a “LOW”/0 to the K input of the flip-flop. This is when a vibration will be made and the corresponding signal will be fed into the J input of the flip-flop. According to a JK flip-flop behavior (truth table), when the K is a LOW (inverted high level clock signal) whatever the J input is (HIGH/LOW), the flip-flop reads the value. Then, when the K input goes to a HIGH, the flip-flop temporarily holds the value read from the J input. The same inverted clock signal is given to the 4-bit shift register which “registers” the output from the JK flip-flop and shifts in the value to the last bit using the right shift feature when the clock signal goes from LOW to HIGH. Just when the register shifts in the value from the flip-flop, the flip-flop is ready to take in the new signal from the vibration circuit and start the process over again. Figure 10 shows the Impulse circuit and Figure 11 shows the impulse signal (“jiggle” from the doorknob) being made during a high level clock signal and being shifted in by the 4-bit shift register starting from Q[3] to Q[0].

2.2.3 Counter (4-Count) Circuit

Figure 12 Counter for 4-bit Storage Circuit

Figure 13 Counter for 4-bit Storage Simulation

7

The Counter Circuit provides 4 counts to the Impulse Detection Circuit. The doorknob rotation/ “jiggle” should happen with the corresponding “beep” sound that indicates when the clock goes from low to high. This process happens for 4 counts with 4 “beeps” to record a 4-bit sequence from the user. Rotating the doorknob stores the binary value “one” in the shift register and the absence of rotating stores the value “zero” in the shift register of the Impulse Detection Circuit during each “beep” sound. The Counter Circuit uses a counter and a logic that resets the counter when it counts up to 4 using the same clock (but not inverted) given to the Impulse Detection Circuit. The Counter Circuit also uses an SR latch that temporarily pauses the counter when the signal of the fourth count is given to the S input. It resets the count over again when the R input of the SR latch is switched from LOW to HIGH. The multiplexer is used to choose between the clock signal and LOW signal which will be given to the Impulse Detection Circuit. During the 4 counts, the MUX will provide the clock signal and at the fourth count, it will provide a LOW signal to the Impulse Detection Circuit to stop it from taking in any more inputs from the user. The circuit and simulation shown in Figures 12 and 13 show the counting of four seconds and pausing in order to store a 4-bit binary sequence for the shift register. This circuit controls the clock signal that will be fed into the shift register so it only reads and stores a 4-bit value. The simulation shows the counting of four counts of the counter and then pausing. After the reset signal is triggered, the counter counts up to four again. The pausing of the counter is done by using an SR-latch to hold the value of the reset when the counter counts to the binary value “0100” (four). The R-input of the SR-latch needs to be reset to zero to reset the counter to count again and take in a new set of 4-bit binary sequence.

2.2.4 Comparison/Calibration Circuit The final 4-bit binary value stored in the shift register (figure 6) is then compared with the value stored in the 4-bit DIP switch in the Comparison/Calibration Circuit. XNOR gates were used to compare each bit from the user and the DIP switches. The all the bits were the same, then a 4-input AND gate was used to indicate a match. This acted as an activation signal “high/1” to the weight detection module.

2.2.5 555 Timer Clock The 555 timer is used to output a 0.5 Hz signal, which is used as a clock to the counter. The value and layout of the timer is shown in the figure below.

Figure 14 555 Timer Using 0.5 Hz clock [2]

8

2.3 Weight Detection As soon as the Weight Detection Module receives the activation signal, an LED glows to indicate the activation of weight detection circuit. This module was made using three parts, a weight scale, an amplifier circuit, and the microcontroller.

2.3.1 Weight Scale

Figure 15 Weight scale

First, the weight scale is used to obtain the weight of the user. This was done by using the load sensors of the weight scale which outputted a certain voltage around .1mV to .7mV depending on the weight of the user.

2.3.2 Amplifier Circuit

Figure 16 Weight Detection Circuit

Next, the mV voltage value was passed into the amplifier circuit. This part of the circuit is mainly built using the instrumentation amplifier (AD620 chip). Since the mV voltage readings is too small to be detected by the microcontroller, this amplifier circuit amplifies the voltage signal so it can be detected and used for comparison. The instrumentation amplifier chip we used followed a formula for voltage gain based on the value of Rg used which is shown below:

9

Using this, we chose Rg around 150 ohms which amplified the .1mV to .7mV voltage signal to about 3.3V to 3.9V. This voltage was large enough to send to the microcontroller and be detected from the varying voltage due to the varying weight.

2.3.3 Microcontroller The value from the amplifier circuit is taken in and read as analog signal (“sensorValue”) with the microcontroller. The signal variation has a resolution of 10 bits (1024 pixels). This is converted back to a voltage signal by taking the analog value and multiplying by (5/1023). The result gave us a similar voltage value we read from the amplifier circuit. Next, the weight/voltage value was taken from a “user” by measuring the voltage value when the person stood on the scale. Knowing the value, the parameters were set by declaring that if a value between two threshold voltage values was read from the amplifier circuit, output a “HIGH”/1 signal. We set a low and high limit cutoff of about ±5 lbs around the captured value to compare the values in 1 pound increments within the range to the value set in the microcontroller. The output signal outputted an activation signal to the next module (height module) if there was a match between the user’s weight input and the pre-set threshold values.

2.4 Height Detection On receiving the activation signal, the LED glows to indicate the activation of height detection circuit. It will detect the height using 8 sensors within about 4 seconds. The reason to have a delay of 4 seconds is that we want the user to have more time to prepare. The clock of this module is 1 Hz. If the height detected matches the height value stored in the switches, the microcontroller will give an activation signal to eye blink detection circuit. If there is no match or the height is not detected at all, the system will not proceed to the next stage. This module will be activated only if resident passes the weight detection (the pass signal is sent from microcontroller to height detection circuit). Figure 17 below shows the schematic of height detection module with one sensor only.

2.4.1 IR Obstacle Detection Sensors The 8 obstacle detection sensors are used as the detection input to the height detection module. The sensors are purchased online. Ideally, the spacing between each sensor is 3.75 cm, however, due to the limitation of the space, we put all 8 sensors in a line on the vector board. The sensors will output a “low/0” signal when they are blocked, and output a “high/1” signal otherwise. The output of sensors goes to MUX DFF unit.

2.4.2 555 Timer Clock The 555 timer is used to output a 1 Hz signal, which is used as a clock to the counter. The layout of the timer is the same as shown in section 2.2.5. The value of resistors are 5.1 K Ohms and 150 K Ohms. The capacitor has a value of 4.7 uF.

2.4.3 Counter The 4-count unit is the same as the 4-count unit in section 2.2.3. The output will be high only on the 4th high rising edge of the clock, which is the 4th second. The output of the counter goes into MUX as the select signal. So the MUX will only select the input from sensor after 4 seconds of the start of this

10

module.

2.4.4 DFF and MUX DFF and MUX unit is used to select the value from sensor and then hold the value if there is a “high/1” signal from the sensors. MUX will invert the input, if the input is a “low/0”, the output will be a “high/1”. So when the sensors are covered, the output from the MUX is a “high/1”, which matches the signal we want to compare using switches.

2.4.5 Switches Switches is the second input to XOR gates. The role of the switches is memory. By closing the switches (close switch means set that value to “high/0”), we can set the desired height for the system to detect.

Figure 17 Height Detection Circuit (with one sensor only)

Figure 18 Height Detection (with one sensor only) Simulation

The simulation shown in figure 18 shows that one of the height sensors detects a signal from the user and compares it to the stored value in memory. In the red circle we can clearly see that when a “high/1” value

11

is detected and is compared to a “high/1” value in memory, the output shows a “high/1” when the counter counts to “4”. Before the counter counts to “4”, even if the sensor value matches the values in the memory, the output stays low. This is the same case when a “low/0” signal is read and matches with the “low/0” signal in memory.

2.5 Eye-Blink Detection Module

Figure 19 Sensors and buzzers for Eye-Blink detection

2.5.1 Eye-blink Distance Circuit The figure above shows three IR sensor units along with two buzzers and NOT gate. The first sensor (which is covered with paper and tape) is used to detect whether the user is too far or in the range for eye-blink detection. It is connected to a buzzer through NOT gate. It beeps when the user is too far away from sensing range. The third sensor is used to detect whether the user is too close or in the range for eye-blink detection. It is directly connected to the buzzer. It beeps when user is too close to close to the sensor. The second sensor detects the eye-blink for which eye should be placed directly above that sensor. User needs to make sure that the sensors in line are directly below forehead, eye and cheek respectively. The output from the second sensor is given to eye-blink capture circuit after passing it through NOT gate.

2.5.2 Impulse Detection Circuit (see section 2.2.2)

2.5.3 Counter (4-Count) Circuit (see section 2.2.3)

2.5.4 Comparison/Calibration Circuit (see section 2.2.4)

3. Design Verification Each individual module was tested for their functionality using equipment available in the Senior Design Laboratory. The Requirements and Verification Table can be found in Appendix A.

12

Figure 20 Oscilloscope Showing 5.39V for Vcc

3.1 Power Supply The power supply provides a 5V to the whole circuit. All modules require 5V to power the components for each respective circuit.

3.1.1 Power for Doorknob Module The Doorknob Module required a voltage of 4-6V to function properly. A voltmeter was used to measure 5.39V for Vcc. This verified that the circuit was properly receiving sufficient power.

3.1.2 Power for Weight Module The Weight Module required a voltage of 4-6V to function properly. A voltmeter was used to measure 5.39V for Vcc. This verified that the circuit was properly receiving sufficient power.

3.1.3 Power for Height Module The Height Module required a voltage of 4-6V to function properly. A voltmeter was used to measure 5.39V for Vcc. This verified that the circuit was properly receiving sufficient power.

3.1.4 Power for Eye-blink Module The Eye-blink Module required a voltage of 4-6V to function properly. A voltmeter was used to measure 5.39V for Vcc. This verified that the circuit was properly receiving sufficient power.

3.2 Doorknob Module The requirement for the Doorknob Vibration Detection Module was to detect a locked doorknob vibrations created from the “jiggling” of the door handle. The module should take a 4-bit sequence from the user and output a HIGH signal to power the next module if the 4-bit sequence of the input and stored/calibrated value match.

3.2.1 Vibration Detection Circuit The Vibration Detection Circuit was verified by performing multiple tests and taking measurements with the voltmeter. Start signal – First, we made sure the activation signal from the start switch was given by verifying the voltage value fell between 4-6V. We measured around 4.98V as the activation signal from the start switch

13

and this showed that the Vibration Detection Circuit was able to receive power from the power supply of 5V. Piezo speaker – We needed the piezo speaker to output 3-5V when vibration was made and 0-2V when no vibration was made. Using a voltmeter, ~4.2V was read with vibration and ~0.3V was read with no vibration. Vibration Circuit Output – In order for the 4-bit shift register to register a HIGH signal, the output of the vibration circuit needed to be above 1.06V. Using a voltmeter, we measured the output to be ~4.2V which was sufficient for the shift register to read the value.

3.2.2 Impulse Detection Circuit This part of the circuit need to detect and record an impulse signal from the vibration of the doorknob made by the user. JK flip-flop – The JK flip-flop logic needed to follow the behavior (truth table) shown in Appendix A. It required 4-6V for a HIGH signal, and -0.3-0.3V for a LOW signal. The voltmeter verified that a HIGH signal of 4.98V was measured and a LOW signal of 0.2V was measured. 4-bit Shift Register – The register required at least 1.06V to detect a HIGH signal. Using a voltmeter and LEDs, providing a voltage above 1.06V to the shift register input gave us a HIGH signal of 4.98V and allowed the LED light to glow. This showed that the register was working properly.

3.2.3 Counter Circuit The Counter Circuit required four counts for each 4-bit sequence inputs. Counter logic – Using a 0.5Hz clock signal, the 74193 counter chip with a combination of inverters and NAND gates needed to count up to four counts (00-01-10-11) and reset. LEDs lights were used to see the binary representations of each count. We verified that the circuit counted up to four counts and reset after the fourth count by seeing the following sequence of LED glowing (00-01-10-11) where 1-glow and 0-no glow.

3.2.4 Comparison/Calibration Circuit DIP switch was used for the setting up the 4-bit sequence that the user was going to use to match the inputted sequence with. This calibration and comparing circuit outputted a HIGH activation signal of 4-6V needed for next module, if there was a match between the 4-bit sequence inputted value and calibrated switch value. We verified a HIGH signal of 4.98V was outputted when there was a match using a voltmeter.

3.3 Weight Module

Figures 21 & 22 Output from the Weight Scale & Output of amplifier circuit with load (~0.9mV to

~3.3V)

14

The weight module needed to read the weight of the user and convert it into voltage using 8-10 bits that would be done by the microcontroller in the Arduino. The voltage would then be compared with the pre-set allowed range and output a HIGH activation signal of 4-6V if the values of the voltage from the user and the pre-set value were a close match. This was verified by having a person stand on the weight scale and recording the value of the user that was automatically converted into voltage by the microcontroller. We then pre-set the range for allowed value to be read from the weight scale. We created a statement using the Arduino that would outputted a HIGH 4.98V signal when the values were a close match using a voltmeter. An LED was also use to indicate there was a match by glowing when the user stepped on the scale and stopped glowing when the person either stepped off or added more weight on the scale.

3.4 Height Detection Module The requirement for the Height Detection Module is that if the blocked sensors match the data in the switch, the output of the circuit should be a HIGH and the system go to the next stage (Eye-blink Detection). If the sensors blocked do not match the memory in the switch, the output is LOW and the system does not go to the next stage. In the demo, our circuit accomplished this requirement. So that every component in this module is working properly.

3.4.1 Power The power to the module is around 5 V dc, within 1V of tolerance. The measurement is taken by oscilloscope.

3.4.2 IR Obstacle sensors When the sensor is blocked, the output is near 0 V. When it is not blocked, the output is 4.75-5.25 V (logic HIGH). The measurement is taken by oscilloscope.

3.4.3 555 Timer Clock The clock output is near 1Hz. The measurement is made by the oscilloscope. Either by reading the time on x-axis or count by a watch. Both methods lead to a close to 1Hz clock signal.

3.4.4 Counter The output of the counter is connected to an oscilloscope. In the requirement, the output should be high for 1 second in every 4 seconds. There are two ways to verify this, the first one is to change the scope and see the waveform goes high in one fourth of one cycle. The other method is to use a watch to count the time. Both methods prove the clock works as designed.

3.4.5 DFF and MUX The output of the MUX and DFF unit should be the same as the sensor output in one second for every 4 seconds. First, we cover the sensor and then wait for 4 seconds to see if the output goes high. The measurement is taken by oscilloscope. The test shows every time a sensor is blocked, the output from DFF will be high for one second in every four second period.

3.4.6 Switch memory The switches are connected to Vcc so the output should be high when closed. The multi-meter is used to verify the switches. When the switches are closed, the output is 4.75-5.25V from 8 switches. When the switches are open, the voltage is low (around 0 V). So the switch unit works.

15

3.5 Eye-Blink Detection Module The requirement of Eye-Blink Detection module is that if the code passed through eye-blink into the sensor is correct, then, the activation signal for unlocking of door should be given by the microcontroller.

3.5.1 Eye-Blink Detection Sensor The Eye-Blink Detection Sensor outputs LOW voltage (0V - 0.4V) when the user’s face is within the sensing distance and HIGH voltage (4.75V - 5.25V) when the user’s face is too far away from the sensors. This was confirmed by seeing the signal values on the oscilloscope.

3.5.2 JK flip-flop The JK flip-flop takes in the value at J input when K input value is LOW. This was confirmed by seeing the output of JK flip-flop on the oscilloscope and providing the J input.

3.5.3 Counter and SR latch and NAND gate The output of the counter should result in HIGH signal (4.75V - 5.25V) at the input of SR latch and the SR latch output should also become HIGH. This was confirmed using the oscilloscope.

3.5.5 Clock The clock signal should have frequency 0.5 Hz (within 0.1 Hz tolerance). This was confirmed by seeing the clock signal on oscilloscope.

Figure 23 Oscilloscope Simulation for 0.5Hz Clock Signal

3.5.6 Shift register The bits should shift into the shift register serially towards right with each clock cycle. This was confirmed by putting the LEDs and resistors at the output of the shift register output pins.

16

4. Cost Analysis

4.1 Labor Table 1: Cost of Labor

Name Hourly Rate ($/hr)

Total Hours Invested Total = Hourly Rate X Total Hours Invested X 2.5

Jerry Shim $30.00 160 $12,000.00

Rachit Saini $30.00

160 $12,000.00

Qi Zhao $30.00 160 $12,000.00

Total 480 $36,000.00

4.2 Parts Table 2: Cost of Parts

Item Part Number Quantity Unit Cost ($) Cost ($)

LED’s COM-00533 10 0.35 3.50

Obstacle Sensors 20 4.90 98.00

Phototransistor MRD360 1 3.67 3.67

IR Sensor COM-09349 1 0.95 0.95

Microcontroller ATmega2560 1 18.00 18.00

Timer NE555 1 0.30 0.30

Resistors, capacitors and diodes

0.00 0.00

Buzzer COM-07950 3 1.95 5.85

Power supply (7805 regulator, adapter)

1 5.00 5.00

Weight Scale 1 20.00 20.00

Total 155.27

17

4.3 Grand Total Table 3: Grand Total

Section Cost ($)

Labor($) 36,000.00

Parts($) 155.27

Total 36,155.27

5. Conclusion

5.1 Accomplishment In this project, we successfully build a system which can detect doorknob vibration, weight, height and eye-blink. The system can compare the data obtained from above detection and compare to the memory, and then react accordingly. The whole project and each module satisfy the requirement from RV table in Appendixes.

5.2 Ethical Considerations According to the IEEE Code of Ethics we promise to consider and commit our project with these particular standards during the design and implementation of our project [3]:

1. to accept responsibility in making engineering decisions consistent with the safety, health and welfare of the public, and to disclose promptly factors that might endanger the public or the environment; Since our project is about home security, so it is very important for us to design the project with as less error as possible. If the system breaks down, the residents may be put in danger. 7. to seek, accept, and offer honest criticism of technical work, to acknowledge and correct errors, and to credit properly the contributions of others; The project will have errors, and it is our responsibility to correct the errors as fast as possible and inform all the people who involved in this project about the errors. 9. to avoid injuring others, their property, reputation, or employment by false or malicious action; This project involves electricity and need the user to directly contact with the doorknob, which is a conductor of electricity. As a result, there is a possibility that the user will be shocked by the electric. We need to design our project with full concern of safety issues and think about ways user may be put in danger by using this product.

5.3 Future Work/Alternatives The Eye-blink detection module can’t accurately detect the eye-blink for everyone. By calibrating, the sensor can detect the eye-blink of members in our team very easily, because our skin and eye color is similar. However, it is harder to detect Prof. Carney’s blink in the demo. In the future, we can use a camera and DSP to detect eye-blink, instead of IR sensors.

18

5.4 Failure Mode As a security system, the probability of our project to fail is calculated using probability theory. Since each module is independent, we can multiply the failing rate of each module together to come up with the failing rate of the whole system. For height detection, there are 8 ways to input the height so the probability is 1/8. For eye blink since its 4-bit binary code, so its probability is 1/16. Same thing for doorknob. For weight since it is 10-bit binary, so the probability to crash is 1/1024. Multiply all the above numbers together we get 0.000047 %.

5.5 Safety For our project, our biggest concern for safety is the damage to eyes from the emission of IR sensors [4]. If the forward current of the sensor is less or equal to 60 mA, the radiation intensity is less or equal to 20 mW per steradian. If the intensity is less than 20 mW per steradian, the radiation is no harm to human eye. In addition, the doorknob will be grounded to prevent user from electric shock.

19

References [1] Mims III, Forrest M. "Forrest M. Mims III: Vibration Sensor Kit." Simple Vibration Sensor with No

Moving Parts. N.p., n.d. Web. 16 Mar. 2014. <http://www.jameco.com/Jameco/pressroom/recipe4.html>.

[2] Jeff. "House of Jeff." 555 Timer Calculator. N.p., 13 Mar. 2013. Web. 07 May 2014.

<http://houseofjeff.com/555-timer-oscillator-frequency-calculator/>. [3] "IEEE Code of Ethics." IEEE. IEEE, n.d. Web. 06 May 2014.

<http://www.ieee.org/about/corporate/governance/p7-8.html>. [4] Earman, Allen. "Eye Safety for Proximity Sensing Using Infrared Light-Emitting Diodes." Intersil

(2012): 1-11. Web. 6 Mar. 2014. <http://www.intersil.com/content/dam/Intersil/documents/an17/an1737.pdf>.

20

Appendix A - RV Table Power supply:

Requirements Verification Verification status (Y or N)

1. Power supply gives an output of 5±1 V

1. Test the power supply output a) Connect multi-meter negative connector to negative connector of the power supply (black) b) Connect multi-meter positive connector to positive connector of the power supply (red) c) Read voltage- it should be in the range 4-6V

Y

2. Vcc for Doorknob module is 5±1 V

2. Test the Vcc of Doorknob module a) Connect multi-meter negative connector to negative connector of the common ground(black) b) Connect multi-meter positive connector to positive connector of the Vcc (red) c) Read voltage- it should be in the range 4-6V

Y

3. Vcc for Weight detection module is 5±1 V

3. Test the Vcc of Weight detection module a) Connect multi-meter negative connector to negative connector of the common ground(black) b) Connect multi-meter positive connector to positive connector of the

Y

21

Vcc (red) c) Read voltage- it should be in the range 4-6V

4. Vcc for Height detection module is 5±1 V

4. Test the Vcc of Height detection module a) Connect multi-meter negative connector to negative connector of the common ground(black) b) Connect multi-meter positive connector to positive connector of the Vcc (red) c) Read voltage- it should be in the range 4-6V

Y

5. Vcc for Eye-blink detection module is 5±1 V

5. Test the Vcc of Eye-blink detection module a) Connect multi-meter negative connector to negative connector of the common ground(black) b) Connect multi-meter positive connector to positive connector of the Vcc (red) c) Read voltage- it should be in the range 4-6V

Y

6. Vcc for microcontroller is 5±1 V

6. Test the Vcc of microcontroller a) Connect multi-meter negative connector to negative connector of the common ground(black) b) Connect multi-meter positive connector to positive connector of the Vcc (red)

Y

22

c) Read voltage- it should be in the range 4-6V

Doorknob Module:

Requirements Verification Verification status (Y or N)

Vibration Sensor Circuit:

1. Signal from start switch is 5 ±1V.

2. The vibration sensor/piezo speaker reads between 3-5V when the doorknob is turned and between 0-2V when the doorknob is not turned.

3. Make sure the output of the vibration sensor circuit (pin 6) reads above 1.06V (up to 5V) when a vibration is made in order to detect a “high/1” digitally.

1. Measure to see if the activation signal from the start button was pressed by the user.

a) Using a voltmeter, ensure that the voltage received by the start button when pressed is between 4-6V.

2. Measure the voltage across the piezo speaker/vibration sensor.

a) When the doorknob is turned (vibration is made), using a voltmeter, ensure that the voltage read is between 3-5V.

b) When the doorknob is not turned (no vibration is made), using a voltmeter, ensure that the voltage read is between 0-2V.

3. Measure the output signal of the vibration sensor circuit (pin 6).

a) When the vibration is made through the sensor, using a voltmeter, make sure that the output signal reads a voltage above 1.06V (up to 5V). This

Y

Y

Y

23

is the threshold of the IC chips and will ensure that the “high/1” signal will be detected digitally.

JK Flip-Flop:

1. The JK flip-flop behaves correctly according to the truth table:

J-input

K-input

Output

0 0 Q

0 1 0

1 0 1

1 1 Q’

(where 0 = 0 ±0.3V, 1 = 5 ±1V, Q = previous value, and Q’ = opposite of previous value)

1. Measure the output values of the JK flip-flop when the appropriate input values of J and K are given:

a) Measure the output voltage first. Then, when inputting a voltage of -0.3V to 0.3V for both J and K inputs, using a voltmeter, ensure the output voltage of -0.3 to 0.3V is measured if this is what was measured previously and 4-6V is measured if this is what was measured previously.

b) When a voltage of -0.3V to 0.3V is inputted for J and 4-6V is inputted for K, using a voltmeter, ensure that the output voltage of -0.3 to 0.3V is measured.

c) When a voltage of 4-6V is inputted for J and -0.3V to 0.3V for K, using a voltmeter, ensure that the output voltage of 4-6V is measured.

d) Measure the output voltage first. Then, when inputting a voltage of 4-6V for both J and K inputs,

Y

24

using a voltmeter, ensure the output voltage of -0.3 to 0.3V is measured if 4-6V was measured previously and 4-6V is measured if -0.3V to 0.3V was measured previously.

Storage Register:

1. The 74194 shift register chip records a “high/1” (5 ±1V) when a voltage above 1.06V is inputted (up to 5V) and a “low/0” (0 ±0.3V) when a voltage of 0 (up to 1.05V) is inputted at rising clock edge of signal.

1. See that the register records/registers a high and low inputs.

a) Using an LED connected to the output of the register, makes sure that when a voltage of 1.06-5V is shifted in, the LED of the most significant output bit glows. If measured by a voltmeter, ensure this voltage is 4-6V.

b) Using an LED connected to the output of the register, make sure that when a voltage of 0-1.05V is shifted in, the LED of the most significant output bit does not glow. If measured by a voltmeter, ensure this voltage is -0.3V to 0.3V.

Y

Counter Circuit:

1. The 74193 counter counts up using 4-bit binary representation: (0000, 0001, 0010, 0011, 0100…) where 0

1. Check the LEDs connected to each of the 4 outputs of the counter.

a) Connect 4 LEDs to each of the 4 output bits

Y

25

= LED glows and 1 = LED doesn’t glow.

2. The counter circuit counts (using a 0.5 Hz clock signal) up to 4 counts and stops counting in order to store a 4-bit binary sequence (e.g. 0110).

of the counter and make sure they count in an ascending order using 4-bit binary representation.

2. Make sure the 4-bit sequence (e.g. 0110) is correctly stored in the register.

a) Choose a 4-bit binary data to store like “0110”.

b) Connect a function generator that generates a slow (0.5 Hz) square wave to the 74194 register and the 74193 counter to make them function in sync.

c) On the rising edge, input a voltage of 1.06-5V for a “1” and 0-1.05V for a “0” binary representation of the 4-bit binary sequence.

d) After inputting the 4 binary values, using LEDs, make sure each of the 4 output bits of the shift register corresponds and matches the chosen 4-bit binary sequence (no more, no less) and holds/stores the sequence on the LEDs. The glowing represents a “1” and no-glowing represents a “0”.

e) Repeat this for multiple 4-bit binary values.

Y

Activation Signal:

1. Activation signal to power the weight circuit is 5 ±1V for

1. Compare the inputted 4-bit binary sequence with values stored in the microcontroller to

Y

26

match and 0 ±0.3V for no match.

verify match (5 ±1V) or no match (0 ±0.3V) from the output pin.

a) Connect the 4-bit binary values to the 4 input pins of the microcontroller to load the data in parallel.

b) Measure to see if the data stored in the microcontroller and the 74194 shift register match by reading the voltage using a voltmeter of the output pin of the microcontroller.

c) If the output pin outputs a “high/1” (4-6V), then there was a match. Otherwise, it will output a “low/0” (-0.3V to 0.3V).

Vcc (Power): 1.Vcc for Doorknob module is 5±1 V

1. Test the Vcc of Doorknob module a) Connect Multi-meter negative connector to negative connector of the common ground(black) b) Connect Multi-meter positive connector to positive connector of the Vcc (red) c) Read voltage- it should be in the range 4-6V

Y

Weight Detection Module:

Requirements Verification Verification status (Y or N)

Digital Weight Scale:

27

1. Weight scale is

functioning properly and reading correct weight ±1 (in lbs).

1. Measure weight of a known

weight. a) Use an object of a

known weight in lbs and place it on the weight scale.

b) Make sure the digital reading on the LCD screen of the scale reads the accurate weight ±1 lbs from the actual weight.

Y

Weight Comparing:

1. The 8-pins are connected correctly from the LCD screen of the weight scale to microcontroller.

2. The correct value of the weight (±1 lbs) is displayed on the computer.

3. Outputs a “high/1” (5

1. Measurement is read on the graphical interface on the computer from the microcontroller.

a) When an object is placed on the digital weight scale, the corresponding value is shown on the stress-strain curve on the graph and is responsive to other weights.

2. Measure the weight of an object of known weight value.

a) Place the object of known weight on the digital and verify that the weight value of the object is displaying accurately on the computer with a tolerance level of (±1 lbs).

3. Compare the stored weight

Y

Y Y

28

±1V) if the value of the weight is same as the weight value stored in the memory as long as the weight value read from the digital scale is ±5 lbs of the stored weight value.

value with the read weight value from the scale.

a) Store a specific weight value for a known object in memory of the microcontroller.

b) Place the object on the weight scale and wait for it to be read into the microcontroller.

c) Check to see if the output pin of the microcontroller outputs a voltage of 5 ±1V with a voltmeter indicating there was a match.

d) Add additional weights within 5 lbs of the stored weight value and verify that the output still reads 5 ±1V.

e) If there is no match, the output pin should output -0.3 to 0.3V.

Vcc (Power): 1.Vcc for Weight detection module is 5±1 V

1. Test the Vcc of Weight detection module a) Connect Multi-meter negative connector to negative connector of the common ground(black) b) Connect Multi-meter positive connector to positive connector of the Vcc (red) c) Read voltage- it should be in the range 4-6V

Y

29

Height detection module:

Requirements Verification Verification status (Y or N)

1. Sensors are operating normally. When blocked, the output is 0 ± 0.3 V. If sensors are not blocked, the output is 5 ± 1V.

1. Test if sensors are operating normally a) Putting the hand to block the sensor at 5-10 cm from the sensor or leave nothing before the sensor b) Connect Multi-meter negative connector to common ground (black) c) Connect Multi-meter positive connector to output of the sensor(red) d) Read the voltage

Y

2. The clock signal is operating at desired frequency. Clock is operating at 1±0.5 Hz

2. Test the clock frequency a) Connect the the positive connector of the oscilloscope to the clock signal b) Connect the negative connector of the oscilloscope to common ground c) Press “measure” on the oscilloscope, and then set measurement to frequency d) Read the frequency, it should be 1± 0.5 Hz

Y

3. The counter is working properly. The counter is giving a 5 ± 1 V every 5 seconds

3. Test the counter a) Connect the positive connector of the Multi-meter to the output of the AND gate which is connected to the counter(74LS192), b) Connect the negative connector of the Multi-meter to the common ground c) look at the a watch and see if the voltage goes to 5 ±1 V every 5 seconds

Y

4. The MUX and DFF works properly. They are able to hold the value for 5 seconds and update every 5th second.

4. Test MUX and DFF sequence I. Case one a) Block the sensor

Y

30

I. Case one: transition from high (5± 1V) to low (0 ± 0.3 V). II. Case two: transition from low (0 ± 0.3 V) to high(5 ± 1V)

b) Connect the positive connector of the Multi-meter to the pin 15 output of the DFF(74ls175) c) Connect the negative connector of the Multi-meter to common ground d) wait for 10 seconds and keep an eye on the voltage during the waiting time e) In this time period, if the output is 0 ± 0.3 V or changes from 5+/- 1V to 0± 0.3V then it is good. II. Case two a) leave the sensor unlocked b) Connect the positive connector of the Multi-meter to the pin 15 output of the DFF(74ls175) c) Connect the negative connector of the Multi-meter to common ground d) wait for 10 seconds and keep an eye on the voltage during the waiting time e)In this time period, if the output is 5 ± 1 V or changes from 0V to 5± 1V then it is good

5. Microcontroller and height detection output matches Compare the inputted 8-bit binary sequence with values stored in the microcontroller to verify match (5 ±1V) or no match (0 ±0.3V) from the output pin.

5. Test microcontroller and Height detection output a) Connect Multi-meter negative connector to common ground (black) b) Connect Multi-meter positive connector to the output of the XNOR gate (red) c) Read voltage- it should be in the range 4-6V if there is a match d) Read the voltage- it should be in the range of -0.3 - 0.3 V is there is no match

Y

31

6. Signal from microcontroller to start Height Detection Circuit is correct. The input from the weight circuit should be 5 ±1V to start the height circuit

6. Test the input to start the height circuit a) Connect Multi-meter positive connector to the pin into height detection sensor which is the input to the inverter (red) b) Connect Multi-meter negative connector to common ground (black) c) Read the voltage, the reading should be 4-6 V

Y

7. Vcc for Height detection module is 5±1 V

7. Test the Vcc of Height detection module a) Connect Multi-meter negative connector to negative connector of the common ground(black) b) Connect Multi-meter positive connector to positive connector of the Vcc (red) c) Read voltage- it should be in the range 4-6V

Y

Eye-blink detection module:

Requirements Verification Verification status (Y or N)

IR emission circuit: 1. IR LED with 10K (± 10%) resistor should be given 5V (± 0.5V).

a) Connect one end of resistor to red lead of multi-meter and the other end to black lead. Set multi-meter to appropriate ohm range and measure the resistance.

b) Connect the red lead of multi-

meter to positive end of the voltage source and black lead of multi-meter to the negative end of the voltage source and after

Y

32

setting the multi-meter to appropriate voltage range, measure the voltage.

IR detection circuit with LED in output: 1. 5V (+/- 0.5V) should be given to photodiode-resistor(3.9 Mega Ohm +/- 0.2 Mega Ohm) circuit. 2. The voltage across the potentiometer should be 5V (+/- 0.5V) and the voltage at the middle pin of potentiometer should be 2.5V (+/- 0.3V).

a) Connect the red lead of multi-meter to positive end of the voltage source and black lead of multi-meter to the negative end of the voltage source and after setting the multi-meter to appropriate voltage range, measure the voltage.

b) Connect one end of resistor to

red lead of multi-meter and the other end to black lead. Set multi-meter to appropriate ohm range and measure the resistance.

a) The positive end of voltage source should be connected to one end of the potentiometer. The other end of potentiometer should be connected to the other end of the voltage source. After setting the multi-meter to appropriate voltage range, measure the voltage.

b) Connect the red lead of multi-

meter to the middle pin of the potentiometer and black lead of multi-meter to the end of the potentiometer which is connected to the negative end of the voltage source. After setting the multi-meter to appropriate voltage range, measure the voltage.

Y

Y

33

3. The voltage at point connecting the photodiode and the resistor should be greater than 3V(+/- 0.1V) when the photodiode is exposed to the IR emission and should be lower than 2.2V(+/- 0.1V) when the photodiode is not exposed to the IR emission. . 4. The output of the LMV324 is 5V(+/- 0.5V) when the photodiode is not exposed to the IR emission and 0V(+/- 0.5V) when the photodiode is exposed to the IR emission.

a) Connect the red lead of multi-meter to the point connecting the photodiode and the resistor and the black lead of multi-meter to the end of the resistor which is connected to the negative end of the voltage source. After setting the multi-meter to appropriate voltage range, measure the voltage while the photodiode is exposed to the IR emission and then, when it is not.

a) Connect the pin 6 of LMV324

to the red lead of multi-meter and the negative end of voltage source which is also connected to pin 4 of LMV324 to the black lead of multi-meter. After connecting, set the multi-meter to appropriate range and measure the voltage.

Y

Y

Clock: 1. The clock signal should have amplitude value 5V (± 0.5V) and frequency value 0.5 Hz (± 0.2 Hz).

a) Connect the clock signal from the microcontroller to the oscilloscope and check the frequency of the signal and also the amplitude of the signal.

Y

Eye-blink value storage: 1. The JK latch should hold high value (5V ± 0.5V) in case of eye blink till low (0V +/- 0.5V) pulse of clock period remains. The JK flip-flop behaves correctly according to the truth table:

a) Connect the output of JK latch to the oscilloscope. It should be high when the sensor is blocked(for a closed eye). The output can be checked for entire low pulse of the clock period by also connecting the clock to the oscilloscope.

Y

34

J-input

K-input

Output

0 0 Q

0 1 0

1 0 1

1 1 Q’

(where 0 = 0 ±0.5V, 1 = 5 ±1V, Q = previous value, and Q’ = opposite of previous value)

Value shifting to shift register: 1. The value of JK latch whether high (5V ± 0.5V) or low(0V ± 0.5V) should be shifted to shift register 74LS194(using serial right shift) when clock goes from high to low. 2. The shifting should take place for 8 seconds (± 0.5 seconds) which is observed using the counter 74LS193 and SR latch. 3. The shifting of inputs should take place in sync with the beeps from buzzer at low (0V ± 0.5V) to high (5V ± 0.5V) change of clock signal.

a) The output of shift register can be seen on LEDs connected to parallel load pins 74LS194 along with 1k (+/- 10%) resistors.

a) The counter output can also be seen on LEDs connected to parallel load pins of 74LS194 along with 1k (+/- 10%) resistors.

a) The sync of beeps can be noted

by observing the clock signal on oscilloscope while listening to the beeps.

Y

Y

Y

Comparing data and verifying: 1. The bits stored in microcontroller are compared with the bits stored in shift

a) The match signal can be given to the microcontroller and using

Y

35

register and if there is a match, the signal to unlock the door should be sent by the microcontroller. Otherwise, the system should shut down.

multi-meter the output of the microcontroller can be tested.

Vcc (Power): 1.Vcc for Eye-blink detection module is 5±1 V

1. Test the Vcc of Eye-blink detection module a) Connect Multi-meter negative connector to negative connector of the common ground(black) b) Connect Multi-meter positive connector to positive connector of the Vcc (red) c) Read voltage- it should be in the range 4-6V

Y

Microcontroller:

Requirements Verification Verification status (Y or N)

Start switch→Doorknob:

1. Activation signal (power) of 5 ±1V is given from the microcontroller of the start switch to the doorknob circuit.

1. Verify that the microcontroller receives start signal and starts system.

a) Using an input pin for the start signal, declare it as start_signal.

b) Set it so that if start_signal is “1” it sends a “1” activation signal to output pin for doorknob circuit. Otherwise, a “0” should be outputted.

c) Using a voltmeter, ensure that a voltage of 4-6V is read from the

Y

36

output pin for doorknob when activation signal of “1” is outputted.

Doorknob→Weight/Eye-blink→Doorlock:

1. Activation signal (power) of 5 ±1V is given from the microcontroller of the doorknob/eye-blink circuit to the weight circuit/doorlock.

1. Verify that the microcontroller compares the input values to the stored values.

a) Using four pins to represent and read the input values from the doorknob/eye-blink circuit, set them as input[3:0] to represent data of most to least significant values.

b) Assign stored values to variables stored[3:0] to represent data of most to least significant values.

c) Compared the input[3:0] to stored[3:0] and set the output of “1=match” or “0=no match” to the output pins that will power the weight circuit/door lock.

d) Measure to see the activation signal (power) is received by using a voltmeter to measure the 4-6V from the output pins for weight circuit and doorlock.

Y

Weight→Height

1. Activation signal (power) of 5 ±1V is given from the microcontroller of the weight circuit to the height circuit.

1. Verify that the microcontroller compares the input values to the stored values.

a) Using 8 pins to represent and read the input values from the weight circuit, set them as weight[7:0]

Y

37

to represent data of most to least significant values.

b) Assign stored values to variables storedweight[7:0] to represent data of most to least significant values.

c) Compared the weight[7:0] to storedweight[7:0] and set the output of “1=match” or “0=no match” to the output pin that will power the height circuit.

d) Measure to see the activation signal (power) is received by using a voltmeter to measure the 4-6V from the output pin for height circuit.

Height→Eye-Blink

1. Activation signal (power) of 5 ±1V is given from the microcontroller of the height circuit to the eye-blink circuit.

1. Verify that the microcontroller compares the input values to the stored values.

a) Using 15 pins to represent and read the input values from the height circuit, set them as height[14:0] to represent data of most to least significant values.

b) Assign stored values to variables storedheight[14:0] to represent data of most to least significant values.

c) Compared the height[14:0] to storedheight[14:0] and set the output of “1=match” or “0=no match” to the output pin

Y

38

that will power the eye-blink circuit.

d) Measure to see the activation signal (power) is received by using a voltmeter to measure the 4-6V from the output pin for eye-blink circuit.

Clock signal:

1. Clock signal for each circuit receives 5 ±0.3V peak-to-peak 0.5 Hz square wave from microcontroller.

1. Ensure the clock signal from microcontroller given to each circuit.

a) Using an oscilloscope, connect to and measure the clock signal pin of microcontroller.

b) For each circuit when the activation signal is given, make sure the oscilloscope reads a 4.7-5.3V peak-to-peak 0.5 square wave signal.

Y

39

Appendix B - Arduino Code // Sweep // by BARRAGAN <http://barraganstudio.com> // This example code is in the public domain. #include <Servo.h> Servo myservo; // create servo object to control a servo // a maximum of eight servo objects can be created int pos = 0; // variable to store the servo position int pin3 = 3; int locksig; // http://www.arduino.cc/en/Tutorial/Smoothing // Define the number of samples to keep track of. The higher the number, // the more the readings will be smoothed, but the slower the output will // respond to the input. Using a constant rather than a normal variable lets // use this value to determine the size of the readings array. const int numReadings = 30; int readings[numReadings]; // the readings from the analog input int index = 0; // the index of the current reading int total = 0; // the running total int average = 0; // the average int inputPin = A0; // weight scale input // digital input pins int startpin = 24; int dkpin = 25; int hpin = 26; int ebpin = 27; // digital output pins int powerdk = 33; int powerw = 34; int powerh = 35; int powereb = 36; int powerlock = 37; int resetpin = 38; int led40 = 40; // signals for inputs int startsig; int dksig; int hsig; int ebsig; // counter int count = 0; void setup()

40

{ // by BARRAGAN <http://barraganstudio.com> myservo.attach(9); // attaches the servo on pin 9 to the servo object // myservo.write(90); // http://www.arduino.cc/en/Tutorial/Smoothing // initialize serial communication with computer: Serial.begin(9600); // initialize all the readings to 0: for (int thisReading = 0; thisReading < numReadings; thisReading++) readings[thisReading] = 0; // assigning pins as INPUTs/OUTPUTs pinMode(startpin, INPUT); pinMode(dkpin, INPUT); pinMode(hpin, INPUT); pinMode(ebpin, INPUT); pinMode(pin3, INPUT); pinMode(powerdk, OUTPUT); pinMode(powerw, OUTPUT); pinMode(powerh, OUTPUT); pinMode(powereb, OUTPUT); pinMode(powerlock, OUTPUT); pinMode(resetpin, OUTPUT); pinMode(led40, OUTPUT); } void loop() { // http://www.arduino.cc/en/Tutorial/Smoothing // subtract the last reading: total= total - readings[index]; // read from the sensor: readings[index] = analogRead(inputPin); // add the reading to the total: total= total + readings[index]; // advance to the next position in the array: index = index + 1; // if we're at the end of the array... if (index >= numReadings) // ...wrap around to the beginning: index = 0; // calculate the average: average = total / numReadings; // send it to the computer as ASCII digits float voltage = average * (5 / 1023.0); Serial.println(voltage); delay(100); // delay in between reads for stability

41

if(voltage >= 2.3 && voltage <= 2.42) //**********adjust weight/voltage value********** { digitalWrite(led40, HIGH); } else { digitalWrite(led40, LOW); } // assigning input pins as signals startsig = digitalRead(startpin); dksig = digitalRead(dkpin); hsig = digitalRead(hpin); ebsig = digitalRead(ebpin); if (count == 0 && startsig == HIGH && dksig == LOW && hsig == LOW && ebsig == LOW) { count++; } else if (count == 1 && startsig == HIGH && dksig == HIGH && hsig == LOW && ebsig == LOW) { count++; } else if (count == 2 && startsig == HIGH && dksig == LOW && hsig == LOW && ebsig == LOW && voltage >= 2.3 && voltage <=2.42) //**********adjust weight/voltage value********** { count++; } else if (count == 3 && startsig == HIGH && dksig == LOW && hsig == HIGH && ebsig == LOW) { count++; } else if (count == 4 && startsig == HIGH && dksig == LOW && hsig == LOW && ebsig == HIGH) { count++; } else { count = count; } if (count == 0) { digitalWrite(powerdk, LOW); digitalWrite(powerw, LOW); digitalWrite(powerh, LOW); digitalWrite(powereb, LOW); digitalWrite(powerlock, LOW); digitalWrite(resetpin, LOW); } else if (count == 1) { digitalWrite(powerdk, HIGH);

42

delay(3000); digitalWrite(resetpin, HIGH); digitalWrite(powerw, LOW); digitalWrite(powerh, LOW); digitalWrite(powereb, LOW); digitalWrite(powerlock, LOW); } else if (count == 2) { digitalWrite(powerdk, LOW); digitalWrite(powerw, HIGH); digitalWrite(powerh, LOW); digitalWrite(powereb, LOW); digitalWrite(powerlock, LOW); digitalWrite(resetpin, LOW); } else if (count == 3) { digitalWrite(powerdk, LOW); digitalWrite(powerw, LOW); digitalWrite(powerh, HIGH); digitalWrite(powereb, LOW); digitalWrite(powerlock, LOW); digitalWrite(resetpin, LOW); } else if (count == 4) { digitalWrite(powerdk, LOW); digitalWrite(powerw, LOW); digitalWrite(powerh, LOW); digitalWrite(powereb, HIGH); delay(3000); digitalWrite(resetpin, HIGH); digitalWrite(powerlock, LOW); } else if (count == 5) { digitalWrite(powerdk, LOW); digitalWrite(powerw, LOW); digitalWrite(powerh, LOW); digitalWrite(powereb, LOW); digitalWrite(powerlock, HIGH); digitalWrite(resetpin, LOW); } else { digitalWrite(powerdk, HIGH); digitalWrite(powerw, HIGH); digitalWrite(powerh, HIGH); digitalWrite(powereb, HIGH); digitalWrite(powerlock, HIGH); digitalWrite(resetpin, HIGH); } // by BARRAGAN <http://barraganstudio.com> locksig = digitalRead(pin3); //code for servo motor used for lock

43

if (locksig == LOW) { myservo.write(180); } else if (locksig == HIGH) { myservo.write(0); } }

44