Example Code

Read GPS Time, Position, Velocity, and Course Heading

Code and Documents

Attachment

Download All
This example application decodes the most common NMEA-0183 sentence transmitted by GPS receivers, the $GPRMC sentence. The course track is plotted on the screen, while the ground speed and course heading are also displayed.

The "Read NMEA GPS SubVI.vi" returns time, position, ground speed, and magnetic variation. This subVI initializes the serial port on first call. On subsequent calls, the initialization is skipped. Always use the Stop input when stopping the subVI so that the serial port connection is closed. This subVI is suitable for use in LabVIEW Real-Time applications (normal priority loop), and uses the VISA serial API.

In your GPS interface configuration, use the "NMEA OUT" setting and set the baud rate to the standard 4800 bps setting. Connect your GPS unit to the computer or LabVIEW Real-Time target serial port using a PC Interface Cable, available from the GPS vendor.

This example should work with any NMEA 0183 compatible GPS unit. The example was developed and tested using a Garmin eTrex GPS unit.

LabVIEW front panel and block diagram screenshots are also attached.

Note: ConsumeBefore.vi is part of the Instrument I/O Assistant (installed via the Device Driver CD with the GPIB drivers).

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors