Changing GPS co-ordinates into Degrees-Minutes-Seconds


Results 1 to 19 of 19

Threaded View

  1. #8
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Well, then...........

    There are a couple different ways to do it. I'm going to show you the Serin2 example, because that is the gps example that MeLabs gives.
    Another good way to do it is to read the entire NMEA sentence into an array like this, then worry about parsing it later:
    Code:
    HSerin 200, Main, [WAIT("$GPRM"), STR gpsdata\MAXDATA\13]
    but we will stick with serin2 for now.

    Here is MeLabs gps example for reading speed.
    http://melabs.com/resources/samples/...d/read_gps.bas

    You would have to adjust to get degrees minutes and then do a conversion for seconds
    For instance, their ...
    Code:
    SerIn2 GPSin,baudGPS,Timeout,Nogps,[wait("$GPRMC"),skip 34,DEC1 tens,DEC1 digits,skip 1,DEC1 tenth]
    means wait till it sees $GPRMC that begins the NMEA sentence, skip 34 characters to the speed tens digit, put it in variable "tens", then read next speed digit and put in variable called "digits", then skip the "." and read the last decimal into a variable called "tenth".

    You would have to adjust the skips to match the digits you want to get.
    Code:
    $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A
    
    Where:
         RMC          Recommended Minimum sentence C
         123519       Fix taken at 12:35:19 UTC
         A            Status A=active or V=Void.
         4807.038,N   Latitude 48 deg 07.038' N
         01131.000,E  Longitude 11 deg 31.000' E
         022.4        Speed over the ground in knots
         084.4        Track angle in degrees True
         230394       Date - 23rd of March 1994
         003.1,W      Magnetic Variation
         *6A          The checksum data, always begins with *
    If your NMEA sentence was similar to above (some add more resolution and are of slightly different format), then you could use:
    Code:
    SerIn2 GPSin,baudGPS,Timeout,Nogps,[wait("$GPRMC"),skip 11,DEC2 lat_deg,DEC2 lat_min,skip 1,DEC3 lat_min_dec ... then same for longitude]
    Now, you need to convert decimal minutes to seconds .... am I right this time? Because the GPS will output in decimal minutes, not seconds.

    So, to convert decimal minutes into seconds:
    lat_seconds = lat_min_dec * 6
    so, using the NMEA sample above: 038 * 6 = 228

    When you print this out to your computer, you print a "." in between the twos
    and get 2.28 seconds. This part just prints the seconds out through the serial port.
    The dig specifies which digit you want to print of the variable called seconds. Rightmost digit is 0
    Code:
    DEBUG DEC lat_seconds dig 2,".",DEC lat_seconds dig 1, DEC lat_seconds dig 0,13,10
    Last edited by ScaleRobotics; - 27th October 2009 at 08:05.
    http://www.scalerobotics.com

Similar Threads

  1. GPS $GPRMC to PIC16F684. Need help with SERIN2
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th November 2009, 10:47
  2. Virtual LED Clock For Windows By Trent Jackson
    By T.Jackson in forum Code Examples
    Replies: 8
    Last Post: - 10th November 2009, 09:20
  3. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 21:19
  4. GPS clock timing !
    By bethr in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 3rd July 2008, 21:11
  5. DS1994 Memory/Time iButton
    By NavMicroSystems in forum mel PIC BASIC Pro
    Replies: 47
    Last Post: - 22nd October 2006, 12:55

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts