Getting heading information from GPS

Discussion in 'Embedded Systems and Microcontrollers' started by wannaBinventor, Feb 2, 2011.

  1. wannaBinventor

    Thread Starter Member

    Apr 8, 2010
    179
    4
    I'm trying to understand how to get heading information from NMEA strings. I understand that one has to be moving to get a reading (IE: the gps is not a compass), but I still don't know which string actually puts out the info.

    $GPVTG has "track made good" and "magnetic track made good," but I don't know what that really means.

    $GPGSV has "azimuth" in degrees, which I normally take to mean direction, but I'm not 100% sure here.

    $GPRMC has "track angle in degrees true" and "Magnetic variation," but I'm once again lost of the meaning of those.

    Thanks.
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,136
    1,786
    Magnetic Variation(Declination) is the difference between "True North", the direction you would have to travel to reach the north pole (90° N Latitude), and "Magnetic North", the direction you would have to travel to reach the magnetic north pole.

    You do know that the Magnetic North Pole is moving about 40 km./year to the west.

    http://www.ngdc.noaa.gov/geomag/declination.shtml

    http://www.ngdc.noaa.gov/geomag/img/DeclinationMap_NorthAmerica.png

    Geez. SE Michigan used to be 4 degrees West(1978), now its almost 7 degrees West
     
  3. wannaBinventor

    Thread Starter Member

    Apr 8, 2010
    179
    4
    Do you mean the GPS actually knows the declination for any one position?

    I'm in the military reserve and I've done my fair share of land nav. We always have to apply to LARS rule based on the declination diagram for the maps we've been given.

    Are you saying that that actually gives me the degrees of declination for the particular part of the earth I'm standing on? Does that 40km/yr get accounted for when the satellite beams down the data?

    Which one actually gives me my heading? Azimuth? I think some of this depends on waypoints that the user enters with more advanced GPS systems, which kind of adds to my confusion here in trying to understand them.
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,136
    1,786
    I'm no expert on what data the satellites do and don't have access to or what mechanism they have for updating declination information. In fact since I have misplaced my information on parsing NMEA strings so I might not be much further help to you.

    Try the following link
    http://www.usglobalsat.com/downloads/SiRF_Binary_Protocol.pdf

    As I understand it not all data slots are populated by some devices.
     
  5. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    Your GPS receiver would have a look-up table to give you that information.

    The azimuth given in the GSV sentence is for the satellite's location.

    There is a NMEA 0183 sentence for Heading but it is usually comes from a compass or is calculated by the GPS receiver.
     
  6. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    If you can get velocity for two directions then both speed and heading can be calculated.

    Here is a sample for calculating heading:

    Code ( (Unknown Language)):
    1.  
    2. double heading = atan2(velEast, velNorth);     // Returns the angle, in radians, between -pi and pi.
    3.     heading *= 180.0 / M_PI;                      // Convert from radians to degrees.  Now heading is in the range [-180, 180]
    4.     if (heading < 0.0)
    5.         heading += 360.0;    
    6.  
    Here is sample code for calculating speed:
    Code ( (Unknown Language)):
    1.  
    2. double v2 = (velEast*velEast) + (velNorth*velNorth) + (velUp*velUp);
    3.  
     
Loading...