The purpose of this homework is to implement a simple to use door lock system th
ID: 3606940 • Letter: T
Question
The purpose of this homework is to implement a simple to use door lock system that includes a hex keypad, one push button switch labelled as OK, two on/off switches labelled as PASSWD and RST and three LEDs labeled as green G, red R and yellow Y and one control output LOCKED.
Assume that the keypad used in the system works as follows: - When a single digit hex number on the keypad is pressed, a DAV (data available) signal goes to high and 4bit binary value corresponding to hex digit is stored at the outputs of the keypad. DAV signal goes to low when the key is released. Assume that all switches in the system eliminate de-bouncing in hardware. The keypad reads and returns the lowest key value if more than one key are pressed simultaneously.
The specification of the system is as follows:
- It requires the user to enter a pre-determined 4-digit hex key code before unlocking the door. - It makes consecutive key readings but ignores, if any, those after four until OK button is pressed. - It compares the user key code entered with the stored code. - If there is a match, it unlocks the door and makes GR=10 for five seconds. - Otherwise, makes GR=01 for three seconds and the passage is rejected by keeping the door locked.
- Assume PASSWD and RST switches can only be activated/deactivated by an authorized user.
- Using PASSWD switch it is possible to change the code stored. - When PASSWD is on, the authorized user is expected to enter the current 4-digit key code. Y starts blinking when correctly entered. While blinking, Y is off for 0.5 seconds and on for 0.5 seconds. - The supervisor then enters the new 4-digit key code and Y=1 when ready. - New code is expected to be different than the last three 4-digit key codes used. If it is not, another 4-digit key code must be entered.
- RST initializes the system with the default key code of 1234. - During normal operation (when not RST and not PASSWD) and except the cases defined above LOCKED=0 and RGY=001.
- The system clock is 1 MHz.
What to do?
a) Design the control unit and datapath of the door lock system specified above. For this, draw the ASM chart, form the state table, and give the implementations for both parts.
b) Design the system and write its Verilog code in behavioral style using Quartus.
c) Simulate your code in part (b) and functionally verify it using a testbench of your own.
What to deliver?
Handwritten document of part (a) Source code for your design in part (b) Testbench for your simulation in part (c) A report containing implementation details and simulation results of your work
Explanation / Answer
First of all, we will make the connection to the 4×4 Keypad. For connecting the keypad with the Arduino we are using both analog and digital pins. We used analog pins since we need more that 14 digitals pins for this project. If you are using Arduino Mega, then there is no need to use analog pins. Connect first six pins of keypad to analog pins A0 ~ A5 of Arduino and remaining two to digital pins 3 and 2.
To connect the push pull solenoid with the Arduino, we will have to use external power because it requires 6 ~ 12V to operate and much more current than the Arduino can provide. So to do that, we will use TIP120 NPN transistor as a switch/driver and a DC power source which can provide 6 ~ 12V. The NPN transistor will switch ON when we will give HIGH to its base. So, connect its first pin (which is the base pin) to the pin 11 through to a 1K resistor, second pin (which is the collector pin) to the negative wire of push pull solenoid and third pin (which is the emitter pin) to the ground. Now connect the positive of power supply to the positive wire of solenoid and the negative of power supply to the ground.
Now connect the positive wire of buzzer to the pin 10 of Arduino and negative wire to the ground.
Now we will connect the 16×2 LCD to the Arduino.
Working
In this project, we have used EEPROM in the Arduino to store the password in it. The default password stored in it will be ‘12
34’. When we enter a password, it will match it with the password stored in the Arduino EEPROM. If it is correct, then it will show ‘Passkey Accepted’ and the push pull solenoid will come in low state (Door Unlocked). If the password is wrong, then it will show ‘Access Denied’. During this condition the buzzer will start beeping and the push pull solenoid will remain in the high state (Door Locked). The buzzer will also beep once when any key is pressed.
For changing the passkey, we have to press ‘#’. When we press ‘#’, it will ask for current passkey. If we enter the correct password it will ask for new passkey and will save it in the EEPROM.
Explanation
First of all, we will include libraries for the Keypad, LCD and EEPROM. The default password saved in the EEPROM will be ‘1234’. Then initializing the library for LCD and defining pins on which the LCD is connected.
Then defining pins for connecting 4×4 keypad. We are using 4×4 keypad therefore we will define 4 pins for rows and 4 pins for columns. If you are using 4×3 keypad then you need only 4 pins for rows and 3 pins for columns.
Then giving command to start the LCD, setting buzzer and make LED pins as output.
The following code will read pressed keys from the keypad and will show it on LCD as well as in serial monitor. Arduino will read keys one by one and make a beep sound whenever a key is pressed.
The following code will compare the entered key with the password stored in the EEPROM. If the password is correct, then it will show ‘Passkey Accepted’ otherwise it will show ‘Access Denied’.
The following code will change the password stored in the EEPROM. When we press the ‘#’ key to change the password. Then it will ask you to enter the current password and if it is correct then it will ask you to enter the new password. Then it will store this new password in the EEPROM.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.