manufacturer of I/O-rich SBCs, operator interfaces, handheld instruments, and development tools for embedded control low cost single board computers, embedded controllers, and operator interfaces for scientific instruments & industrial control development tools for embedded control order our low cost I/O-rich embedded control products embedded controller manufacturer profile single board computers & embedded controllers development tools & starter kits for your embedded design operator interfaces with touchscreens and graphical user interface plug-in expansion modules for digital & analog I/O C language & Forth language integrated development tools, IDE single board and embedded computer accessories embedded controller enclosures, bezels, environmental gaskets

Table of Contents

GPS Overview

The Garmin GPS Subsystem

GPS Wildcard Hardware

Connecting To the Wildcard Bus

Selecting the Wildcard Address

Mosaic GPS Driver Software

Driver Functions Extract GPS Data from NMEA Sentences

Overview of the Mosaic GPS Software Device Driver Functions

GPS Service Loop Is Best Placed In Its Own Task

Demo Program Prints Formatted GPS Data

Installing the Mosaic GPS Wildcard Driver Software

Using the Mosaic GPS Driver Code with C

Using the Mosaic GPS Driver Code with Forth

Glossary of GPS Driver Functions

Glossary Quick Reference

GPS_STRUCT Definition

Glossary Entries

C Demonstration Program

Forth Demonstration Program

Hardware Schematics

The GPS Wildcard User Guide

<< Previous | Next>>

Mosaic GPS Driver Software

A package of pre-coded device driver functions is provided to make it easy to control the GPS Wildcard.  This code is available as a pre-compiled "kernel extension" library to C and Forth programmers.  Both C and Forth source code versions of a demonstration program are provided.  The demo program illustrates how to initialize and use the GPS Wildcard in a multitasking application.

In the following sections we examine the formatted data that is transmitted by the Garmin GPS subsystem, and summarize how the Mosaic GPS driver software extracts the data and makes the GPS information available to your application program.  The gps_info data structure that holds the collected GPS information is described, and a comprehensive glossary of functions is presented.

Driver Functions Extract GPS Data from NMEA Sentences

The NMEA (National Marine Electronics Association) 0183 standard specifies the format of ASCII serial data output by the GPS receiver.  On the GPS Wildcard, this serial data is transmitted by the Garmin GPS subsystem and received by a UART (Universal Asynchronous Receiver Transmitter) chip.  The processor can read the data out of the UART receive buffer via the Wildcard bus, and the driver functions facilitate extraction of the GPS parameters from the serial data stream.

The GPS serial data is organized into "sentences". Each sentence starts with the ASCII ‘$’ character, followed by the sentence name field, followed by the data fields, followed by an ASCII ‘*’ character and the hexadecimal ASCII checksum. The checksum is calculated as the 8-bit exclusive-OR sum of all ASCII characters between the ‘$’ and ‘*’ characters (not including the ‘$’ and ‘*’).  The sentence is terminated by the carriage return (0x0D) and linefeed (0x0A) characters.  There is a comma after the name field, and after each data field except the last one before the checksum.  Any alphabetic letters in the sentence must be upper case.  In the Garmin implementation of the NMEA protocol, a sentence may contain up to 82 characters.

Table 1‑3 summarizes the four NMEA sentences from which data is extracted by the GPS Wildcard driver software. Each of these sentences is discussed in turn.

Table 1‑3      GPS sentences parsed by the GPS Wildcard driver software.

Sentence

Description

Fields Extracted by Mosaic Driver

GPRMC

Recommended minimum specific GPS data

UTC and local time/date, position valid flag, latitude N/S, longitude E/W, ground speed, ground course, magnetic variation E/W

GPGGA

Global positioning fix data

Fix available flag, number of satellites in use, altitude

GPGSV

GPS satellites in view

Number of satellites in view

PGRME

Garmin estimated error info

Estimated horizontal, vertical and overall position errors

The GPRMC sentence delivers the fundamental position, time, course, and direction information.  The Mosaic software driver extracts all of the fields from this sentence and stores them in the gps_info data structure described below.   For those who are interested in the details of the sentence structure, the format is as follows:

 

$GPRMC,<hhmmss_utc>,<A|V>,<ddmm.mmmm_lat>,<N|S>,<dddmm.mmmm_long>,<E|W>,

<kkk.k_knots>,<ddd.d_degrees_course>,<ddmmyy>,<ddd.d_mag_var>,<E|W_mag_var_dir>*hhcrlf

After the sentence name, the universal time is presented in hours, minutes and seconds.  The “Coordinated Universal Time” is somewhat surprisingly abbreviated as “UTC”; it is the time in Greenwich England that serves as the global time reference.  The next field is a single-character ‘A’ or ‘V’, where A indicates a valid position, and ‘V’ indicates an invalid position warning.  The next field is the latitude expressed as a 2-digit number of degrees in the range 00 to 89 degrees, followed by the number of minutes expressed with 2 digits to the left of the decimal point and 4 digits to the right in the range 00.0000 to 59.9999 minutes.  The next field is ‘N’ or ‘S’ to indicate North or South latitude (relative to the equator).  The longitude is expressed in similar fashion, except that there are 3 longitude degree digits in the range 000 to 179 degrees, followed by the longitude minutes and the ‘W’ or ‘E’ hemisphere.  The longitude hemisphere is relative to the prime meridian which passes through Greenwich England.  The next field is the ground speed in the range 000.0 to 999.9 knots (a knot is 1.152 miles per hour).  The next field is the course (also known as the heading or direction) expressed in degrees with respect to true north in the range 000.0 to 359.9 degrees.  The next field is the UTC date expressed as a 2-digit date (01-31), 2-digit month (01-12), and 2-digit year (00-99).  The next field is the magnetic variation in degrees in the range 000.0 to 180.0 degrees; this variation quantifies the difference between "true north" and the "magnetic north" indicated by a compass.  The next field is the direction of the magnetic variation; westerly magnetic variation adds to the true course.  The ‘*’ checksum indicator, hexadecimal ASCII checksum, and carriage return/linefeed complete the sentence.

As explained in detail below, the function GPS_Frame_Extract and its calling function GPS_Update automatically parse this sentence, extract the fields, and store them in the gps_info data struct so your application program can use the data.  The fields are stored as binary quantities.  As summarized in the glossary, a family of additional driver functions is available to fetch the fields out of the gps_info data struct and return them for use in your program.

The GPGGA sentence describes whether a GPS fix is available, the number of satellites in use, and the current altitude of the GPS antenna in meters.  For those interested in the sentence structure, here it is:

 

$GPGGA,<hhmmss_utc>,<ddmm.mmmm_lat>,<N|S>,<dddmm.mmmm_long>,<E|W>,<0|1>,

<00-12_numsats_in_use>,<0.5-99.9_horiz_DOP>,<antenna_height>,M,

<geoidal_hght>,M,,*hhcrlf

After the GPGGA sentence name is the UTC time field, the latitude field, the latitude hemisphere, the longitude, and the longitude hemisphere.  All of these are redundant with information from the GPRMC sentence and are ignored.  The next field is an ASCII ‘0’ or ‘1’, where 0 means that the GPS fix is not available, and 1 means that a standard non-differential GPS fix is available.  The next field is the 2-digit number of satellites in use.  We ignore the following “dilution of precision” field.  The next field is the antenna height (altitude) in meters expressed as a number in the range -9999.9 to 99999.9.  The following field is an ASCII ‘M’ to indicate that the altitude is expressed in meters.  The final fields present the geoidal height in meters, followed by the ‘M’ for meters, followed by two empty fields, hex checksum, and the carriage return linefeed terminators.  Only the fix availability indicator, number of satellites in use, and altitude fields are extracted by GPS_Frame_Extract and its calling function GPS_Update.  These fields are stored in the gps_info data struct. Your application program can access them directly, or invoke a family of additional driver functions to fetch the fields.

The GPGSV sentence is used to extract a single field: the number of satellites in view.  The sentence structure is as follows:

 

$GPGSV,<num_gpgsv_sentences>,<index_of_this_sentence>,<00-12_numsatinview>,

<01-32_sat_prn>,<00-90deg_sat_elev>,<000-359_sat_azim>,<00-99db_snr>,

<repeat the above line for each satellite up to max of 4 per sentence>*hhcrlf

After the sentence name is a field that tells the total number of GPGSV sentences, followed by a sentence index as described below.  The next field is a 2-digit number of satellites visible to the GPS receiver in the range 00 to 12; this field is extracted by the driver functions.  If the GPS receiver is inside a building, this field will typically report zero satellites in view, while in unobstructed outside situations all 12 GPS receiver channels may have a satellite in view.  The remainder of the sentence presents satellite-specific elevation, azimuth and signal-to-noise ratio information that is ignored by the Mosaic GPS driver. 

In a single 1-second frame of sentences from the GPS subsystem, there is one GPGSV sentence describing up to 4 of the satellites in view; let’s say this is the GPGSV statement with sentence index 1.  If there are more than 4 satellites in view, the next frame includes a GPGSV sentence describing up to 4 of the additional satellites in view, say with index 2.  If there are more than 8 satellites in view, the next frame will include GPGSV sentence with index = 3 to describe the remaining satellites, and the process starts again with GPGSV index 1 present in the subsequent frame.  This is explained further in the commentary describing Listing 1‑1 on page 8.

The PGRME sentence is a “proprietary” statement created by Garmin to describe the estimated position errors. The sentence structure is as follows:

 

$PGRME,<0.0-999.9meter_hor_pos_err>,M,<0.0-999.9meter_vert_pos_err>,M,

<0.0-999.9meter_overall_position_err>,M*hhcrlf

After the sentence name, the horizontal position error field presents a number in the range 0.0 to 999.9, followed by an ASCII ‘M’ field to indicate that the units are meters.  In parallel fashion, the vertical position error and overall position error fields and their ‘M’ unit fields are presented.  These estimated errors are extracted by GPS_Frame_Extract and its calling function GPS_Update, and are stored in the gps_info data struct so your application program can access them

Three additional sentences are transmitted by the GPS subsystem: GPGSA (dilution of precision report), PGRMT (sensor status information, output only once per minute), and PGRMM (name of map currently in use; the default is WGS84).  The Mosaic GPS Wildcard driver software does not extract data from these sentences.

Table 1‑4 summarizes the sentences transmitted by the GPS subsystem each second, and shows which provide data extracted by the GPS driver functions.  The NMEA sentences are listed in the order in which they are transmitted, but note that the PGRMT sentence is transmitted only once per minute, while the other 6 sentences are transmitted every second. 

Listing 1‑1 presents a sample of four 1-second frames of data as transmitted by the Garmin GPS subsystem.  Carriage returns have been inserted after each frame for clarity; the actual GPS output does not include any blank lines.  You can generate a listing similar to this by passing the Wildcard address and local hour offset to GPS_Init and then invoking the GPS_Dump function. Your controller and GPS Wildcard will then stream the raw NMEA sentence frames to your Mosaic terminal window.

There are a few key items to notice while inspecting Listing 1‑1.  Notice that the first 3 frames shown contain 6 sentences, while the last one contains 7, including the PGRMT sentence which is transmitted only once per minute (that is, once every 60 frames).  Also note while there is only one GPGSV sentence present in each frame of data, there are 3 distinct GPGSV sentences that present themselves in successive frames.  The first numeric field of each GPGSV sentence is the number of distinct GPGSV sentences, and the second numeric field is the GPSSV sentence index. Each GPGSV sentence summarizes the information about a maximum of 4 satellites, and there can be as many as 12 satellites in use.  The Mosaic driver software extracts only the number of satellites in view from this sentence, and this information is present in each instance of the sentence.  The satellite specific information is not extracted or stored.

Table 1‑4      Summary of NMEA sentences transmitted by GPS sensor.

Sentence

Description

Data Extracted?

GPRMC

Recommended minimum specific GPS data

Yes

GPGGA

Global positioning fix data

Yes

GPGSA

GPS DOP (dilution of precision) and active satellites

No

GPGSV

GPS satellites in view

Yes

PGRME

Garmin estimated error info

Yes

PGRMT

Garmin sensor status info (output only once per minute)

No

PGRMM

Garmin name of map datum currently in use (default = WGS 84)

No

 

Listing 11     Four 1-second frames of NMEA sentences from the GPS.

$GPRMC,223321,A,3732.3791,N,12201.1625,W,0.0,194.8,220207,15.1,E*5A

$GPGGA,223321,3732.3791,N,12201.1625,W,1,08,1.1,11.0,M,-28.0,M,,*45

$GPGSA,A,3,03,,07,09,,16,18,19,21,,,26,1.7,1.1,1.3*3A

$GPGSV,3,2,12,14,24,188,00,16,13,244,39,18,71,018,46,19,15,319,48*7B

$PGRME,5.0,M,5.8,M,7.7,M*26

$PGRMM,WGS 84*06

 

$GPRMC,223322,A,3732.3792,N,12201.1625,W,0.0,194.8,220207,15.1,E*5A

$GPGGA,223322,3732.3792,N,12201.1625,W,1,08,0.9,11.1,M,-28.0,M,,*4D

$GPGSA,A,3,03,,07,09,,16,18,19,21,,,26,1.6,0.9,1.3*32

$GPGSV,3,3,12,21,56,082,47,22,63,268,00,24,11,102,00,26,13,037,42*7B

$PGRME,5.0,M,5.8,M,7.7,M*26

$PGRMM,WGS 84*06

 

$GPRMC,223323,A,3732.3792,N,12201.1625,W,0.0,194.8,220207,15.1,E*5B

$GPGGA,223323,3732.3792,N,12201.1625,W,1,08,0.9,11.2,M,-28.0,M,,*4F

$GPGSA,A,3,03,,07,09,,16,18,19,21,,,26,1.6,0.9,1.3*32

$GPGSV,3,1,12,03,39,301,34,06,08,157,00,07,18,163,33,09,09,096,46*7E

$PGRME,5.0,M,5.8,M,7.7,M*26

$PGRMM,WGS 84*06

 

$GPRMC,223324,A,3732.3793,N,12201.1625,W,0.0,194.8,220207,15.1,E*5D

$GPGGA,223324,3732.3793,N,12201.1625,W,1,08,0.9,11.3,M,-28.0,M,,*48

$GPGSA,A,3,03,,07,09,,16,18,19,21,,,26,1.6,0.9,1.3*32

$GPGSV,3,2,12,14,24,188,00,16,13,244,39,18,71,018,46,19,15,319,48*7B

$PGRME,5.0,M,5.8,M,7.7,M*26

$PGRMT,Bravo PDA Ver. 2.01,P,P,R,R,P,,21,*6C

$PGRMM,WGS 84*06

 

The Mosaic GPS Wildcard driver software does not send any sentences to the GPS.  Thus the sentences named PGRMI, PGRMC, and PGRMO that configure various options and parameters in the GPS subsystem are not supported or used.  The Mosaic driver accept the default performance of the GPS, which does its best to remember the proper time and location information to minimize acquisition time.  Experts who are interested in the details of these configuration sentences can consult the Garmin GPS-15 datasheet.

<< Previous | Next>>


Home|Site Map|Products|Manuals|Resources|Order|About Us
Copyright (c) 2006 Mosaic Industries, Inc.
Your source for single board computers, embedded controllers, and operator interfaces for instruments and automation