Difference between revisions of "MTS420 GPS Tutorial"
m (Create Page) |
(flesh out the details) |
||
Line 1: | Line 1: | ||
− | ' | + | The GPS drivers for the MTS420 are still in development. As such the reliability may be sketchy. Please be cautious and do your own thorough testing before deploying any application using this code. |
+ | |||
+ | Also, I assume that you are familiar with writing and compiling programs for the MICAz motes. Every single step is not included. This is just meant as a starting point. | ||
+ | |||
+ | ==Minimum Requirements== | ||
+ | |||
+ | *TinyOS 2.x development platform | ||
+ | *MICAz mote (and a way to program it) | ||
+ | *MTS420 (CA or CB) sensorboard | ||
+ | *GPS antenna compatible with the MTS420 sensorboard | ||
+ | *Internet access to read this tutorial and download the files as instructed below | ||
+ | |||
+ | ==Download the Files== | ||
+ | |||
+ | The files are found in the [http://tinyos.cvs.sourceforge.net/ TinyOS Sourceforge CVS Repository]. | ||
+ | |||
+ | Download the following files from the tinyos-2.x-contrib/rincon/ directory and add them to your TinyOS-2.x development source files in the respective directories: | ||
+ | |||
+ | */tos/chips/adg715/ directory | ||
+ | */tos/chips/atm128/ directory | ||
+ | */tos/lib/Nmea/ directory | ||
+ | */tos/SyncUartStream/ directory | ||
+ | */tos/platforms/micaz/sensorboards/mts420/ directory | ||
+ | */tos/sensorboards/mts420/ directory | ||
+ | |||
+ | ==The Minimum Program== | ||
+ | |||
+ | To make a minimal program using the GPS of the MTS420 it is fairly simple. After you have downloaded the above files and added them to your TinyOS-2.x source tree you will have to do three things. | ||
+ | |||
+ | 1. Add the following line to your Makefile: | ||
+ | SENSORBOARD=mts420 | ||
+ | 2. Add the following code to your configuration implementation section: | ||
+ | components YourModuleP as app, NmeaRawReceiveC, gps9546C, NmeaGgaC; | ||
+ | |||
+ | app.NmeaRawReceive -> NmeaRawReceiveC; | ||
+ | app.SplitControl -> gps9546C; | ||
+ | app.NmeaPacket -> NmeaGgaC; | ||
+ | 3. Add the following code to your module: | ||
+ | *Start of File: | ||
+ | #include "Nmea.h" | ||
+ | #include "NmeaGga.h" | ||
+ | *Head: | ||
+ | interface NmeaRawReceive; | ||
+ | interface SplitControl; | ||
+ | interface NmeaPacket<nmea_gga_msg_t>; | ||
+ | *Implementation: | ||
+ | nmea_gga_msg_t* gpsInfo; | ||
+ | |||
+ | event void SplitControl.startDone(error_t error) { | ||
+ | } | ||
+ | |||
+ | event void SplitControl.stopDone(error_t error) { | ||
+ | } | ||
+ | |||
+ | event void NmeaRawReceive.received(nmea_raw_t* packet, bool complete) { | ||
+ | if(complete) { | ||
+ | if(gpsInfo != NULL) { | ||
+ | //Interprets the raw packet and stores the information in gpsInfo | ||
+ | if(call NmeaPacket.process(packet, gpsInfo) == SUCCESS) { | ||
+ | if(gpsInfo->fixQuality != FIX_INVALID) { | ||
+ | //Valid GPS fix = do some processing/send information over radio | ||
+ | } | ||
+ | } else { | ||
+ | //Handle error | ||
+ | } | ||
+ | } | ||
+ | } else { | ||
+ | //Handle error | ||
+ | } | ||
+ | } | ||
+ | |||
+ | ==That doesn't do anything, what next?== | ||
+ | |||
+ | True. If the above program is compiled and run, nothing will happen. At some point in time the SplitControl.start() command will have to be called. After that call (say in a Boot.booted() event) then GPS packets will start to come in. Still, it will appear that nothing is happing. Some processing will have to be done on gpsInfo (for example, send it over the radio) for this program to be of use. | ||
+ | |||
+ | To see a functioning example look in the [http://tinyos.cvs.sourceforge.net/ TinyOS Sourceforge CVS Repository]: tinyos-2.x-contrib/rincon/apps/tests/TestMts420Gps/ directory. The program turns on the green LED when the gps is listening for packets. The red LED flashes every time the NmeaPacket.parse() call fails (usually because it is not a gga packet that just came in). The yellow LED toggles every time a valid GGA packet comes in with a valid GPS fix and then sends that packet over the radio for a mote running the BaseStation app to pick up. |
Revision as of 13:48, 26 May 2008
The GPS drivers for the MTS420 are still in development. As such the reliability may be sketchy. Please be cautious and do your own thorough testing before deploying any application using this code.
Also, I assume that you are familiar with writing and compiling programs for the MICAz motes. Every single step is not included. This is just meant as a starting point.
Contents
Minimum Requirements
- TinyOS 2.x development platform
- MICAz mote (and a way to program it)
- MTS420 (CA or CB) sensorboard
- GPS antenna compatible with the MTS420 sensorboard
- Internet access to read this tutorial and download the files as instructed below
Download the Files
The files are found in the TinyOS Sourceforge CVS Repository.
Download the following files from the tinyos-2.x-contrib/rincon/ directory and add them to your TinyOS-2.x development source files in the respective directories:
- /tos/chips/adg715/ directory
- /tos/chips/atm128/ directory
- /tos/lib/Nmea/ directory
- /tos/SyncUartStream/ directory
- /tos/platforms/micaz/sensorboards/mts420/ directory
- /tos/sensorboards/mts420/ directory
The Minimum Program
To make a minimal program using the GPS of the MTS420 it is fairly simple. After you have downloaded the above files and added them to your TinyOS-2.x source tree you will have to do three things.
1. Add the following line to your Makefile:
SENSORBOARD=mts420
2. Add the following code to your configuration implementation section:
components YourModuleP as app, NmeaRawReceiveC, gps9546C, NmeaGgaC; app.NmeaRawReceive -> NmeaRawReceiveC; app.SplitControl -> gps9546C; app.NmeaPacket -> NmeaGgaC;
3. Add the following code to your module:
- Start of File:
#include "Nmea.h" #include "NmeaGga.h"
- Head:
interface NmeaRawReceive; interface SplitControl; interface NmeaPacket<nmea_gga_msg_t>;
- Implementation:
nmea_gga_msg_t* gpsInfo; event void SplitControl.startDone(error_t error) { } event void SplitControl.stopDone(error_t error) { } event void NmeaRawReceive.received(nmea_raw_t* packet, bool complete) { if(complete) { if(gpsInfo != NULL) { //Interprets the raw packet and stores the information in gpsInfo if(call NmeaPacket.process(packet, gpsInfo) == SUCCESS) { if(gpsInfo->fixQuality != FIX_INVALID) { //Valid GPS fix = do some processing/send information over radio } } else { //Handle error } } } else { //Handle error } }
That doesn't do anything, what next?
True. If the above program is compiled and run, nothing will happen. At some point in time the SplitControl.start() command will have to be called. After that call (say in a Boot.booted() event) then GPS packets will start to come in. Still, it will appear that nothing is happing. Some processing will have to be done on gpsInfo (for example, send it over the radio) for this program to be of use.
To see a functioning example look in the TinyOS Sourceforge CVS Repository: tinyos-2.x-contrib/rincon/apps/tests/TestMts420Gps/ directory. The program turns on the green LED when the gps is listening for packets. The red LED flashes every time the NmeaPacket.parse() call fails (usually because it is not a gga packet that just came in). The yellow LED toggles every time a valid GGA packet comes in with a valid GPS fix and then sends that packet over the radio for a mote running the BaseStation app to pick up.