Difference between revisions of "F12: Android Door Lock"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Implementation)
(Implementation)
Line 246: Line 246:
  
 
'''User Interface Task'''
 
'''User Interface Task'''
 +
 +
Before the user is able to input any data, all drivers and all data buses should be initialized first. If something is not initialized and the user tries to access it, the micro-controller may output the wrong data or may not allow access. Therefore, initialization functions are called at the beginning of this task. Once all initializations are done, the task enters a for loop where the user can enter and choose specified commands.
 +
Under the "wifly" command, the user may talk to the WiFly module. This works by sending whatever the user inputs into UART1. UART1 is the communication link between LPC2148 and the WiFly module. In response to the user, the wifly will send something back via UART1 and then printed to screen via UART0.
 +
If the user enters "ls" the SDCard directory will be outputted using the FAT functions to retrieve information.
 +
The "play" command will ask the user to input the name of an mp3 file given that the user knows the file name in the SDCard. Once the user enters the mp3 file name, it is sent into a song queue.
 +
"Time" simply prints out the hour, minute, and seconds using the RTC variables specified in the LPC2148.h.
 +
"Read" will open the locktimes file in the SDCard and read out the time stamps that were logged. Similar to reading the mp3 file, it is done in a while loop.
  
 
'''WiFly Task'''
 
'''WiFly Task'''

Revision as of 05:52, 10 December 2012

Android Door Lock

Abstract

Using a Wifi connection, our door lock can be locked and unlocked remotely with an Android device.

Introduction & Features

  • UART communication between RN-XV WiFly Module and LPC2148 Microcontroller.
  • Andriod application that enables wireless door access.
  • WiFly module for wireless communication between Android and LPC2148 Microcontroller.
  • TCP communication running on LPC2148 handling requests from the Android application.
  • Web server to handle user permission, to set door codes, and to view time stamps of when the door was accessed.
  • MP3 player that allows customizable tunes to play when the door is unlocked.
  • Filing system that stores all the log times that the door has been accessed.
  • Electronic door strike that unlocks when door code is recognized.

Show list of your objectives. This section includes the high level details of your project. You can write about the various sensors or peripherals you used to get your project completed.

Team Members & Responsibilities

  • Rosemary Chen
    • Created the UART1 driver that enables communication between the wireless module and the micro controller.
    • Created the Real Time Clock driver used for logging the time that users access the door.
    • Created the user interface for setting and configuring the wifly module as well as automating the default settings for network connection.
    • Created a task for
      • Correct password detection
      • Enabling the lock when password is detected
      • Logging the time when the door is accessed
      • Playing a tune when the door is unlocked.
  • Cindy Li
    • Created the web server that allows the host to track door users, enable or disable users, and sets the door code.
    • Created the door lock driver circuit that supplies the required 8v
  • Hai Wang
    • Create a TCP client Android application that allows connectivity between the wireless module (server) and the Android application (client). The application is responsible for sending the correct door code to the server in order for the door to unlock.

Schedule

Show a simple table or figures that show your scheduled as planned before you started working on the project. Then in another table column, write down the actual schedule so that readers can see the planned vs. actual goals. The point of the schedule is for readers to assess how to pace themselves if they are doing a similar project.

Cost of shipping and handling excluded

Week Number Scheduled Items Actual

November 2, 2012

  • Set up environment (Android)
  • Confirm/order parts
  • Update Wiki

Done

November 9, 2012

  • UART 1 Driver
  • Wifly driver
  • Android app UI
  • Update Wiki

Done

November 16, 2012

  • Android to LPC2148 communication
  • Automate default WiFly network connection
  • Start Web server
  • Update Wiki

Done

November 23, 2012

  • Construct door lock mechanism circuit
  • Write driver for GPIO to enable and disable lock
  • Continue with Web Server
  • Update Wiki

Done

November 30, 2012

  • Enable MP3 to play when door is opened.
  • Continue with Web Server
  • Update Wiki

Done

December 7, 2012

  • Write Real Time Clock Driver
  • Create a task for time stamp logging
  • Construct box to contain messy wires and modules
  • Write task for count down door unlock
  • Update Wiki

In progress

December 14, 2012

  • Testing
  • Fix bugs
  • Update Wiki

In progress

Parts List & Cost

Give a simple list of the cost of your project broken down by components. Do not write long stories here.

Parts Cost

Nexus 7 Android Tablet

$249.00

RN-XV WiFly Module x3

$34.95 x3

Electric Door Strike

$12.00

LPC2148 Microcontroller

$60.00

**Cost excludes shipping and handling

Design & Implementation

The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.

Hardware Design

Discuss your hardware design here. Show detailed schematics, and the interface here.

Hardware Interface

In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the Software Design section is isolated to talk about high level workings rather than inner working of your project.


SPI BUS

The LPC2148 Micro-controller communicates with the SD Card and the MP3 Decoder through the SPI bus. For both the SD Card and the MP3 Decoder, the chip select is transmitted through the SPI bus. For the decoder, data request and reset is also transmitted through SPI. The SD Card transmits MP3 data into the MP3 decoder. Once the decoder is done processing this data, it is then outputted into the I2C bus to the DAC.

I2C BUS

The LPC2148 Micro-controller communicates with the DAC and the MP3 Decoder using the I2C bus. The MP3 decoded data is outputted into the DAC so that it can convert digital signals into analog signals. The analog signals will be the sound produced out of our head phones which is connected to the audio jack. The micro controller can also send signals via I2C to the DAC to control volume, bass, treble, etc.

UART BUS

The uart bus allows communication between the LPC2148 micro-controller and the laptop as well as the WiFly module with the LPC2148. For the LPC2148, there are only two UART pins. In this case, UART0 is the connection between the computer and the micro-controller and UART1 is the connection between the micro-controller and the WiFly module. For the programmer to communicate with the WiFly module, the programmer would first have to send data to the LPC2148 micro-contoller through UART0, then redirect the data to the Wifly module using UART1. Once the WiFLy has received the data which may contain commands, the WiFly will respond by transmitting the requested data back to the LPC2148 via UART1 and from the LPC2148 back to the computer via UART0 so that the programmer can view the data that the Wifly transmitted.

GPIO PORT

The GPIO port is used to enable or disable the door lock. When the LPC2148 micro-controller recognizes a key code that is sent from the Android, it will send 5v through the GPIO which is connected to the door lock circuit.

Door Lock Circuit

The 5v supplied by the LPC2148 from the GPIO port is not sufficient to power the door lock so a small circuit was made to supply 8v to the door lock.

Software Design

Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show psuedocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it.

User Interface Task

All kinds of initialization takes place at the beginning of this task such as SPI, I2C, SDCard, MP3 Decoder, DAC, Door Lock, RTC, and the WiFly. Besides initialization, the UI task allows the user to communicate with the WiFly module such as sending data through wifi and configuring the settings on the WiFly, to view the directory of the SDCard, to select MP3 files to be played from the SDCard, to view the current time on the LPC2148, and to read the logged time stamps from the SDCard.

WiFly Task

This task is responsible for outputting data to Hercules that's sent from the WiFly module, parsing the data, and recognizing key codes sent from the Android. When the door code matches, this task will enable the GPIO port (unlock the door), send a song name to the song queue (play a tune), and log the time that the GPIO is enabled (when the door has been accessed).

MP3 Task

This task is responsible for reading mp3 files from the SDCard to the MP3 Decoder.

Real Time Clock Task

This task is responsible for outputting the time every minute.

Implementation

This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.

User Interface Task

Before the user is able to input any data, all drivers and all data buses should be initialized first. If something is not initialized and the user tries to access it, the micro-controller may output the wrong data or may not allow access. Therefore, initialization functions are called at the beginning of this task. Once all initializations are done, the task enters a for loop where the user can enter and choose specified commands. Under the "wifly" command, the user may talk to the WiFly module. This works by sending whatever the user inputs into UART1. UART1 is the communication link between LPC2148 and the WiFly module. In response to the user, the wifly will send something back via UART1 and then printed to screen via UART0. If the user enters "ls" the SDCard directory will be outputted using the FAT functions to retrieve information. The "play" command will ask the user to input the name of an mp3 file given that the user knows the file name in the SDCard. Once the user enters the mp3 file name, it is sent into a song queue. "Time" simply prints out the hour, minute, and seconds using the RTC variables specified in the LPC2148.h. "Read" will open the locktimes file in the SDCard and read out the time stamps that were logged. Similar to reading the mp3 file, it is done in a while loop.

WiFly Task

The user interface task will constantly check whether or not there is data sitting in the UART1 buffer. If there is, it will print it to screen through UART0. Because the buffer stores a chunk of data sent from WiFly, we designed this task to use a string compare with the buffer and the door code. To isolate the door code from the rest of the data in the buffer, a simple parser is made. To keep the buffer to a sizable amount the content in the buffer is printed to screen and emptied every time a '\n' or any specified character is detected. If the string compare matches, then a acknowledge message will be sent to both UART0 and UART1 to indicate that the door is open. In addition to the acknowledge message, the name of the tune is sent to the song queue by using osHandles and an enable function for the GPIO port will be called. The GPIO function sets the GPIO pin high for five seconds, and then disables it when five seconds are up allowing enough time for the user to open the door and enter before it locks.

MP3 Task

This task is responsible for reading mp3 files from the SDCard to the MP3 Decoder. To do this it loads the song name of the mp3 selected in the UI task from the song queue and opens the file. Once this mp3 file is opened in the SDCard, it reads the file from the SPI bus into the MP3 decoder. The reading is done in a while loop so that the file will continue to be read as long as there is data to be read. If it has reached the end of file, the while loop will break. When the file has been read, this task will close the file.

Real Time Clock Task

To implement the time stamp portion, I have the task constantly check the minute hand. If the minute hand is not the same as the previous minute then print out the time and update the previous minute to the current minute.

Testing & Technical Challenges

Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.

Include sub-sections that list out a problem and solution, such as:

Wifi Connection Issues

Many wifi connection issues were encountered. To solve this problem, a dedicated task was created to re-connect to wifi if the connection was ever lost.

Conclusion

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?

Project Video

Upload a video of your project and post the link here.

Project Source Code

Send me your zipped source code and I will upload this to SourceForge and link it for you.

References

Acknowledgement

We'd like to thank:

Chris Cheng for helping us with UART1 that was much needed for the communication between the LPC2148 and Hercules.

Preet Kang for walking us through the our labs and our project the whole way.

References Used

Appendix

You can list the references you used.