Difference between revisions of "S14: Asset Management and Location System"
Proj user7 (talk | contribs) (→Project Source Code) |
Proj user7 (talk | contribs) (→Project Source Code) |
||
Line 544: | Line 544: | ||
=== Project Source Code === | === Project Source Code === | ||
− | *[[SJ One Development source code: cmpe244_s14_am_asset_management_lpc. | + | *[[SJ One Development source code: cmpe244_s14_am_asset_management_lpc.txt]] |
− | *[[Web source code: cmpe244_s14_am_asset_management_web. | + | *[[Web source code: cmpe244_s14_am_asset_management_web.txt]] |
== References == | == References == |
Revision as of 01:35, 23 May 2014
Contents
S14: Asset Management and Location System
Abstract
The ultimate vision of this project was to develop an asset management and location system to compete with The Tile App. There were two major components to the Tile solution: the tile and the application. The tile was small low-power embedded system that could be attached to an object. The application was primarily a user interface that provides visual feedback to guide a user to a specified tag.
For this project, the tile is simply a Bluetooth module powered by a coin cell battery. The management unit, on the other hand, consists of:
- SJ One development board
- LCD
- Bluetooth module
- GPS module
The system used the Bluetooth RSSI value to determine proximity of the application device to the tile device. SJ One board communicated proximity to the user via a histogram that was displayed on the LCD. If the tile device was within the expected proximity, the GPS coordinates of the tile device were written to a file on the SC card. A webpage was developed which would read this file and plot the tile location of know tiles on Google Maps.
Complete feature set of Asset Management and Location System enabled the following:
- Locating/tracking a tile
- Adding/registering a new tile
- Removing a tile
- Listing all the registered tiles
- Updating the RTC
- Displaying the last known location of tiles on Google Maps
Objectives & Introduction
Objectives
- To track a tile location within 100 meters
- To add/register tiles to user
- To remove tiles from user tiles database
- To display a histogram of tile vicinity
- To display last known location on Google Maps
Team Members & Responsibilities
- Akash Ayare - Feature development
- Pardeep Badhan - Feature development
- Talha Ilyas - Packaging and feature unit testing
Schedule
Show a simple table or figures that show your scheduled as planned before you started working on the project. Then in another table column, write down the actual schedule so that readers can see the planned vs. actual goals. The point of the schedule is for readers to assess how to pace themselves if they are doing a similar project.
Week | Date | Planned | Actual |
---|---|---|---|
1 | 3/6 | Create Wiki page and add the schedule of the project. | Wiki page was created and preliminary scheduling was added. |
2 | 3/13 | Research on Bluetooth and Zigbee radio technologies. | Compared Bluetooth and Zigbee range and power consumption.
Although Zigbee has slightly better power consumption and better range, decision was made to use Bluetooth for the project to keep similarity with Tile project. |
3 | 3/20 | Order parts and research RSSI | Parts were not ordered mainly due to the number of options available; more research was still needed.
Instead, the team registered with GitLab. Project "lpc1758_freertos" was checked in as the base project. Furthermore, the team trained on Git workflow and branching methodology. |
4 | 3/27 | Interface Bluetooth Modules. | Ordered Class 1 Bluetooth version 2 modules. |
5 | 4/3 | Achieve basic Bluetooth communication. | Basic connectivity achieved.
Hercules Setup software was used to connect to the Bluetooth Serial port. |
6 | 4/10 | Fetch RSSI value from the Bluetooth module. | Discovered there are two ways to fetch the RSSI value. One mode worked better over the other, but it was slower. In a open room, with one of the modes, there wasn't significant change in RSSI value when proximity changed. The second mode provided better distance estimation, but it was slower to fetch RSSI value in this mode. |
7 | 4/17 | Experiment how this value changes with proximity. | Started interfacing with the Bluetooth module with SJ One Board instead of Hercules.
Also, added a task to receive Bluetooth data and display it on console. |
8 | 4/24 | Implement visual indicator (histogram) corresponding to RSSI values. | Interfaced LCD screen with SJ One Board.
Added tasks to control the user menu and monitor switches, and user menu infrastructure that:
|
9 | 5/1 | Packaging, battery installation, and testing. Expansion of feature-set. | Enhanced features:
|
10 | 5/8 | Demo | The demo was postponed to 05/22
Enhanced features:
|
11 | 5/15 | Final Exams, Additional week for bug fixing, testing, and packaging. | Fixed bugs:
Enhanced features:
|
12 | 5/22 | Demo and report submission. | More feature development:
|
Parts List & Cost
Item | Part Name | Part Cost | Qty | Total Cost |
---|---|---|---|---|
1 | LPC1758 SJSU One Board | $80 | 1 | $80 |
2 | SparkFun BlueSMiRF Gold] | $64.95 | 2 | $209.90 |
3 | SparkFun Bluetooh Mate Gold | $64.95 | 1 | $274.85 |
4 | Serial Enabled 16x2 LCD | $24.95 | 1 | $299.80 |
5 | Venus GPS Logger with SMA Connector | $59.95 | 1 | $359.75 |
6 | Antenna GPS Embedded SMA | $11.95 | 1 | $371.70 |
7 | Philmore Micro Rocker Switch | $1.99 | 1 | $373.69 |
8 | SPDT Sub-Mini Slide Switch 2-Pack | $3.99 | 1 | $377.68 |
9 | Tile Enclosure | $0.98 | 2 | $379.64 |
10 | Tracker Enclosure | $4.99 (+ $11.99 fabrication) | 1 | $396.62 |
10 | 9V Battery | $4.99 | 2 | $406.60 |
11 | Philmore 9V Snap-In Battery Holder | $0.89 | 1 | $407.49 |
12 | 24.5mm Coin Cell Battery | $2.95 | 2 | $413.39 |
13 | 12mm Coin Cell Battery | $1.99 | 1 | $415.38 |
14 | Fabricated Button Extensions | $0.99 | 1 | $416.37 |
15 | Micro SD Card | $9.99 | 1 | $426.36 (tax + shipping not included) |
Design & Implementation
Hardware Design
The following diagram captures how all the modules of the application device were interfaced:
The diagram below shows the breadboard prototype of the final product:
As mentioned earlier, the tile device was simply a Bluetooth module connected to a coin cell battery.
Hardware Implementation
Engineering Prototype - Implemented with a drop in replacement so the LCD output is adjusted for a console display over USB. Other than the LCD display being replaced by an FT232 device, this design is exactly the same as illustrated in the hardware design section.
Demonstration Prototype - To demonstrate the functionality of the system, a demonstration prototype was developed to present the system to an audience of engineers. All hardware is enclosed and runs on an independent power supply.
Tile Prototype - The tile prototype is a Bluetooth Module connected to a battery source that can be independently operated. This prototype is also enclosed with the intention to be used for demonstration purposes.
Hardware Interface
SJSU One UART3 was interfaced with the Bluetooth module at 115200 bps with RX and TX queue depth of 1024 character elements, respectively using the supplied UART3 driver. Both LCD and GPS modules share UART2 at 9600 bps with RX and TX depth of 1024 character elements. The LCD module was interfaced with the TX of UART2 and the GPS module was interfaced with the RX of UART2. The following table depicts the connections:
SJSU One | Peripheral | ||
---|---|---|---|
Power | 3.3V | VCC | Bluetooth |
Ground | GND | GND | |
N/A | CTS-I | RTS | |
UART3 | TX | RX - I | |
RX | TX - O | ||
Power | 3.3V | VCC | LCD |
Ground | GND | GND | |
UART2 | TX | RX | |
Power | 3.3V | 3.3V | GPS |
Ground | GND | GND | |
UART2 | RX | TX |
Software Design
Asset Management and Location System consisted of four tasks:
- Switch Task - Monitored the switches that allowed the user to navigate the user menu. When a switch was pressed, this task enqueued the switch ID to the Asset Management task. This task executed in low priority at 10ms interval.
- Asset Management Task - Controlled the LCD (user menu navigation) and Bluetooth module. This task received switch pressed notification from the Switch task. Upon receiving a switch pressed event, this task either updated the user display or initiated a Bluetooth inquiry. It also stored the GPS coordinates of each tile to a file on the flash memory. This task executed in low priority. If Bluetooth inquiry was in progress, this task operated at 1s interval otherwise it blocked on switch pressed event.
- GPS Task - Fetched the current location from the GPS module and stored it in global variable. This task operated in low priority at 1s interval.
- Map Task - This task executed in low priority at 30s interval. Using the files generated by the Asset Management task, it composed a file that the webpage parsed to plot tile location on Google Maps.
The interface between these tasks is described in the figure below:
The Asset Management task managed the user menu based on events received from the Switch task. The user menu could be navigated in the following manner:
Implementation
LCD
The LCD class represented the LCD module. The main objective of this class was to determine what was displayed and format the data that was displayed on the LCD. Furthermore, it was capable of operating in two modes:
- Real Mode: In this mode, all the data was printed to the LCD.
- Emulation Mode: In this mode, all the data was printed to UART1. The feature allowed multiple members of the team to work on the project even though the team owned single LCD module.
LCD module was represented by singleton design pattern:
Bluetooth
As the name implies, Bluetooth class enabled communication with the Bluetooth module. It provided the following functionality:
- Enter Command Mode: The Bluetooth module used for this project was capable of operating in two modes - 1) data mode and 2) command mode. In the data mode, the Bluetooth module worked as a data pipe and simply converted Bluetooth signals to UART and vice verse. In the command mode, however, the received data (either via Bluetooth or UART) instrumented the Bluetooth module to an operation such as change configuration ("set" commands, return current configuration ("get" commands), etc. The Bluetooth module doesn't have any physical indication of whether the module is in data mode or command mode. To address this issue, this feature issued a "get" command to retrieve the current firmware version of the module. If the expected firmware version was read, it was known that the module was in command mode. If not, an attempt was made to enter the command mode and read the firmware version number. This process repeated until either it eventually exceeded the number of expected tries or it command mode was entered.
- Enter Data Mode: This feature was not used for this project.
- Send Command: This was simply UART TX.
- Receive Data: This was simply UART RX.
The Bluetooth module was represented by singleton design pattern:
Tile Device
The information of each device was stored in the following class. The stored information consisted of MAC address, tile name (identifier selected by the user), Bluetooth name, RSSI value, and Bluetooth class of service identifier.
Asset Management
Bluetooth Inquiry
One of the most critical components of the project was Bluetooth inquiry. In hindsight, this functionality should have been implemented in Bluetooth software module. Doing so would change the interface, but the core functionality of the inquiry would remain the same. The Bluetooth inquiry can be best implemented with a state machine. The following diagram lists all the states and the transitions. To enable the user to cancel the inquiry at any time, the Bluetooth inquiry spanned multiple function calls. This required using local static variables to preserve the state. Of course, this means inquiry can't be launched from multiple threads. This was, however, the design that was chosen since Asset Management system has only one main thread.
User Menu
The update of user menu which was triggered by switch press or Bluetooth inquiry state change was made non-blocking operation. This allowed the user the ultimate control of the system behavior. For example, it allowed the user to cancel a Bluetooth inquiry and navigate to the previous menu while Bluetooth inquiry was under way. In order to support this, however, each menu had to preserve it's state across multiple function calls.
- Main Menu: This menu just displays all the options that were available to the user.
- Add Tile Menu: The following flow chart illustrates the add tile operation. When a tile device was added, the tile information was stored in RAM and to a file on the flash memory.
- Remove Tile Menu: This operation was essentially the inverse to add tile operation.
- List Tiles: This menu listed information of all the registered devices to the LCD. The displayed information included: 1) User selected tile name, 2) Bluetooth name, 3) MAC address.
- Time: This menu allowed the user to set the system RTC. The following figure illustrate how the set time menu worked. The diagram ignores the Up and Down buttons because they just change the value.
File Storage
There were 3 set of files that were written:
- This was a single file with name flash:tiles.txt. This file stored information of all the registered tiles and had the following structure:
- These were set of files stored in directory flash:gpsdb. Each tile device had a dedicated file that contained the last known GPS data of the tile device. The filename was the MAC address of the tile device. For example, tile device with the MAC address of aa:bb:cc:dd:ee:ff would be stored with full path of flash:gpsdb/aabbccddeeff. This file has the following structure:
Tile Identifier, Bluetooth Name, MAC, Time, Latitude, Longitude
- This was a single file that was stored on the micro SD card. This file was parsed by the webpage to compose Google Maps. This file had the following structure:
Tile Identifier 1, Bluetooth Name 1, MAC 1, Time 1, Latitude 1, Longitude 1 | |||
Tile Identifier 2, Bluetooth Name 2, MAC 2, Time 2, Latitude 2, Longitude 2 | |||
... | |||
Tile Identifier n, Bluetooth Name n, MAC n, Time n, Latitude n, Longitude n |
Test Case # | Description | Expected Behavior | Result |
---|---|---|---|
1 | Search for Tiles. | Show list of discovered Tiles. | Passed |
2 | Search for Tiles with none available in vicinity. | Display message stating no Tiles found. | Passed |
3 | Add a tile. | Tile is successfully added. | Passed |
4 | Add more than one tile. | Multiple tiles added in succession. | Passed |
5 | List added tiles. | Display list of Tile assigned names, actual names, and MAC addresses. | Passed |
6 | Track a tile. | Initiate tracking sequence and display RSSI value with proximity gauge. | Passed. |
7 | Select a second tile to track. | Tracking should display information for different tile. | Passed |
8 | Exit tracking state. | Return to user menu interface, one level up. | Passed |
9 | Exit Tile search state. | Return back to user menu interface. | Passed |
10 | Remove a Tile. | Tile entry should be removed with success message, should not be shown in listed/track-able devices. | Passed |
11 | Seamless navigation of user menu interface. | User should be able to navigate menu without error. | Passed |
12 | Clock and calendar set functionality. | User should be able to set and save data and time on Tracker. | Passed |
13 | GPS data-logging and display on Google Maps. | GPS module should log location data and store to micro SD flash card in order to display locations in Google Maps. | Passed |
Conclusion
Ultimately, we were able to successfully develop a functioning prototype that is comparable to competitive products available on the market today. There were many lessons learned over the course of the project. Some lessons were regarding infrastructure, others regarding operating system topics, and some in manufacturing techniques. Give an opportunity to do the project again, there are many things we would do differently regarding design and implementation. However, overall we are very happy with the results of our project as it is currently passing all test cases.
Project Video
Upload a video of your project and post the link here.
Project Source Code
- SJ One Development source code: cmpe244_s14_am_asset_management_lpc.txt
- Web source code: cmpe244_s14_am_asset_management_web.txt
References
Acknowledgement
Any acknowledgement that you may wish to provide can be included here.
References Used
List any references used in project.