Difference between revisions of "F13: Garage Parking Assistant"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Appendix)
(Project Source Code)
 
(90 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=== Grading Criteria ===
 
<font color="green">
 
*  How well is Software & Hardware Design described?
 
*  How well can this report be used to reproduce this project?
 
*  Code Quality
 
*  Overall Report Quality:
 
**  Software Block Diagrams
 
**  Hardware Block Diagrams
 
**:  Schematic Quality
 
**  Quality of technical challenges and solutions adopted.
 
</font>
 
 
 
== Garage Parking Assistant ==  
 
== Garage Parking Assistant ==  
 
Project by:
 
Project by:
Line 25: Line 13:
 
The project consists of two separate modules which communicate with each other wirelessly. One module is located in the garage while the other is located in the vehicle with the driver. Each module is designed around an SJOne board with ARM Cortex-M3 (LPC1758) microcontroller.
 
The project consists of two separate modules which communicate with each other wirelessly. One module is located in the garage while the other is located in the vehicle with the driver. Each module is designed around an SJOne board with ARM Cortex-M3 (LPC1758) microcontroller.
  
The garage module uses an ultrasonic rangefinder to measure the distance of an approaching vehicle. The distance will be displayed symbolically on an LED strip. The distance will be transmitted wireless using the onboard Nordic IC to the vehicle module. The vehicle module will open the garage door, using a dissected garage door opener. It will display the distance on a 7-segment LED display and sound an alarm when the vehicle reaches it's stopping point.
+
The garage module uses an ultrasonic rangefinder to measure the distance of an approaching vehicle. The distance will be displayed symbolically on an LED strip. The distance will be transmitted wireless using the onboard Nordic IC to the vehicle module. The vehicle module will receive the distance signal. It will open the garage door. It will display the distance on a 7-segment LED display and sound an alarm when the vehicle reaches it's stopping point.
  
 
=== Team Members & Responsibilities ===
 
=== Team Members & Responsibilities ===
Line 91: Line 79:
  
 
== Parts List & Cost ==
 
== Parts List & Cost ==
Give a simple list of the cost of your project broken down by components.  Do not write long stories here.
+
 
  
 
{| class="wikitable"
 
{| class="wikitable"
 +
! scope="col"| Item #
 +
! scope="col"| Part Description
 +
! scope="col"| Vendor
 
! scope="col"| Qty
 
! scope="col"| Qty
! scope="col"| Part
+
! scope="col"| Unit Cost
! scope="col"| Cost
+
! scope="col"| Total Cost
! scope="col"| Purchase from
 
 
|-
 
|-
|scope="row"| 2
+
|scope="row"| 1
|SJSU Board with LPC1758 microcontroller || $75 ||SJSU CmpE
+
|[http://www.socialledge.com/sjsu/index.php?title=SJ_One_Board SJOne Board (LPC1758)]||SJSU CmpE || 2 || $75 || $150
 
|-
 
|-
 
| scope="row"| 2
 
| scope="row"| 2
|Antennas || Provided by instructor ||  
+
|SMA Antennas || Instructor || 2 || $0 ($2) || $0 ($4)
 +
|-
 +
| scope="row"| 3
 +
||[http://www.adafruit.com/products/306#Description Addressable RGB LED Light Strip]|| Adafruit|| 1 || $29.95 || $29.95
 +
|-
 +
| scope="row"| 4
 +
||[http://www.maxbotix.com/documents/MB1010_Datasheet.pdf Ultrasonic Rangefinder]|| Sparkfun || 1 || $0 ($24.99) || $0 ($24.99)
 +
|-
 +
| scope="row"| 5
 +
||[http://www.homedepot.com/p/Chamberlain-Clicker-Universal-Remote-Control-KLIK1U/100609179#.UlICxxAkvwkUniversal Garage Door Remote]|| Home Depot || 1 || $34.97 || $34.97
 +
|-
 +
| scope="row"| 6
 +
||[http://srt.co.th/Products/Import_Products/Kepo/PDF/KPR-G3045R.pdf Piezo Buzzer] || Instructor || 1 || $0 ($2) || $0 ($2)
 +
|-
 +
| scope="row"| 7
 +
||Connectors for LED strip lights (JST plug and receptacle)|| Adafruit || 2 || $1.50 || $3
 +
|-
 +
| scope="row"| 8
 +
||  Vehicle Module enclosure || Daiso|| 1 || $1.50 || $1.50
 +
|-
 +
| scope="row"| 9
 +
|| [http://www.adafruit.com/products/903?gclid=CP3psejPnrsCFclQOgoda1sAbwGarage Module enclosure] ||Adafruit || 1 || $9.95 || $9.95
 +
|-
 +
| scope="row"| 10
 +
|| [http://www.adafruit.com/products/830 4 x AA battery holder] ||Adafruit  || 1 || $2.95 || $2.95
 
|-
 
|-
| scope="row"| 1
+
| scope="row"| 11
||Addressable RGB LED Light Strip|| $29.95 || Adafruit.com
+
|| [http://www.adafruit.com/products/368 Female DC power adapter - 2.1mm] ||Adafruit  || 1 || $2.00  || $2.00
 
|-
 
|-
| scope="row"| 1
+
| scope="row"| 12
||Ultrasonic Rangefinder|| Provided by instructor ($25.95) || Sparkfun.com
+
|| [http://www.adafruit.com/products/276 5V 2A switching power supply] ||Adafruit  || 1 || $9.95 || $9.95
 
|-
 
|-
| scope="row"| 1
+
| scope="row"| 13
||N-Channel MOSFET|| $0.95 || Sparkfun.com
+
|| Ribbon cable ||Anchor Electronics  || 1 || $1.27 || $1.27
 
|-
 
|-
| scope="row"| 1
+
| scope="row"| 14
||Universal Garage Door Remote|| $34.97 || Home Depot / Walmart
+
|| [http://www.digikey.com/product-search/en?WT.z_header=search_go&lang=en&site=us&keywords=1241-1053-ND&x=11&y=13&formaction=on Screws nuts and standoffs] ||Digikey  || 2 || $4.00 || $8.00 
 
|-
 
|-
| scope="row"| 1
+
| scope="row"| 15
||Piezo Buzzer || Provided by instructor ||
+
|| [http://www.newegg.com/Product/Product.aspx?Item=9SIA27C12M7437 Mini USB Type-B Male socket connectors (includes 10)] ||Newegg  || 1 || $4.34 || $4.34
 
|-
 
|-
| scope="row"| 2
+
| scope="row"| 16
||Connectors for LED strip lights (JST plug and receptacle)|| $1.50 || Adafruit.com
+
|| Batteries (4-pack) || Target || 1 || $3.99 || $3.99
 +
|-
 +
| scope="row"|
 +
|| Total||  ||  || || $261.87
 
|}
 
|}
  
 
== Design & Implementation ==
 
== 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 ===
 
=== Hardware Design ===
Discuss your hardware design here. Show detailed schematics, and the interface here.
+
The design consists of two separate hardware components that communicate with each other wirelessly. The components are labeled the Garage Module and Vehicle Module.  
  
'''Rangefinder'''
+
The Garage Module is designed to be mounted on the wall of the garage, facing the oncoming vehicle. The Vehicle Module is designed to be mounted on the dashboard of the vehicle within the driver's field of vision.
  
The garage module uses an ultrasonic rangefinder to detect the distance of the approaching vehicle. An ultrasonic rangefinder was chosen over other rangefinder types because it has the best balance of range (0 - 21ft) and resolution (1 inch) for our application. The ultrasonic rangefinder outputs an analog signal to represent the distance to the vehicle. The analog signal is connected to an ADC input on the microcontroller which translates the signal to a numeric value. The microcontroller uses this value to compute the distance in inches.
+
==== Garage Module ====
  
The garage module symbolically displays the distance of the approaching vehicle on an LED strip. The LED strip houses 32, individually addressable, tri-color LEDs. Each LED has a red, green, and blue component; which can be mixed to output any visible color. The LED strip contains built in LPD8806 LED drivers. The LED drivers are interfaced via a daisy-chain SPI bus. Note: This SPI bus uses only two signals: Clock and MOSI.  
+
The SJOne board and ultrasonic rangefinder are mounted in a compact plastic enclosure. The top of the enclosure is transparent so that the electronics, including on-board LED display, are visible when the enclosure is sealed. The LED strip is connected to the enclosure with a 4-wire ribbon cable. All parts of the garage module are powered by a single 5V, 2A AC/DC power converter. <br/><br/>
  
The module is designed toggle the color of the individual between green and red depending on the distance of the the approaching vehicle. As the vehicle approaches, the LED's will, one-by-one, turn from green to red. When the vehicle reaches its stop point, the entire LED strip will flash red on/off.
+
'''Rangefinder'''
 
 
The modules will communicate with each other using the onboard Nordic chip. The garage module uses this interface to transmit the distance to the vehicle module.
 
  
One of the garage microcontroller's responsibilities is to determine the distance of the approaching vehicle. The garage microcontroller uses an ultrasonic rangefinder to accomplish this task. The ultrasonic rangefinder measures the distance to the closest object and outputs it as an analog signal to the microcontroller. The microcontroller uses the onboard ADC to convert the analog signal to data. The data is then used to compute the distance, in feet.
+
The Garage module uses an ultrasonic rangefinder to detect the distance of the approaching vehicle. An ultrasonic rangefinder was chosen over other rangefinder types because it has the best balance of range (0 - 21ft) and resolution (1 inch) for our application. The ultrasonic rangefinder outputs an analog signal to represent the distance to the approaching vehicle. The analog signal is connected to an ADC input on the microcontroller which translates the signal to a data. The microcontroller uses this data to compute the distance in inches.
  
The photo below depicts a test of the ultrasonic rangefinder. The rangefinder is positioned to measure the distance to a nearby wall. The microcontroller is processing the analog distance signal and outputing the distance on it's onboard LED display. Note: The rangefinder and microcontroller are mounted in a temporary electronic enclosure for easy testing. The final design will be mounted in a compact plastic case.
+
The photo below depicts a close-up of the ultrasonic rangefinder. The rangefinder is mounted pointing outwards to detect the approaching vehicle. The microcontroller processes the analog distance signal and outputs the distance on the onboard LED display.
  
 
[[File:GarageParkingAssistant_Rangefinder.jpg|480px|Close-up of rangefinder]]
 
[[File:GarageParkingAssistant_Rangefinder.jpg|480px|Close-up of rangefinder]]
Line 149: Line 163:
 
'''LED Strip'''
 
'''LED Strip'''
  
A second responsibility of the garage microcontroller is to symbolically display the distance of the approaching vehicle on an LED strip. The LED's will incrementally turn on and change color as the vehicle approaches. When the vehicle reaches its final position the entire LED strip will flash red to indicate to the driver to stop.
+
The Garage module symbolically displays the distance of the approaching vehicle on an LED strip. The LED strip houses 32, individually addressable, tri-color LEDs. Each LED has a red, green, and blue component; which can be mixed to output any visible color. The LED strip contains built in LPD8806 LED drivers. The LED drivers are interfaced via a daisy-chain SPI bus. Note: This SPI bus uses only two signals: Clock and MOSI.
 +
 
 +
The Garage module toggles the color of the individual LEDs between green and red depending on the distance of the the approaching vehicle. As the vehicle approaches, the LED's will incrementally, turn from green to red. When the vehicle reaches its stop point, the entire LED strip will flash red on/off.
  
The photo below depicts the LED light strip and the temporary enclosure mounted on the garage wall. The three left-most LEDs are turned on as a white color. The LED strip is connected to the enclosure using a ribbon cable. The enclosure is powered by an external 5V wall adapter.
+
The photo below depicts the LED light strip and the garage module enclosure mounted on the garage wall. It is clear to see that the approaching vehicle is a little more than 1/2 the distance to the stop point. The ribbon cable to the left connects the LED strip to the enclosure. The cable to the right connects the enclosure to the 5V wall adapter.
  
 
[[File:GarageParkingAssistant LEDStrip.JPG|480px|LED strip and garage module]]
 
[[File:GarageParkingAssistant LEDStrip.JPG|480px|LED strip and garage module]]
 
<br/>''LED strip and garage module''<br/><br/>
 
<br/>''LED strip and garage module''<br/><br/>
 
 
  
 
'''Wireless'''  
 
'''Wireless'''  
  
A third responsibility of the garage microcontroller is to wirelessly transmit the distance to the vehicle microcontroller. The garage microcontroller uses the onboard Nordic wireless radio in conjunction with an SMA antenna for maximum range.
+
Garage module's microcontroller wirelessly transmits the distance to the Vehicle module's microcontroller. The garage microcontroller uses the onboard Nordic wireless radio in conjunction with an SMA antenna for maximum range.
  
 
[[File:GarageParkingAssistant_GarageMod.jpg|480px|Close-up of garage module with SMA antenna]]
 
[[File:GarageParkingAssistant_GarageMod.jpg|480px|Close-up of garage module with SMA antenna]]
 
<br/>''Close-up of garage module with SMA antenna''<br/><br/>
 
<br/>''Close-up of garage module with SMA antenna''<br/><br/>
  
'''Garage Door Opener'''
+
====Vehicle Module====
 +
 
 +
The SJ One board, piezo buzzer, and garage door remote control are contained in a compact transparent plastic enclosure. The SJ One board is mounted on lid of the enclosure with the on-board LED display visible to the user using standoffs. The piezo and remote control are resting at the bottom of the enclosure facing the bottom. All parts of the Vehicle module are powered either by 4-battery pack modified to connect to mini USB or USB car charger and cable.
 +
 
 +
'''Garage Door Remote Control'''
 +
 
 +
The Vehicle module opens the garage door by sending GPIO signal from the microcontroller (pin P1.28) to the garage door remote control.  The GPIO is signal is wired to the back of the pushbutton switch on the remote control. The garage door remote control is universal garage door remote and needs to be pre-programmed to communicate with the garage door prior to installation in the enclosure. In addition, a LED on the SJ OneBoard will be lit up for the time duration when GPIO signal is sent.
  
The first task of the car microcontroller is to open the garage door by sending a GPIO signal to the remote controller when the car microcontroller receives data from garage microcontroller.  
+
The photo of the Vehicle module back side shows a rectangular garage door opener with the pushbutton cover removed.  The photo of the Vehicle module front side show the LED that will light up when GPIO signal is sent.
  
The photo below shows a rectangular garage door opener with the pushbutton cover removed connected to the car microcontroller.
+
'''7-segment LED Display'''
  
'''LED Display - Car Side'''
+
The Vehicle module displays the distance (inches) of the approaching vehicle on a 2-digit, 7 segment LED display, which is on the microcontroller. 
  
The second task of the car microcontroller is to display the distance of the approaching vehicle on a 2-digit LED display on the car microcontroller. It requires the car microcontroller to receive distance data wirelessly from the garage microcontroller.  
+
The photo of the Vehicle module front side shows the 2-digit LED display on the microcontroller.
  
The photo below shows the 2-digit LED display on the car microcontroller.
+
'''Alarm (Piezo Buzzer)'''
 +
The vehicle module uses piezo buzzer to alert the driver to stop the car because it has exceeded it's stop distance from garage wall.  The piezo buzzer is rated for 5V and max of 15mA at 4.5KHz frequency.
 +
In order to produce a sound, the piezo buzzer is sent PWM signal from the SJ OneBoard microcontroller pin P1.20 as shown in the schematic.  
  
'''Alarm'''
+
The photo of the Vehicle module back side shows the piezo buzzer.
  
The third task of the car microcontroller is to sound an alarm to alert the driver that the car is too close to the car. At a certain distance, the piezo buzzer will make noise based upon the distance data sent wirelessly from the garage microcontroller. Tentatively, the buzzer will sound off about 2 feet from the wall.
+
Below are photos of the front and back side of the Vehicle Module Hardware. <br/>
 +
[[File:GarageParkingAssistantCarFront.PNG|480px]]
  
The photo below shows the piezo buzzer connected to  the car microcontroller.
+
''Vehicle Module Hardware - Front side''
  
[[File:GarageParkingAssistantCarFront.PNG|link=GarageParkingAssistantCarFront|Garage Parking Assistant - Vehicle Module (Front Side)]]
+
[[File:GarageParkingAssistantCarBack.PNG|350px]]
  
[[File:GarageParkingAssistantCarBack.PNG|link=GarageParkingAssistantCarFront|Garage Parking Assistant - Vehicle Module (Back Side)]]
+
''Vehicle Module Hardware - Back side''
  
 
=== Hardware Interface ===
 
=== Hardware Interface ===
In this section, you can describe how your hardware communicates, such as which BUSes usedYou 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.
+
{| class="wikitable"
 +
|-
 +
|align="top"|The hardware interface consists of five interfaces. The garage module uses the microcontroller's ADC driver and SPI driver. The vehicle module use the microcontroller's GPIO and PWM drivers. Wireless communication uses a wireless mesh network and SPI driver. These drivers are already provided with the LPC1758 microcontroller. 
 +
 
 +
The Hardware Interface schematic is shown on the right.
 +
 
 +
'''SPI Interface'''
 +
 
 +
The Garage module LPC1758 Micro-controller communicates with the Ultrasonic rangefinder through the SPI interface.
 +
The LED drivers are interfaced via a daisy-chain SPI bus. Note: This SPI bus uses only two signals: Clock and MOSI.
 +
The garage module toggles the color of the individual LEDs between green and red depending on the distance of the the approaching vehicle.
 +
As the vehicle approaches, the LED's will incrementally, turn from green to red.
 +
When the vehicle reaches its stop point, the entire LED strip will flash red on/off.   
 +
Note: The SPI 1 driver was created by copying the existing SPI 0 driver
 +
 
 +
'''ADC Interface'''
 +
 
 +
The Garage module LPC1758 Micro-controller communicates with LED Strip through ADC interface.
 +
The ultrasonic rangefinder outputs an analog signal to represent the distance to the approaching vehicle.
 +
The analog signal is connected to an ADC input on the microcontroller which translates the signal to a data.
 +
The microcontroller uses this data to compute the distance in inches.
 +
 
 +
'''PWM Interface'''
 +
 
 +
The Vehicle module LPC1758 Micro-controller communicates with piezo buzzer through PWM interface.
 +
In order to produce a sound, PWM signal is sent to the piezo buzzer at a human hearing frequency between 20Hz to 2000Hz and duty cycle greater than 0%.
 +
 
 +
'''GPIO Interface'''
 +
 
 +
The LPC1758 Micro-controller communicates with garage door remote through GPIO interface.
 +
In order to open the garage, GPIO signal is manipulated into 500 ms pulse signal to simulate the pressing of push button switch on the garage remote.  In addition, GPIO signal will be sent to light up LED on-board the microcontroller to indicate the signal to open garage door is being sent.
  
[[File:GarageParkingAssistant_BlockDiag_Nov5.jpg]]
+
'''Mesh Interface'''
 +
 
 +
The Vehicle module LPC1758 Micro-controller communicates with Garage module LPC1758 Micro-controller through low mesh interface.
 +
The vehicle module receives mesh packet from Garage Module that contains distance data.
 +
|[[File:GarageParkingAssistant HWSchematic.png|450px|right]]
 +
'''Hardware Interface schematic'''
 +
|}
  
 
=== Software Design ===
 
=== 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.
+
Each hardware component runs on it's own separate build file. Both software builds were designed using the polling method to obtain sensor and communication inputs. The polling method was chosen for it's simplicity of use.
 +
 
 +
 
 +
'''Garage Module Pseudocode and Software Flow Diagram'''<br/>
 +
{| class="wikitable"
 +
|-
 +
|align="top"|Below is psuedocode for Garage Module software design.
  
'''Garage Module'''<br/>
 
 
main()
 
main()
 
*Initialize devices
 
*Initialize devices
Line 227: Line 291:
 
****Waits a moment, and then turns them all off <br/>
 
****Waits a moment, and then turns them all off <br/>
  
'''Vehicle Module'''<br/>
+
|[[File:GarageFlowDiagram.jpg|350px|Garage Module software flow diagram]]
placeholder
+
<br/>''Garage Module software flow diagram''<br/><br/>
 +
|}
 +
 
 +
 
 +
'''Vehicle Module Pseudocode and Software Flow Diagram'''<br/>
 +
{| class="wikitable"
 +
|-
 +
|align="top"|Main() function
 +
*Clear LED display
 +
* while(1) //This is continuous loop
 +
** Call car() to perform Vehicle Module functions
 +
 
 +
Car() function
 +
*Set up P1.20 as GPIO output signal for Garage remote control
 +
*Set up P1.1 as GPIO output signal for garage LED2 indicator
 +
*Setup PWM4 signal for 4.5KHz frequency
 +
*Set distance to 0 inches and count to 0
 +
*Initialize garageIsOpen variable to false.
 +
 
 +
while(1) //This is continuous loop
 +
*If mesh packet is received from Garage module
 +
**If garage is not open
 +
*** Send 500ms pulse  to open garage door
 +
*** Light up open garage door LED indicator for 500ms
 +
*** Set GarageIsOpen variable to true
 +
** Deform mesh packet to get distance data in inches
 +
** If distance > 99
 +
*** Display 99 inches on 2-digit LED display
 +
** If distance < 99
 +
*** Display actual distance on 2-digit LED display
 +
**If distance > stop distance
 +
*** Send PWM signal to sound piezo buzzer
 +
**If distance < stop distance
 +
*** Stop sending PWM signal to piezo buzzer
 +
* Else no mesh packet is received from Garage module
 +
**Increment count by 1
 +
**If count > 1000
 +
***Clear LED display
 +
***Stop sending PWM signal to piezo buzzer
 +
 
 +
| [[File:GarageParkingAssistantVehicleFlowDiagram.png|550px]]
 +
''Software flow diagram - Vehicle Module''
 +
|}
  
 
=== Implementation ===
 
=== Implementation ===
This section includes implementation, but again, not the details, just the high levelFor 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 FlashYou can include sub-sections for each of your component implementation.
+
 
 +
 
 +
'''Rangefinder to microcontroller''' <br/>
 +
The rangefinder to microcontroller communication was implemented using an ADC. The rangefinder outputs an analog voltage between 0-3.3V. This voltage corresponds to the distance of the approaching vehicle between 0-254 inches. In order to obtain more stable readings we sample the ADC 1000 times and use the average for each reading. Additionally, we opted to only process the data when the distance was less than 99 inches. We did this for two reasons. First, output of the rangefinder becomes very jittery at distances greater than ~10ft, so we chose to ignore those distances. Second, the on-board LED display on the board only has two digits, so 99 is the greatest distance (in inches) that we could display.
 +
 
 +
'''Microcontroller to LED strip'''<br/>
 +
The microcontroller to LED strip communication was implemented using SPI. Each LED on the strip is powered by a driver IC (LPD8806).  The driver IC's on the strip are daisy-chained together. Only two data pins from the microcontroller are used: MOSI and CLK. All driver IC's are inherently enabled. The MOSI pin from the microcontroller only connects to the first driver IC, to start the daisy chain. Because the drivers are daisy-chained, any time one driver gets updated, they all get updated.
 +
 
 +
'''Garage Module to Vehicle Module'''<br/>
 +
The garage module to vehicle module communication was implemented using the Nordic wireless IC on each board. The mesh network drivers were used to interface with the Nordic IC. The garage module tranmits the distance and the vehicle module receives it. Acknowledgement was not used to improve throughput.
 +
 
 +
'''Microcontroller to Piezo Buzzer''' <br/>
 +
The microcontroller to piezo buzzer communication was implemented using PWM.  The microcontroller outputs PWM signal of approximately 3.3V.  The piezo buzzer operates nominally at 5V.  The volume of the alarm can be adjusted by the duty cycle and different sounds can be produced based upon different frequencies.
 +
In the alarm application, the frequency was set to within the human hearing frequency range and duty cycle is set at 50% for maximum volume. The software initializes the PWM output and the frequencyUsing  set(duty cycle) function from the PWM class, 50% is used to turn on alarm and 0% is used to turn OFF alarm.
 +
 
 +
'''Microcontroller to Garage Door Remote Control''' <br/>
 +
The microcontroller to garage door remote control communication was implemented using GPIO. To open the garage door, a pulse equivalent to pushing down on a push button switch is sent. First, the GPIO pin is  initialized by setting the pin corresponding to FIODIR to output. In order to simulate 500 millisecond pulse, microcontroller sends high (3.3V) GPIO signal for 500 milliseconds and then sets it low using FIOSET and FIOCLR.
 +
 
 +
'''Microcontroller to 7-segment LED display''' <br/>
 +
The microcontroller to 7-segment LED display communication was implemented using I2C.  However, LED class and its functions have already been created to display digits to LED display so LED display code development was not needed.  The set(char num) function was called to display distance on LED.  If the distance exceeds 99 inches, the LED display will be set to 99After not receiving data from Garage module for 1000 mesh packets, the clear() function was used to clear LED display.
  
 
== Testing & Technical Challenges ==
 
== 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:
 
  
 
=== Garage Module Testing ===
 
=== Garage Module Testing ===
Line 244: Line 365:
 
1. The first garage module function tested was the ADC. To test the ADC we programmed the garage module to output the distance on the on-board 7-segment display. We then practiced moving the rangefinder around and pointing at various objects to get a feel for its capabilities.
 
1. The first garage module function tested was the ADC. To test the ADC we programmed the garage module to output the distance on the on-board 7-segment display. We then practiced moving the rangefinder around and pointing at various objects to get a feel for its capabilities.
  
[[File:GarageParkingAssistant Rangefinder 12Nov.jpg|480px|Early stage testing of ultrasonic rangefinder]]
+
[[File:GarageParkingAssistant Rangefinder 12Nov.jpg|480px|Early stage testing of ultrasonic rangefinder and ADC]]
<br/>''Early stage testing of ultrasonic rangefinder''<br/><br/>
+
<br/>''Early stage testing of ultrasonic rangefinder and ADC''<br/><br/>
  
 
Below is a close-up of the microcontroller. The LED display indicates the distance to the wall: 7 feet.
 
Below is a close-up of the microcontroller. The LED display indicates the distance to the wall: 7 feet.
Line 266: Line 387:
  
 
=== Vehicle Module Testing ===
 
=== Vehicle Module Testing ===
The Vehicle Module was divided into 2 Tests:
+
The Vehicle Module individual testing consisted of:
  
1) GPIO was initially placed into a separate function and a pushbutton on the SJSU OneBoard to send GPIO signal to the garage remote controller.  The garage remote controller LED light was monitored to ensure it lit up when GPIO signal was sent.
+
1. GPIO was initially placed into a separate function, in which a pushbutton on the SJ OneBoard sends GPIO signal to the garage remote control.  The garage remote control LED light was monitored to ensure it lit up when GPIO signal was sent.
  
2) Piezo Buzzer was tested for different frequencies to determine the frequency with the loudest noise. The piezo buzzer were tested at the following frequencies:  2kHz, 4kHz, 4.5kHz, 6kHz, and 10kHz. It was determined the loudest sound was from the piezo buzzer's datasheet resonant frequency of 4.5kHz at 85dB.
+
2. Piezo Buzzer was tested for different frequencies to determine the frequency with the loudest noise. The piezo buzzer was tested at the following frequencies:  2kHz, 4kHz, 4.5kHz, 6kHz, and 10kHz. It was determined the loudest sound was from the piezo buzzer's datasheet resonant frequency of 4.5kHz at 85dB.
  
The integration testing consisted of:
 
  
1) Initial test to ensure the Vehicle and Garage module can perform wireless communicate by following the sample commander and example.
+
The Vehicle Module integration testing consisted of:
  
2) Tested the distance data is being sent from Garage module to Vehicle module.  We used printfs and display on the 7 segement LED on both modules.
+
1. Initial test to ensure the Vehicle and Garage module can perform wireless communication by following the commander and light node example.
  
3) Tested the garage remote control will activate only on the first package received from garage controller
+
2. Tested the distance data is being sent from Garage module to Vehicle module.  We used printfs and displayed on the 7 segment LED on both modules.
  
4) Tested Piezo buzzer turn off at less than per-determined stop distance.  However, we also discovered piezo buzzer needs to stop when it stops receiving wireless signal from Garage Module.
+
3. Tested the garage remote control will activate only on the first package received from garage microcontroller
 +
 
 +
4. Tested piezo buzzer will turn off at less than per-determined stop distance.  However, we also discovered piezo buzzer needs to stop when it stops receiving wireless signal from Garage Module.
  
 
===System Integration Testing===
 
===System Integration Testing===
1. Board to board communication
+
1. Board to board communication: The first step to integrating our system was to establish wireless communication between the two boards. For this task, the garage module read the distance from the rangefinder and displayed it on the LED. At the same time it also transmitted the value to the vehicle module, which also displayed the value on the LED. Verifying good communication was as simple as comparing the two LED's side by side and verifying that they were in sync.
2. Whole system  
+
 
 +
2. Complete system: The complete system test was performed exactly as the product is designed to work during actual use. We mounted the garage module on the wall of the garage. We mounted the vehicle module in the car. We started with the car out-of-range from the garage module. We drove the vehicle towards the garage and verified that the vehicle module flashed it's lights and opened the garage door when it received a signal from the garage module. We continued driving the vehicle into the garage towards the garage module, verifying that the distance displayed on the vehicle module and the lights on the LED strip decremented properly. Finally, as the vehicle reached its stop point, we verified that the vehicle module sounded the audible alarm and the garage module flashed the red LEDs on the strip.
  
 
=== My Issue #1: RS232 and UART ===
 
=== My Issue #1: RS232 and UART ===
Line 290: Line 413:
  
 
=== My Issue #2: PWM and Piezo buzzer ===
 
=== My Issue #2: PWM and Piezo buzzer ===
The PWM outputs a continuous pulse of varying duty cycle.  However, there was an issue with my computer in which no sound was produced after the initial click. Once the new SourceForge was used, the PWM signal worked. However, during the time I was troubleshooting to ensure the piezo buzzer was not damaged, GPIO output was used to generate PWM.  A PWM signal was generated when implementing delays and loop and setting GPIO signal high or low.
+
The SJ One Board has capability to output PWM signal to create a sound from the piezo buzzer.  However, there was an issue with my computer in which no sound was produced after the initial click. Once the new SourceForge was used, the PWM signal worked. However, during the time I was troubleshooting to ensure the piezo buzzer was not damaged, GPIO output was used to generate PWM.  A PWM signal was generated when implementing delays, a for loop and setting GPIO signal high or low.
 +
 
 +
=== My Issue #3: Daisy-chain SPI and Nordic wireless ===
 +
We were having an issue with the LED strip displaying properly. It was functioning perfectly until we started transmitting using the Nordic IC. The strip would output the wrong colors and the LED patterns became garbled. The issue was that we were using SPI0 to communicate with both the LED strip and the Nordic IC. Normally having multiple devices on an SPI bus is not an issue, but we were the exception. We were using a daisy-chained LED strip, which means that all of the chips are inherently enabled. So every time we communicated with the Nordic chip we were also sending data to the LED strip. The fix was simple: We moved the LED strip over to SPI1.
  
 
== Conclusion ==
 
== Conclusion ==
Conclude your project hereYou can recap your testing and problemsYou should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?
+
At the start of this class, neither of us had very much previous experience with microcontrollersBut we gained a lot of new knowledge in this class through lectures and hands-on exercises. We were able to learn how to communicate using GPIO, ADC, PWM, and SPI interfacesWe were able to use the knowledge that we gained in this class to design, build, troubleshoot, test and deliver a fully functional product that met all of our specifications. The Garage Parking Assistant was an immense success.  
 +
 
 +
If there was more time, we would have liked to implemented the following additions:
 +
* Vehicle module will determine whether to open/close garage door based distance data transmitted by Garage module
 +
* Allow user to program stopping point through push buttons on vehicle module
  
 
=== Project Video ===
 
=== Project Video ===
Line 301: Line 431:
  
 
=== Project Source Code ===
 
=== Project Source Code ===
Send me your zipped source code and I will upload this to SourceForge and link it for you.
+
* [https://sourceforge.net/projects/sjsu/files/CmpE240_LM_F2013/ Project Source Code]
  
 
== References ==
 
== References ==
 
=== Acknowledgement ===
 
=== Acknowledgement ===
Any acknowledgement that you may wish to provide can be included here.
+
We would like to thank Preet for teaching a successfully interesting and fun class.
  
 
=== References ===
 
=== References ===
Line 315: Line 445:
 
[http://github.com/adafruit/LPD8806 LPD8806 LED Driver Library] <br/>
 
[http://github.com/adafruit/LPD8806 LPD8806 LED Driver Library] <br/>
 
[http://www.maxbotix.com/documents/MB1010_Datasheet.pdf LV-EZ Ultrasonic Rangefinder Datasheet] <br/>
 
[http://www.maxbotix.com/documents/MB1010_Datasheet.pdf LV-EZ Ultrasonic Rangefinder Datasheet] <br/>
 +
[http://www.avs4you.com/AVS-Video-Editor.aspx AVS Video Editor] <br/>

Latest revision as of 03:54, 8 December 2013

Garage Parking Assistant

Project by: Eric Maki & Kathryn Ng

Abstract

The purpose of this project is to build a multifunctional parking assistant. The parking assistant will simplify the driver’s task of parking a car in a garage. The parking assistant will automatically open the garage door as the vehicle approaches the garage. Once the vehicle is inside the garage, the parking assistant will notify the driver of the vehicle's position relative to a predetermined stop point. When the vehicle reaches the stop point, the parking assistant will alert the driver with audible and visual cues.

Objectives & Introduction

The project consists of two separate modules which communicate with each other wirelessly. One module is located in the garage while the other is located in the vehicle with the driver. Each module is designed around an SJOne board with ARM Cortex-M3 (LPC1758) microcontroller.

The garage module uses an ultrasonic rangefinder to measure the distance of an approaching vehicle. The distance will be displayed symbolically on an LED strip. The distance will be transmitted wireless using the onboard Nordic IC to the vehicle module. The vehicle module will receive the distance signal. It will open the garage door. It will display the distance on a 7-segment LED display and sound an alarm when the vehicle reaches it's stopping point.

Team Members & Responsibilities

  • Eric - Garage Module
    • Measure approaching distance
    • Transmit distance
    • Display closing distance
    • Display stop point
  • Kathryn - Vehicle Module
    • Receive approaching distance
    • Open garage door
    • Display closing distance
    • Sound alarm

Schedule

Week# Date Task Status
1 10/08/13 Proposal due. Order parts. Completed task on time.
2 10/15/13 All parts arrive. Write code to open garage door. Completed task on time.
3 10/22/13 Establish board-to-board wireless connection Completed task on time.
4 10/29/13 Start working on tasks listed on 11/5 and 11/12. Completed task on time.
5 11/05/13 Garage microcontroller: Range finder. Vehicle microcontroller: LED display Completed task on time.
6 11/12/13 Garage microcontroller: LED strip functional. Vehicle microcontroller: Piezo functional Completed task on time.
7 11/19/13 Complete garage/vehicle module integration. Start system testing. Completed task on time.
8 11/26/13 Complete system testing. Practice Demo. Completed task on time.
9 12/03/13 Complete demonstration. Completed task on time.
10 12/07/13 Complete report. Completed task on time.

Parts List & Cost

Item # Part Description Vendor Qty Unit Cost Total Cost
1 SJOne Board (LPC1758) SJSU CmpE 2 $75 $150
2 SMA Antennas Instructor 2 $0 ($2) $0 ($4)
3 Addressable RGB LED Light Strip Adafruit 1 $29.95 $29.95
4 Ultrasonic Rangefinder Sparkfun 1 $0 ($24.99) $0 ($24.99)
5 Garage Door Remote Home Depot 1 $34.97 $34.97
6 Piezo Buzzer Instructor 1 $0 ($2) $0 ($2)
7 Connectors for LED strip lights (JST plug and receptacle) Adafruit 2 $1.50 $3
8 Vehicle Module enclosure Daiso 1 $1.50 $1.50
9 Module enclosure Adafruit 1 $9.95 $9.95
10 4 x AA battery holder Adafruit 1 $2.95 $2.95
11 Female DC power adapter - 2.1mm Adafruit 1 $2.00 $2.00
12 5V 2A switching power supply Adafruit 1 $9.95 $9.95
13 Ribbon cable Anchor Electronics 1 $1.27 $1.27
14 Screws nuts and standoffs Digikey 2 $4.00 $8.00
15 Mini USB Type-B Male socket connectors (includes 10) Newegg 1 $4.34 $4.34
16 Batteries (4-pack) Target 1 $3.99 $3.99
Total $261.87

Design & Implementation

Hardware Design

The design consists of two separate hardware components that communicate with each other wirelessly. The components are labeled the Garage Module and Vehicle Module.

The Garage Module is designed to be mounted on the wall of the garage, facing the oncoming vehicle. The Vehicle Module is designed to be mounted on the dashboard of the vehicle within the driver's field of vision.

Garage Module

The SJOne board and ultrasonic rangefinder are mounted in a compact plastic enclosure. The top of the enclosure is transparent so that the electronics, including on-board LED display, are visible when the enclosure is sealed. The LED strip is connected to the enclosure with a 4-wire ribbon cable. All parts of the garage module are powered by a single 5V, 2A AC/DC power converter.

Rangefinder

The Garage module uses an ultrasonic rangefinder to detect the distance of the approaching vehicle. An ultrasonic rangefinder was chosen over other rangefinder types because it has the best balance of range (0 - 21ft) and resolution (1 inch) for our application. The ultrasonic rangefinder outputs an analog signal to represent the distance to the approaching vehicle. The analog signal is connected to an ADC input on the microcontroller which translates the signal to a data. The microcontroller uses this data to compute the distance in inches.

The photo below depicts a close-up of the ultrasonic rangefinder. The rangefinder is mounted pointing outwards to detect the approaching vehicle. The microcontroller processes the analog distance signal and outputs the distance on the onboard LED display.

Close-up of rangefinder
Close-up of rangefinder

LED Strip

The Garage module symbolically displays the distance of the approaching vehicle on an LED strip. The LED strip houses 32, individually addressable, tri-color LEDs. Each LED has a red, green, and blue component; which can be mixed to output any visible color. The LED strip contains built in LPD8806 LED drivers. The LED drivers are interfaced via a daisy-chain SPI bus. Note: This SPI bus uses only two signals: Clock and MOSI.

The Garage module toggles the color of the individual LEDs between green and red depending on the distance of the the approaching vehicle. As the vehicle approaches, the LED's will incrementally, turn from green to red. When the vehicle reaches its stop point, the entire LED strip will flash red on/off.

The photo below depicts the LED light strip and the garage module enclosure mounted on the garage wall. It is clear to see that the approaching vehicle is a little more than 1/2 the distance to the stop point. The ribbon cable to the left connects the LED strip to the enclosure. The cable to the right connects the enclosure to the 5V wall adapter.

LED strip and garage module
LED strip and garage module

Wireless

Garage module's microcontroller wirelessly transmits the distance to the Vehicle module's microcontroller. The garage microcontroller uses the onboard Nordic wireless radio in conjunction with an SMA antenna for maximum range.

Close-up of garage module with SMA antenna
Close-up of garage module with SMA antenna

Vehicle Module

The SJ One board, piezo buzzer, and garage door remote control are contained in a compact transparent plastic enclosure. The SJ One board is mounted on lid of the enclosure with the on-board LED display visible to the user using standoffs. The piezo and remote control are resting at the bottom of the enclosure facing the bottom. All parts of the Vehicle module are powered either by 4-battery pack modified to connect to mini USB or USB car charger and cable.

Garage Door Remote Control

The Vehicle module opens the garage door by sending GPIO signal from the microcontroller (pin P1.28) to the garage door remote control. The GPIO is signal is wired to the back of the pushbutton switch on the remote control. The garage door remote control is universal garage door remote and needs to be pre-programmed to communicate with the garage door prior to installation in the enclosure. In addition, a LED on the SJ OneBoard will be lit up for the time duration when GPIO signal is sent.

The photo of the Vehicle module back side shows a rectangular garage door opener with the pushbutton cover removed. The photo of the Vehicle module front side show the LED that will light up when GPIO signal is sent.

7-segment LED Display

The Vehicle module displays the distance (inches) of the approaching vehicle on a 2-digit, 7 segment LED display, which is on the microcontroller.

The photo of the Vehicle module front side shows the 2-digit LED display on the microcontroller.

Alarm (Piezo Buzzer) The vehicle module uses piezo buzzer to alert the driver to stop the car because it has exceeded it's stop distance from garage wall. The piezo buzzer is rated for 5V and max of 15mA at 4.5KHz frequency. In order to produce a sound, the piezo buzzer is sent PWM signal from the SJ OneBoard microcontroller pin P1.20 as shown in the schematic.

The photo of the Vehicle module back side shows the piezo buzzer.

Below are photos of the front and back side of the Vehicle Module Hardware.
GarageParkingAssistantCarFront.PNG

Vehicle Module Hardware - Front side

GarageParkingAssistantCarBack.PNG

Vehicle Module Hardware - Back side

Hardware Interface

The hardware interface consists of five interfaces. The garage module uses the microcontroller's ADC driver and SPI driver. The vehicle module use the microcontroller's GPIO and PWM drivers. Wireless communication uses a wireless mesh network and SPI driver. These drivers are already provided with the LPC1758 microcontroller.

The Hardware Interface schematic is shown on the right.

SPI Interface

The Garage module LPC1758 Micro-controller communicates with the Ultrasonic rangefinder through the SPI interface. The LED drivers are interfaced via a daisy-chain SPI bus. Note: This SPI bus uses only two signals: Clock and MOSI. The garage module toggles the color of the individual LEDs between green and red depending on the distance of the the approaching vehicle. As the vehicle approaches, the LED's will incrementally, turn from green to red. When the vehicle reaches its stop point, the entire LED strip will flash red on/off. Note: The SPI 1 driver was created by copying the existing SPI 0 driver.

ADC Interface

The Garage module LPC1758 Micro-controller communicates with LED Strip through ADC interface. The ultrasonic rangefinder outputs an analog signal to represent the distance to the approaching vehicle. The analog signal is connected to an ADC input on the microcontroller which translates the signal to a data. The microcontroller uses this data to compute the distance in inches.

PWM Interface

The Vehicle module LPC1758 Micro-controller communicates with piezo buzzer through PWM interface. In order to produce a sound, PWM signal is sent to the piezo buzzer at a human hearing frequency between 20Hz to 2000Hz and duty cycle greater than 0%.

GPIO Interface

The LPC1758 Micro-controller communicates with garage door remote through GPIO interface. In order to open the garage, GPIO signal is manipulated into 500 ms pulse signal to simulate the pressing of push button switch on the garage remote. In addition, GPIO signal will be sent to light up LED on-board the microcontroller to indicate the signal to open garage door is being sent.

Mesh Interface

The Vehicle module LPC1758 Micro-controller communicates with Garage module LPC1758 Micro-controller through low mesh interface. The vehicle module receives mesh packet from Garage Module that contains distance data.

GarageParkingAssistant HWSchematic.png

Hardware Interface schematic

Software Design

Each hardware component runs on it's own separate build file. Both software builds were designed using the polling method to obtain sensor and communication inputs. The polling method was chosen for it's simplicity of use.


Garage Module Pseudocode and Software Flow Diagram

Below is psuedocode for Garage Module software design.

main()

  • Initialize devices
    • Set up P0.26 as ADC0.3
    • Call adc0_init() to initialize ADC0
    • Call spi1_init() to initialize SPI1
    • Call spi1_set_max_clock() to initialize SPI1 clock to 1KHz
    • Call strip.show() to write to the LED strip (all LEDs off)
    • Call colorWipe(), a fancy way to set LEDs to green 1 by 1
      • Call setPixelColor() to write green to the array representing each LED in the strip
      • Call strip.show() to write to the strip
      • Wait a moment and repeat until all LEDs have been written green
  • while(1) //This is a continuous loop
    • Call sensor()
      • Call getdistance() 1000 times
        • Gets ADC0 value and converts it to inches
        • Returns distance in inches as float
      • Calculate average distance from the 1000 samples
      • Round distance to nearest inch
      • Transmit distance to vehicle module
      • Display distance on 7-segment LED
      • Returns the distance in inches as float
    • If distance > stop point
      • Call colorDistance(), to set the LEDs red/green based on distance
        • Determines what color each LED in the strip should be (red/green)
        • Calls setPixelColor() to write to an array representing the LED strip
        • Calls strip.show() to write to the LED strip
    • If distance <= stop point
      • Call colorFlash() to flash the LEDs red, all at once
        • Calls setPixelColor() and strip.show() to set all LEDs red
        • Waits a moment, and then turns them all off
Garage Module software flow diagram


Garage Module software flow diagram


Vehicle Module Pseudocode and Software Flow Diagram

Main() function
  • Clear LED display
  • while(1) //This is continuous loop
    • Call car() to perform Vehicle Module functions

Car() function

  • Set up P1.20 as GPIO output signal for Garage remote control
  • Set up P1.1 as GPIO output signal for garage LED2 indicator
  • Setup PWM4 signal for 4.5KHz frequency
  • Set distance to 0 inches and count to 0
  • Initialize garageIsOpen variable to false.

while(1) //This is continuous loop

  • If mesh packet is received from Garage module
    • If garage is not open
      • Send 500ms pulse to open garage door
      • Light up open garage door LED indicator for 500ms
      • Set GarageIsOpen variable to true
    • Deform mesh packet to get distance data in inches
    • If distance > 99
      • Display 99 inches on 2-digit LED display
    • If distance < 99
      • Display actual distance on 2-digit LED display
    • If distance > stop distance
      • Send PWM signal to sound piezo buzzer
    • If distance < stop distance
      • Stop sending PWM signal to piezo buzzer
  • Else no mesh packet is received from Garage module
    • Increment count by 1
    • If count > 1000
      • Clear LED display
      • Stop sending PWM signal to piezo buzzer
GarageParkingAssistantVehicleFlowDiagram.png

Software flow diagram - Vehicle Module

Implementation

Rangefinder to microcontroller
The rangefinder to microcontroller communication was implemented using an ADC. The rangefinder outputs an analog voltage between 0-3.3V. This voltage corresponds to the distance of the approaching vehicle between 0-254 inches. In order to obtain more stable readings we sample the ADC 1000 times and use the average for each reading. Additionally, we opted to only process the data when the distance was less than 99 inches. We did this for two reasons. First, output of the rangefinder becomes very jittery at distances greater than ~10ft, so we chose to ignore those distances. Second, the on-board LED display on the board only has two digits, so 99 is the greatest distance (in inches) that we could display.

Microcontroller to LED strip
The microcontroller to LED strip communication was implemented using SPI. Each LED on the strip is powered by a driver IC (LPD8806). The driver IC's on the strip are daisy-chained together. Only two data pins from the microcontroller are used: MOSI and CLK. All driver IC's are inherently enabled. The MOSI pin from the microcontroller only connects to the first driver IC, to start the daisy chain. Because the drivers are daisy-chained, any time one driver gets updated, they all get updated.

Garage Module to Vehicle Module
The garage module to vehicle module communication was implemented using the Nordic wireless IC on each board. The mesh network drivers were used to interface with the Nordic IC. The garage module tranmits the distance and the vehicle module receives it. Acknowledgement was not used to improve throughput.

Microcontroller to Piezo Buzzer
The microcontroller to piezo buzzer communication was implemented using PWM. The microcontroller outputs PWM signal of approximately 3.3V. The piezo buzzer operates nominally at 5V. The volume of the alarm can be adjusted by the duty cycle and different sounds can be produced based upon different frequencies. In the alarm application, the frequency was set to within the human hearing frequency range and duty cycle is set at 50% for maximum volume. The software initializes the PWM output and the frequency. Using set(duty cycle) function from the PWM class, 50% is used to turn on alarm and 0% is used to turn OFF alarm.

Microcontroller to Garage Door Remote Control
The microcontroller to garage door remote control communication was implemented using GPIO. To open the garage door, a pulse equivalent to pushing down on a push button switch is sent. First, the GPIO pin is initialized by setting the pin corresponding to FIODIR to output. In order to simulate 500 millisecond pulse, microcontroller sends high (3.3V) GPIO signal for 500 milliseconds and then sets it low using FIOSET and FIOCLR.

Microcontroller to 7-segment LED display
The microcontroller to 7-segment LED display communication was implemented using I2C. However, LED class and its functions have already been created to display digits to LED display so LED display code development was not needed. The set(char num) function was called to display distance on LED. If the distance exceeds 99 inches, the LED display will be set to 99. After not receiving data from Garage module for 1000 mesh packets, the clear() function was used to clear LED display.

Testing & Technical Challenges

Garage Module Testing

The garage module functions were first tested separately and then combined to verify they worked together.

1. The first garage module function tested was the ADC. To test the ADC we programmed the garage module to output the distance on the on-board 7-segment display. We then practiced moving the rangefinder around and pointing at various objects to get a feel for its capabilities.

Early stage testing of ultrasonic rangefinder and ADC
Early stage testing of ultrasonic rangefinder and ADC

Below is a close-up of the microcontroller. The LED display indicates the distance to the wall: 7 feet.

Display indicates a range of 7 feet
Display indicates a range of 7 feet

2. The second garage module function tested was the LED strip. We ran a demo loop with only the LED strip connected to verify that it functioned properly.

Below is an animated picture demonstrating the capabilities of the LED Strip.

Testing the RGB LED Strip
Testing the RGB LED Strip

3. Final test step of the garage module was to integrate the input from the rangefinder with the output on the LED strip. We mounted the LED strip and rangefinder on the wall of the garage and moved objects across the beam of the rangefinder. We verified that the LED strip updated accordingly.

Below is an animated picture demonstrating the capabilities of the LED Strip. The strip is programmed with a stopping point of 32 inches.
Testing complete garage module‎
Testing the complete garage module

Vehicle Module Testing

The Vehicle Module individual testing consisted of:

1. GPIO was initially placed into a separate function, in which a pushbutton on the SJ OneBoard sends GPIO signal to the garage remote control. The garage remote control LED light was monitored to ensure it lit up when GPIO signal was sent.

2. Piezo Buzzer was tested for different frequencies to determine the frequency with the loudest noise. The piezo buzzer was tested at the following frequencies: 2kHz, 4kHz, 4.5kHz, 6kHz, and 10kHz. It was determined the loudest sound was from the piezo buzzer's datasheet resonant frequency of 4.5kHz at 85dB.


The Vehicle Module integration testing consisted of:

1. Initial test to ensure the Vehicle and Garage module can perform wireless communication by following the commander and light node example.

2. Tested the distance data is being sent from Garage module to Vehicle module. We used printfs and displayed on the 7 segment LED on both modules.

3. Tested the garage remote control will activate only on the first package received from garage microcontroller

4. Tested piezo buzzer will turn off at less than per-determined stop distance. However, we also discovered piezo buzzer needs to stop when it stops receiving wireless signal from Garage Module.

System Integration Testing

1. Board to board communication: The first step to integrating our system was to establish wireless communication between the two boards. For this task, the garage module read the distance from the rangefinder and displayed it on the LED. At the same time it also transmitted the value to the vehicle module, which also displayed the value on the LED. Verifying good communication was as simple as comparing the two LED's side by side and verifying that they were in sync.

2. Complete system: The complete system test was performed exactly as the product is designed to work during actual use. We mounted the garage module on the wall of the garage. We mounted the vehicle module in the car. We started with the car out-of-range from the garage module. We drove the vehicle towards the garage and verified that the vehicle module flashed it's lights and opened the garage door when it received a signal from the garage module. We continued driving the vehicle into the garage towards the garage module, verifying that the distance displayed on the vehicle module and the lights on the LED strip decremented properly. Finally, as the vehicle reached its stop point, we verified that the vehicle module sounded the audible alarm and the garage module flashed the red LEDs on the strip.

My Issue #1: RS232 and UART

The Ultrasonic Rangefinder (LV-EZ1) outputs data as an RS232 signal. The intent was to read this signal using the SJOne's UART connection along with the provided drivers. The problem was that we were reading garbage data. The cause was an incompatibility between the RS232 signal and the provided drivers. The provided UART drivers expect 0V = Logic LOW, and 3.3V (Vcc) = Logic HIGH. The the rangefinder outputs a modfied RS232 signal. The modified RS232 is defined as 0V = Logic HIGH, and 3.3V (Vcc) = Logic LOW. Data was becoming corrupted due to being inverted. Our solution was not to use the serial output of the rangefinder. Instead we used the alternate analog output of the rangefinder in conjunction with the ADC on the SJOne. Other possible solutions include: Updating the micro-controller software to accept the inverted signal, or use the PWM output of the rangefinder.

My Issue #2: PWM and Piezo buzzer

The SJ One Board has capability to output PWM signal to create a sound from the piezo buzzer. However, there was an issue with my computer in which no sound was produced after the initial click. Once the new SourceForge was used, the PWM signal worked. However, during the time I was troubleshooting to ensure the piezo buzzer was not damaged, GPIO output was used to generate PWM. A PWM signal was generated when implementing delays, a for loop and setting GPIO signal high or low.

My Issue #3: Daisy-chain SPI and Nordic wireless

We were having an issue with the LED strip displaying properly. It was functioning perfectly until we started transmitting using the Nordic IC. The strip would output the wrong colors and the LED patterns became garbled. The issue was that we were using SPI0 to communicate with both the LED strip and the Nordic IC. Normally having multiple devices on an SPI bus is not an issue, but we were the exception. We were using a daisy-chained LED strip, which means that all of the chips are inherently enabled. So every time we communicated with the Nordic chip we were also sending data to the LED strip. The fix was simple: We moved the LED strip over to SPI1.

Conclusion

At the start of this class, neither of us had very much previous experience with microcontrollers. But we gained a lot of new knowledge in this class through lectures and hands-on exercises. We were able to learn how to communicate using GPIO, ADC, PWM, and SPI interfaces. We were able to use the knowledge that we gained in this class to design, build, troubleshoot, test and deliver a fully functional product that met all of our specifications. The Garage Parking Assistant was an immense success.

If there was more time, we would have liked to implemented the following additions:

  • Vehicle module will determine whether to open/close garage door based distance data transmitted by Garage module
  • Allow user to program stopping point through push buttons on vehicle module

Project Video

Garage Parking Assistant Demonstration Video

Garage Parking Assistant Video Link.png

Project Source Code

References

Acknowledgement

We would like to thank Preet for teaching a successfully interesting and fun class.

References

List any references used in project.

LPC1758 Datasheet
LPC1758 User Manual
LPD8806 LED Driver IC Datasheet
LPD8806 LED Driver Library
LV-EZ Ultrasonic Rangefinder Datasheet
AVS Video Editor