Difference between revisions of "S13: Door Alarm System"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Hardware Design)
(Hardware Interface)
Line 196: Line 196:
  
 
[[File:CmpE146_S13_TP_GSM board.png.png|500px|thumb|center]]
 
[[File:CmpE146_S13_TP_GSM board.png.png|500px|thumb|center]]
<div style="text-align: center;">'''Figure 9:''' GSM Module Ver.3</div>
+
<div style="text-align: center;">'''Figure 8:''' GSM Module Ver.3</div>
  
 
For our test we used a regular size SIM card from Tmobile. This Sim is a prepaid card that can be brought in any cellular store. It is worth noting that a regular data plan is required in order to send, receive or make phone call with this GSM module. To set this GSM module, connect the UART selection jumper GSM, connect S1 jumper to USB mode, and connect S2 Jumper to communication mode. The led on this module indicates network status
 
For our test we used a regular size SIM card from Tmobile. This Sim is a prepaid card that can be brought in any cellular store. It is worth noting that a regular data plan is required in order to send, receive or make phone call with this GSM module. To set this GSM module, connect the UART selection jumper GSM, connect S1 jumper to USB mode, and connect S2 Jumper to communication mode. The led on this module indicates network status
Line 209: Line 209:
 
The RFID reader is used to read data written in the RFID tags. It is interfaced to the SJ One board using UART 3 such that the TX pin of the RFID reader is connected to the RX pin (P4.29) of UART 3 in the board. This RFID reader is a break out board for pins located on ID-12. It is worth mentioning the ID-2 does not come with an internal or external antenna. So the user is require to create and antenna from coiling copper wires. We used the ID-12 which comes with an internal antenna. The following figures shows the pinout needed to communicate with this RFID device. The only pin require to use this device is GND, +5V, and D0 for UART communications. Both cards that came with the reader have a 12 bit string preloaded to the card.
 
The RFID reader is used to read data written in the RFID tags. It is interfaced to the SJ One board using UART 3 such that the TX pin of the RFID reader is connected to the RX pin (P4.29) of UART 3 in the board. This RFID reader is a break out board for pins located on ID-12. It is worth mentioning the ID-2 does not come with an internal or external antenna. So the user is require to create and antenna from coiling copper wires. We used the ID-12 which comes with an internal antenna. The following figures shows the pinout needed to communicate with this RFID device. The only pin require to use this device is GND, +5V, and D0 for UART communications. Both cards that came with the reader have a 12 bit string preloaded to the card.
 
[[File:CmpE146 S13 TP rfid pinout.png|380px|thumb|center]]
 
[[File:CmpE146 S13 TP rfid pinout.png|380px|thumb|center]]
<div style="text-align: center;">'''Figure 10:''' Pinout for RFID reader</div>
+
<div style="text-align: center;">'''Figure 9:''' Pinout for RFID reader</div>
  
 
<b>Piezoelectric Buzzer </b><br>
 
<b>Piezoelectric Buzzer </b><br>

Revision as of 06:00, 22 May 2013

Door Alarm System

Abstract

Our project is a alarm system that will allow the user to lock/unlock a door simply by sending a text message. An RFID module will also be implemented as an alternative to opening the door. The user can receive a text message or phone call from the system about the current status of the door. The purpose for this project is to improve security as well as allowing easier access for people who are tired of using the traditional key.

Objectives & Introduction

  • System will lock or unlock base on the message sent by the user
  • If door scans an RFID tag
    • Tags with correct code will have access
    • System will send text message that a correct tag has been scanned.
  • System will have function to call user's phone

Team Members & Responsibilities

Thanh Huynh

  • Design and creating FreeRTOS task for:
    • Communication with GSM
      • Sending and reciveing SMS message
      • Making phone call
    • Reading RFID tags
      • Processing information and passing it to GSM
    • Interfacing with LCD

Phi Le

  • Drivers Development for:
    • Both UART2 and UART3 driver
    • Pulse width modulation (PWM)
  • Interfacing servo to board
  • Hardware construction of system
  • Assisted and gave input in trouble shooting

Schedule

Week Number Planned Tasks Actual Tasks

Week 1

  • Order RFID reader & tags
  • Order GSM Module
  • Go over the project
  • Completed
  • Completed
  • Completed

Week 2

  • Write UART1 driver
  • Learn LPC 7158 board framework
  • Completed
  • Completed

Week 3

  • Create system schematic
  • Get RIFD to interface with UART
  • Write SPI driver
  • Interface LCD with with board
  • Learn AT commands
  • Interface GSM Module with board
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed

Week 4

  • Construct alarm system
  • Write PWM driver
  • Interface servo with board
  • Completed
  • Completed
  • Completed

Week 5

  • Testing and Fix bugs
  • Make final changes for demo
  • Finalize content in Wiki article
  • Completed
  • Completed
  • Completed

Parts List & Cost

Parts Cost
2012 SJ One Board $40
RFID Complete Kit $50
Jumper Wires $6
NewHaven LCD $25
GSM/GPS Module V3 $89
Piezo Buzzer $1
Servo $15
Total: $226

Design & Implementation

Hardware Design

The entire hardware block diagram is shown below

The heart of the system is the micro-controller LPC1758 integrated to the SJ One board. It controls all components in the system such as RFID reader, GSM module, servo and LCD through UART, PWM and SPI interfaces.

The following are individual components of the system

CmpE146 S13 TP SJ One Board.png
CmpE146 S13 TP gsm module.jpg
CmpE146 S13 TP RFID Reader.jpg
Figure 3: RFID Reader (http://www.sparkfun.com)
CmpE146 S13 TP RFID USBreader.jpg
Figure 4: RFID USB Reader (http://www.sparkfun.com)
CmpE146 S13 TP RFID Tag.jpg
Figure 5: RFID Tag (http://www.sparkfun.com)
CmpE146 S13 TP servo.jpg
Figure 6: Standard Servo (http://www.parallax.com)
CmpE146 S13 TP LCD.jpg
Figure 7: 4x20 LCD (http://www.newhavendisplay.com)

Hardware Interface

GSM Module
This GSM module will allow us to send and receive messages from our phone. This GSM module was designed to be compatatible with an Arduino Revision 3 board. However this board can be connected to the SJ ONE board using UART2 for communication. Connect RX pin from UART2 to TX pin from GSM. Connect TX pin from UART2 to TX pin of GSM. This GSM module requires a baud rate of 38400 bits per seconds. This module requires a voltage of 7 to 12 volts in order to work properly.

CmpE146 S13 TP GSM board.png.png
Figure 8: GSM Module Ver.3

For our test we used a regular size SIM card from Tmobile. This Sim is a prepaid card that can be brought in any cellular store. It is worth noting that a regular data plan is required in order to send, receive or make phone call with this GSM module. To set this GSM module, connect the UART selection jumper GSM, connect S1 jumper to USB mode, and connect S2 Jumper to communication mode. The led on this module indicates network status

Servo Module
The servo is used as a simulation for the door lock. It is interfaced to the SJ One board using PWM interface such that the input pin (white) of the servo is connected to P1.20 in the board.

LCD
The LCD is used to display the status of the lock as well as the data written in the RFID tags when read by RFID reader. It is interfaced to the SJ One board using SPI interface such that the SCK pin (pin 3) of the LCD is connected to the SCK pin (P0.7) of the board, the SDI pin (pin 4) of the LCD is connected to the MOSI pin (P0.9) of the board, and the SPISS pin (pin 1) of the LCD is connected to the CLK pin (P0.15) of the board.

RFID Reader and Tag
The RFID reader is used to read data written in the RFID tags. It is interfaced to the SJ One board using UART 3 such that the TX pin of the RFID reader is connected to the RX pin (P4.29) of UART 3 in the board. This RFID reader is a break out board for pins located on ID-12. It is worth mentioning the ID-2 does not come with an internal or external antenna. So the user is require to create and antenna from coiling copper wires. We used the ID-12 which comes with an internal antenna. The following figures shows the pinout needed to communicate with this RFID device. The only pin require to use this device is GND, +5V, and D0 for UART communications. Both cards that came with the reader have a 12 bit string preloaded to the card.

CmpE146 S13 TP rfid pinout.png
Figure 9: Pinout for RFID reader

Piezoelectric Buzzer
This device requires a frequency input. PWM will be used to send a high level frequency to the piezo electric buzzer. May require an inverting op amp in order to raise the sound level. For this project, this buzzer was loud enough

Software Design

CmpE146 S13 TP system flowchart.png
Figure 9: Flowchart showing system upon start up

How to Send a Message
Steps:
1. Send:AT
2. Send:At+CMGF=1
3. Send:AT+CMGS="XXXXXXXXXX" (X means phone number of the receiver)
4. wait for indicator '<' and start typing your message
5. when done Send character 'ctrl+z'

How to Make a phone Call
Steps:
1. Send:AT
2. Send:ATDXXXXXXXXXX; (X means receiver's phone number, then end with a semicolon);

Above are steps of how to send AT command through serial communication. For example in order to make a phone call, first send string 'AT' to the GSM. GSM will reply with AT which will acknowledge that it received your command. Then proceed by sending "ATD" concatenated with a phone number. It will take a few seconds for the GSM to establish a connection before calling the phone number. After the receiver hangs up the phone the GSM will send a message through serial indicating phone call has ended.

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.

CmpE146 S13 TP blockDiagram.png
Block Diagram of the System

RFID Task
This task waits for a card to be read by the RFID reader. When a card is read there will be a string provided by that specific card. If the string matches our password, then the RFID will call function send_sms_to_phone() which will send SMS message that door is now open. If card provides an invalid password then the send_sms_to_phone() function call will send a string saying "invalid user".

GSM Task
Gsm will wait indefinite until it receives a text message. When a text message arrive the gsm will give a semaphore signal to new_text task to process the text.

New_Text Task
This task processes the new text message when receiving the semaphore from GSM task. First this task will read the message and look for specific operation indicated by the user. When done, the text message will be deleted to open up room for new incoming text messages.

LCD Task
LCD task will wait for a string giving by other task.LCD task the LCD will display string on to screen one character at a time.

Testing & Technical Challenges

  • Could not establish serial communication with GSM module v3
    • GSM jumpers need to be in correct location. The following switch configuration needs to be established on the board in order to send or receive AT commands. Switch 1: USB, Switch 2: Comm, Switch 3: GSM.
  • UART is not working properly, sometimes it works and sometimes is does not.
    • All UART registers should be set at right values, refer to the datasheet.
  • Servo does not turn in directions and speeds as required
    • Ensure that the frequency for servo to work is 50 Hz, pulse widths vary from 1.0 ms to 2.0 ms, 20 ms intervals.
  • GSM module is not sending back any acknowledgement signal or is not processing any AT command that I am sending to it.
    • A newline character 'r' is required after most AT command sent to GSM.
    • Sometime a delay is required before the next AT command can be sent.
  • A powerful and stable power supply is needed in order to provide enough power to all components of the system.
    • All GROUNDs need to be connected together in order to establish a common GROUND.

Conclusion

The project achieves all proposed objectives.

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

Preet Kang
Dr. Haluk Özemek

References Used

Appendix

You can list the references you used.