Difference between revisions of "S13: Door Alarm System"
(→Hardware Design) |
(→Project Source Code) |
||
(93 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Door Alarm System == | == Door Alarm System == | ||
+ | [[File:CmpE146 S13 TP project.JPG|400px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Door Alarm System''' </div> | ||
== Abstract == | == Abstract == | ||
Line 32: | Line 22: | ||
*** Making phone call | *** Making phone call | ||
** Reading RFID tags | ** Reading RFID tags | ||
− | *** Processing information and passing it to GSM | + | *** Processing information and passing it to GSM |
− | |||
** Interfacing with LCD | ** Interfacing with LCD | ||
'''Phi Le''' | '''Phi Le''' | ||
Line 71: | Line 60: | ||
</center> </td> | </center> </td> | ||
<td> | <td> | ||
− | * Write | + | * Write UART drivers |
* Learn LPC 7158 board framework | * Learn LPC 7158 board framework | ||
</td> | </td> | ||
Line 87: | Line 76: | ||
<td> | <td> | ||
* Create system schematic | * Create system schematic | ||
− | * Get | + | * Get RFID to interface to UART |
* Write SPI driver | * Write SPI driver | ||
− | * Interface LCD | + | * Interface LCD to board |
* Learn AT commands | * Learn AT commands | ||
− | * Interface GSM Module | + | * Interface GSM Module to board |
</td> | </td> | ||
Line 113: | Line 102: | ||
* Construct alarm system | * Construct alarm system | ||
* Write PWM driver | * Write PWM driver | ||
− | * Interface servo | + | * Interface servo to board |
</td> | </td> | ||
<td> | <td> | ||
Line 133: | Line 122: | ||
</td> | </td> | ||
<td> | <td> | ||
− | * | + | * Completed |
− | * | + | * Completed |
− | * | + | * Completed |
</td> | </td> | ||
</tr> | </tr> | ||
Line 156: | Line 145: | ||
| Jumper Wires | | Jumper Wires | ||
| $6 | | $6 | ||
− | |||
− | |||
− | |||
|- | |- | ||
| NewHaven LCD | | NewHaven LCD | ||
Line 173: | Line 159: | ||
|- | |- | ||
! Total: | ! Total: | ||
− | ! $ | + | ! $226 |
|} | |} | ||
Line 182: | Line 168: | ||
The entire hardware block diagram is shown below | The entire hardware block diagram is shown below | ||
− | [[File: | + | 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. |
− | <div style="text-align: center;">'''Figure 1:''' | + | |
+ | The following are individual components of the system | ||
+ | |||
+ | [[File:CmpE146_S13_TP_SJ One Board.png|300px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 1:''' SJ One Board (http://www.socialledge.com/sjsu/index.php?title=2012_SJ_One_Board)</div> | ||
+ | |||
+ | [[File:CmpE146_S13_TP_gsm_module.jpg|300px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 2:''' GSM Module (http://www.dfrobot.com/wiki/index.php/GPS/GPRS/GSM_Module_V3.0)</div> | ||
+ | |||
+ | [[File:CmpE146_S13_TP_RFID_Reader.jpg|300px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 3:''' RFID Reader (http://www.sparkfun.com)</div> | ||
+ | |||
+ | [[File:CmpE146_S13_TP_RFID_USBreader.jpg|300px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 4:''' RFID USB Reader (http://www.sparkfun.com)</div> | ||
+ | |||
+ | [[File:CmpE146_S13_TP_RFID_Tag.jpg|300px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 5:''' RFID Tag (http://www.sparkfun.com)</div> | ||
+ | |||
+ | [[File:CmpE146_S13_TP_servo.jpg|300px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 6:''' Standard Servo (http://www.parallax.com)</div> | ||
− | + | [[File:CmpE146_S13_TP_LCD.jpg|300px|thumb|center]] | |
+ | <div style="text-align: center;">'''Figure 7:''' 4x20 LCD (http://www.newhavendisplay.com)</div> | ||
=== Hardware Interface === | === Hardware Interface === | ||
− | + | <b>GSM Module </b><br> | |
+ | 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. | ||
+ | |||
+ | [[File:CmpE146_S13_TP_GSM board.png.png|500px|thumb|center]] | ||
+ | <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 | ||
+ | |||
+ | <b>Servo Module </b><br> | ||
+ | Servos are controlled by sending them a pulse of variable width via control wire. The angle that a servo turns is determined by the duration of a pulse that is applied to the control wire. This is called Pulse width Modulation | ||
+ | (PWM). The servo expects to see a pulse every 20 ms. The length of the pulse will determine how far the motor turns. For example, with a regular standard servo, a 1.5 ms pulse will make the motor turn to the 90 degree position (neutral position); a less than 1.5 ms pulse will make the motor turn a certain angle to the left, depended on how small the pulse is in comparison to 1.5 ms; a more than 1.5 ms pulse will make the motor turn a certain angle to the right, depended on how large the pulse is in comparison to 1.5 ms. | ||
+ | |||
+ | In this project, the servo is used as a simulation for the door lock. It is interfaced to the SJ One board using PWM1.2 such that the control pin (white) of the servo is connected to P1.20 in the board. | ||
+ | |||
+ | [[File:CmpE146_S13_TP_servo_pinout.png|500px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 9a:''' Servo Pinout (http://www.parallax.com)</div> | ||
+ | |||
+ | [[File:CmpE146_S13_TP_servo_period.jpg|600px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 9b:''' Servo duty cycle (http://www.servocity.com/html/how_do_servos_work_.html)</div> | ||
+ | |||
+ | [[File:CmpE146_S13_TP_servo_period2.jpg|500px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 9c:''' Servo pulse width (http://www.servocity.com/html/how_do_servos_work_.html)</div> | ||
+ | |||
+ | |||
+ | <b>LCD </b><br> | ||
+ | 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. | ||
+ | |||
+ | [[File:CmpE146_S13_TP_lcd_pinout.png|500px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 10:''' LCD Pinout (http://www.newhavendisplay.com)</div> | ||
+ | |||
+ | <b>RFID Reader and Tag </b><br> | ||
+ | The RFID reader (ID-12) is used to read data written in the RFID tags. It is used with a break out board for easier pins located and connected. | ||
+ | It is worth mentioning we first started with a ID-2 which does not come with an internal or external antenna. Users are required to create an antenna from coiling copper wires themselves. We did not have time to do that, so we ended up buying the ID-12LA which comes with an internal antenna. The following figures shows the pinout needed to communicate with this RFID device. | ||
+ | The only pins required to use this device are GND, +5V, and D0 for UART communications. It is interfaced to the SJ One board using UART 3 such that the TX pin (D0, pin 9) of the RFID reader is connected to the RX pin (P4.29) of UART 3 in the board. | ||
+ | Both RFID tags that come with the reader have a 12 bit string preloaded to the card and cannot be rewritten without some special tools. | ||
+ | [[File:CmpE146 S13 TP rfid pinout.png|380px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 11:''' Pinout for RFID reader</div> | ||
+ | |||
+ | <b>Piezoelectric Buzzer </b><br> | ||
+ | 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 | ||
+ | |||
+ | <b>How to write a driver for UART</b><br> | ||
+ | Below are some basic steps to initialize the UARTs | ||
+ | * Configure pin select (PINSEL) for UART, refer to the LPC1758 user manual for details | ||
+ | * Setup and provide the clock to UART peripheral (PCLKSEL), refer to the LPC1758 user manual for details | ||
+ | * Write "putChar" and "getChar" functions for the UART to transmit and receive data | ||
+ | |||
+ | <b>How to write a driver for PWM</b><br> | ||
+ | Below are some basic steps to initialize the PWMs | ||
+ | * Power up the PWM, refer to the LPC1758 user manual for details | ||
+ | * Setup and provide the clock to PWM peripheral (PCLKSEL), refer to the LPC1758 user manual for details | ||
+ | * Reset the timer on Match Register 0 (MR0) | ||
+ | * Set the value for MR0 to get desired PWM rate | ||
+ | * Enable the timer/counter and PWM | ||
+ | * Enable PWM output | ||
+ | * In order to use PWM to control a servo, write values to Match Register of corresponding PWM channel | ||
=== Software Design === | === Software Design === | ||
− | + | [[File:CmpE146_S13_TP_system_flowchart.png|550px|thumb|center]] | |
+ | <div style="text-align: center;">'''Figure 12:''' Flowchart showing system upon start up </div> | ||
+ | |||
+ | <b>How to Send a Message</b><br> | ||
+ | Steps:<br> | ||
+ | 1. Send:AT <br> | ||
+ | 2. Send:At+CMGF=1<br> | ||
+ | 3. Send:AT+CMGS="XXXXXXXXXX" (X means phone number of the receiver)<br> | ||
+ | 4. wait for indicator '<' and start typing your message<br> | ||
+ | 5. when done Send character 'ctrl+z'<br> | ||
+ | |||
+ | <b>How to Make a phone Call</b><br> | ||
+ | Steps:<br> | ||
+ | 1. Send:AT<br> | ||
+ | 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 === | === Implementation === | ||
− | This | + | |
+ | [[File:CmpE146_S13_TP_blockDiagram.png|500px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 13: Block Diagram of the System</div> | ||
+ | |||
+ | <b>RFID Task </b><br> | ||
+ | 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". | ||
+ | |||
+ | <b>LCD Task </b><br> | ||
+ | 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. | ||
+ | |||
+ | <b>GSM Task</b><br> | ||
+ | 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. | ||
+ | |||
+ | [[File:CmpE146_S13_TP_new_text_task.png|500px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 14:''' Task to process newly received Text Message </div> | ||
+ | |||
+ | <b>New_Text Task </b><br> | ||
+ | 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. | ||
+ | |||
+ | [[File:CmpE146 S13 TP GSM task.png|400px|thumb|center]] | ||
+ | <div style="text-align: center;">'''Figure 15:''' GSM Task</div> | ||
== Testing & Technical Challenges == | == Testing & Technical Challenges == | ||
− | |||
− | |||
− | |||
− | |||
* Could not establish serial communication with GSM module v3 | * 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. | ** 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 | + | ** 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. | * GSM module is not sending back any acknowledgement signal or is not processing any AT command that I am sending to it. | ||
Line 212: | Line 308: | ||
** Sometime a delay is required before the next AT command can be sent. | ** 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. | |
+ | |||
+ | * The wireless carrier who makes the SIM card used in the GSM module plays a key role in the speed of sending/receiving messages. We used a T-Mobile SIM card (first AT&T SIM card did not work), and sometimes it takes very long to send/receive messages. | ||
+ | ** Move the device to another locations for better signals i.e. near the windows. | ||
+ | ** Use a SIM card from better wireless carriers. | ||
== Conclusion == | == Conclusion == | ||
− | + | We started off wanting to do a project that is unique and have not been done before. We learned how challenging it can be to tackle a project that was unfamiliar to us. Luckily we had Preet to help us with the coding. | |
+ | |||
+ | At first it was difficult for us to switch from using the LPC2148 and then transitioned over to using LPC1758 SJ One board. The learning curve was steep but rewarding. Especially in the end where now we are comfortable to write a task in new the FreeRTOS framework. There were times when we thought it may be impossible to finish this project in a such amount of time. But we kept trying hard to and was able to finish. | ||
+ | |||
+ | After completing this project, we believe our programming skills have dramatically improved. Many times our code lacked simple algorithms or functions such as strcmp() which could have made our life so much simpler in the beginning. Our knowledge of using different communication protocols such as UART and SPI have greatly improved. Overall, being able to finish this project was a great accomplishment and experience for us. The skills and knowledge that we take away from this project will definitely benefit us in our future. | ||
+ | |||
+ | The project can be extended in the future with more functions, for example, adding servo controlled cameras to capture images/videos of anyone trying to enter the door unauthorizedly, or adding infrared beams behind the door as another security in case of the lock is disable. | ||
+ | |||
=== Project Video === | === Project Video === | ||
− | + | [http://www.youtube.com/watch?v=LsHk_ty5q4k Demonstation Video] | |
=== Project Source Code === | === Project Source Code === | ||
− | + | * [https://sourceforge.net/projects/sjsus13/files/ Project source code is available at SourceForge] | |
== References == | == References == | ||
=== Acknowledgement === | === Acknowledgement === | ||
− | |||
− | + | Preet Kang <br> | |
− | + | Dr. Haluk Özemek | |
− | * DFROBOT's Wiki:http://www.dfrobot.com/wiki/index.php/GPS/GPRS/GSM_Module_V3.0_(SKU:TEL0051) | + | === References/Appendices === |
+ | |||
+ | * GSM Module Datasheet - DFROBOT's Wiki: | ||
+ | ** http://www.dfrobot.com/wiki/index.php/GPS/GPRS/GSM_Module_V3.0_(SKU:TEL0051) | ||
* SIM908 AT Command Manual_V1.01 | * SIM908 AT Command Manual_V1.01 | ||
− | * RFID ID-12 | + | * RFID ID-12 Datasheet |
− | + | * LPC1758 Datasheet | |
− | + | * Parallax Standard Servo Datasheet | |
− | + | * NHD-0420D3Z-FL-GBW-V3 LCD Datasheet |
Latest revision as of 21:37, 23 May 2013
Contents
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
- Communication with GSM
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
|
|
|
Week 2
|
|
|
Week 3
|
|
|
Week 4
|
|
|
Week 5
|
|
|
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
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.
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
Servos are controlled by sending them a pulse of variable width via control wire. The angle that a servo turns is determined by the duration of a pulse that is applied to the control wire. This is called Pulse width Modulation
(PWM). The servo expects to see a pulse every 20 ms. The length of the pulse will determine how far the motor turns. For example, with a regular standard servo, a 1.5 ms pulse will make the motor turn to the 90 degree position (neutral position); a less than 1.5 ms pulse will make the motor turn a certain angle to the left, depended on how small the pulse is in comparison to 1.5 ms; a more than 1.5 ms pulse will make the motor turn a certain angle to the right, depended on how large the pulse is in comparison to 1.5 ms.
In this project, the servo is used as a simulation for the door lock. It is interfaced to the SJ One board using PWM1.2 such that the control 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 (ID-12) is used to read data written in the RFID tags. It is used with a break out board for easier pins located and connected.
It is worth mentioning we first started with a ID-2 which does not come with an internal or external antenna. Users are required to create an antenna from coiling copper wires themselves. We did not have time to do that, so we ended up buying the ID-12LA which comes with an internal antenna. The following figures shows the pinout needed to communicate with this RFID device.
The only pins required to use this device are GND, +5V, and D0 for UART communications. It is interfaced to the SJ One board using UART 3 such that the TX pin (D0, pin 9) of the RFID reader is connected to the RX pin (P4.29) of UART 3 in the board.
Both RFID tags that come with the reader have a 12 bit string preloaded to the card and cannot be rewritten without some special tools.
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
How to write a driver for UART
Below are some basic steps to initialize the UARTs
- Configure pin select (PINSEL) for UART, refer to the LPC1758 user manual for details
- Setup and provide the clock to UART peripheral (PCLKSEL), refer to the LPC1758 user manual for details
- Write "putChar" and "getChar" functions for the UART to transmit and receive data
How to write a driver for PWM
Below are some basic steps to initialize the PWMs
- Power up the PWM, refer to the LPC1758 user manual for details
- Setup and provide the clock to PWM peripheral (PCLKSEL), refer to the LPC1758 user manual for details
- Reset the timer on Match Register 0 (MR0)
- Set the value for MR0 to get desired PWM rate
- Enable the timer/counter and PWM
- Enable PWM output
- In order to use PWM to control a servo, write values to Match Register of corresponding PWM channel
Software Design
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
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".
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.
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.
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.
- The wireless carrier who makes the SIM card used in the GSM module plays a key role in the speed of sending/receiving messages. We used a T-Mobile SIM card (first AT&T SIM card did not work), and sometimes it takes very long to send/receive messages.
- Move the device to another locations for better signals i.e. near the windows.
- Use a SIM card from better wireless carriers.
Conclusion
We started off wanting to do a project that is unique and have not been done before. We learned how challenging it can be to tackle a project that was unfamiliar to us. Luckily we had Preet to help us with the coding.
At first it was difficult for us to switch from using the LPC2148 and then transitioned over to using LPC1758 SJ One board. The learning curve was steep but rewarding. Especially in the end where now we are comfortable to write a task in new the FreeRTOS framework. There were times when we thought it may be impossible to finish this project in a such amount of time. But we kept trying hard to and was able to finish.
After completing this project, we believe our programming skills have dramatically improved. Many times our code lacked simple algorithms or functions such as strcmp() which could have made our life so much simpler in the beginning. Our knowledge of using different communication protocols such as UART and SPI have greatly improved. Overall, being able to finish this project was a great accomplishment and experience for us. The skills and knowledge that we take away from this project will definitely benefit us in our future.
The project can be extended in the future with more functions, for example, adding servo controlled cameras to capture images/videos of anyone trying to enter the door unauthorizedly, or adding infrared beams behind the door as another security in case of the lock is disable.
Project Video
Project Source Code
References
Acknowledgement
Preet Kang
Dr. Haluk Özemek
References/Appendices
- GSM Module Datasheet - DFROBOT's Wiki:
- SIM908 AT Command Manual_V1.01
- RFID ID-12 Datasheet
- LPC1758 Datasheet
- Parallax Standard Servo Datasheet
- NHD-0420D3Z-FL-GBW-V3 LCD Datasheet