GPM to BrainStem Example
Last Modified: 2006-10-27
find:

basket

Acroname Robotics PDF webpage version GPM to BrainStem Example PDF

Related
Products

Product image for BrainStem Moto 1.0 Module
BrainStem Moto 1.0 Module
Product image for GPS Module
GPS Module
Product image for BrainStem to GPS Cable
BrainStem to GPS Cable
Product image for 8 Char x 2 Line LCD
8 Char x 2 Line LCD

Contents

Setup for GPM unit and Moto Controller.

Introduction

In this example, a BrainStem Moto 1.0 module uses a Total Robots Global Positioning System Module (GPM) to determine time, date, and position.  The BrainStem module uses its built-in I2C bus to communicate with the GPM.  For this example, any BrainStem module could be used as they all share I2C commands and all have the same I2C connector. 

These programs use the TEA language which is a subset of ANSI C.  They can be compiled using the BrainStem Console by entering the steep command.  They can be downloaded to the BrainStem and executed using load and launch commands.  These programs use standard TEA libraries as well as a GPM library. 

Note

These examples use Build 20 or later of the BrainStem Console and TEA libraries. 

Circuit Schematic

Wiring diagram between the GPM and the Moto.

In the above schematic, one of the two I2C headers on the BrainStem is used to interface to the I2C port on the GPM.  The I2C headers provide power and ground connections for the device.  The photo shows how to connect the color-coded adapter cable (sold separately) between the Stem and GPM. 

Source Code - GPM Data to Console Application

When a GPM module is powered-up for the first time, it may take up to thirty minutes for it to get a positional fix.  However, the time and date functions will work very soon after the first power-up.  This first example program reads the time and date info and formats them for display on the Console screen.  The time will be Greenwich Mean Time.  An offset may be added to get the local time. 

/* gpm-1a.tea */ /* GPM Test Application */ #include <aCore.tea> #include <aPrint.tea> #include <aGPM.tea> #define ADDR_GPM (unsigned char)0xD0 void main() { /* set I2C baud rate to 100KHz */ aCore_Outportc(aPortIICBaud, 0); aPrint_String("DATE = "); aPrint_IntDec(aGPM_GetDay(ADDR_GPM)); aPrint_Char('-'); aPrint_IntDec(aGPM_GetMonth(ADDR_GPM)); aPrint_Char('-'); aPrint_IntDec(aGPM_GetYear(ADDR_GPM)); aPrint_Char('\n'); aPrint_String("TIME = "); aPrint_IntDec(aGPM_GetHours(ADDR_GPM)); aPrint_Char(':'); aPrint_FixedIntDec(aGPM_GetMinutes(ADDR_GPM),2,'0'); aPrint_Char(':'); aPrint_FixedIntDec(aGPM_GetSeconds(ADDR_GPM),2,'0'); aPrint_String(" (GMT)\n"); }

Source Code - GPM Data to LCD Display

The following program uses an 8x2 character LCD module with an I2C interface to display data.  This makes it possible to take the prototype outdoors for testing.  The program will cycle every two seconds between a time and date display, a latitude and longitude display in degrees and minutes, and the fractional minutes of latitude and longitude.  The LCD in this example is small and can't fit a lot of information so it was necessary to cycle between three different displays. 

Note that the aGPM.tea library converts all the GPS data into actual numeric variables.  This makes it possible to do math operations on the data.  The Moto board is especially well-suited to GPS applications since it has built-in motion control features and a large 16K program slot for the lengthy calculations that may be needed to implement a GPS guidance algorithm. 

/* GPM Test Application */ /* gpm-1b.tea */ #include <aCore.tea> #include <aPrint.tea> #include <aGPM.tea> #define ADDR_GPM (unsigned char)0xD0 #define ALCD_ADDR 92 #include <aLCD.tea> void show_date_time() { int y; int h; int m; /* clear screen */ aLCD_Byte((char)254); aLCD_Byte(88); /* display date */ y = aGPM_GetYear(ADDR_GPM) - 2000; aLCD_IntDec(aGPM_GetMonth(ADDR_GPM)); aLCD_Byte('/'); aLCD_IntDec(aGPM_GetDay(ADDR_GPM)); aLCD_Byte('/'); aLCD_Byte('0'); aLCD_IntDec(y); aLCD_Byte('\n'); /* display time */ h = aGPM_GetHours(ADDR_GPM); m = aGPM_GetMinutes(ADDR_GPM); if (h < 10) aLCD_Byte('0'); aLCD_IntDec(h); aLCD_Byte(':'); if (m < 10) aLCD_Byte('0'); aLCD_IntDec(m); } void show_position() { int latmin; int longmin; /* clear screen */ aLCD_Byte((char)254); aLCD_Byte(88); latmin = aGPM_GetLatitudeMinutes(ADDR_GPM); longmin = aGPM_GetLongitudeMinutes(ADDR_GPM); aLCD_Byte(aGPM_GetLatitudeDirChar(ADDR_GPM)); aLCD_IntDec(aGPM_GetLatitudeDegrees(ADDR_GPM)); aLCD_Byte(':'); if (latmin < 10) aLCD_Byte('0'); aLCD_IntDec(latmin); aLCD_Byte('\n'); aLCD_Byte(aGPM_GetLongitudeDirChar(ADDR_GPM)); aLCD_IntDec(aGPM_GetLongitudeDegrees(ADDR_GPM)); aLCD_Byte(':'); if (longmin < 10) aLCD_Byte('0'); aLCD_IntDec(longmin); } void show_frac_position() { int latfrac; int longfrac; /* clear screen */ aLCD_Byte((char)254); aLCD_Byte(88); latfrac = aGPM_GetLatitudeFrac(ADDR_GPM); longfrac = aGPM_GetLongitudeFrac(ADDR_GPM); aLCD_Byte('.'); if (latfrac < 100) aLCD_Byte('0'); if (latfrac < 10) aLCD_Byte('0'); aLCD_IntDec(latfrac); aLCD_Byte('\n'); aLCD_Byte('.'); if (longfrac < 100) aLCD_Byte('0'); if (longfrac < 10) aLCD_Byte('0'); aLCD_IntDec(longfrac); } void main() { /* set I2C baud rate to 100KHz */ aCore_Outportc(aPortIICBaud, 0); /* cursor blink off */ aLCD_Byte((char)254); aLCD_Byte(84); while (1) { show_date_time(); aCore_Sleep(20000); show_position(); aCore_Sleep(20000); show_frac_position(); aCore_Sleep(20000); } }

Revision History:

  • 2003-12-08: Example Created.
 

Related Links:

Brainstem Software: Console Overview

voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy
© Copyright 1994-2009 Acroname, Inc., Boulder, Colorado. All rights reserved.