Changing GPS co-ordinates into Degrees-Minutes-Seconds


Results 1 to 19 of 19

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    You are using one of the newer GPS's with a little higher resolution. With any handheld gps, there will be a little wandering of the output. You will see slight position changes, even though you are standing still. This will result in a display of speed, although it will be very low speed.

    The checksum is used to ensure the device reading the gps doesn't receive faulty input. If it is important for your application, the Pic chip can be made to perform a checksum on the sentence, and compare it to the one the gps calculated. If it differs, the data read from the gps is corrupt, and must be read again.

    To convert Knotts to km/h, multiply by 1.852. Since PICs don't do decimal, we will have to make our own. A close enough approximation of knotts x 1.852 is (knotts x 2048)/11, but remind yourselft that your result will have two digits past the decimal point. If you want whole numbers for km/h then divide by 100, or do (knotts x 2048)/1100. A handy tool to figure these fractions out is a download at the very bottom of this page: http://www.miscel.dk/MiscEl/miscel.html

    To convert, you follow my earlier example, but insert skips to match the format of your NMEA sentence.

    For your:
    Code:
    $GPRMC,123339.000,A,5134.2770,N,00007.8480,E,1.14, 254.38,271009,,*09
    it would be something like:
    Code:
    SerIn2 GPSin,baudGPS,Timeout,Nogps,[wait("$GPRMC"),skip 14,DEC2 lat_deg,DEC2 lat_min,skip 1,DEC3 lat_min_dec ....]
    you should be able to enter the rest for longitude now....

    The degrees and whole minutes are already in the format you want. We just need to convert decimal minutes into seconds. To do this, we use the same conversion I showed you in the previous example (except you will see that I forgot to add another digit for the seconds result). Here you have .2770 minutes. We only care about the first three digits. In fact, we might care about even fewer digits, but since we used three of the digits in the last example, lets just use three again.

    The following will multiply your 277 by 6. This will give you a result of 1662, which really is 16.62, but again, the PIC can't do decimal, so we will use the whole number, and just format it for output.
    Code:
    lat_seconds = lat_min_dec * 6
    DEBUG DEC lat_deg," deg ",DEC lat_min," min ",DEC lat_seconds dig 3,DEC lat_seconds dig 2,".",DEC lat_seconds dig 1, DEC lat_seconds dig 0," sec",13,10
    That would print out:
    "51 deg 34 min 16.62 sec", which matches pretty well with the 51 34 16 that you converted on line.
    Last edited by ScaleRobotics; - 27th October 2009 at 15:08.
    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, 09:47
  2. Virtual LED Clock For Windows By Trent Jackson
    By T.Jackson in forum Code Examples
    Replies: 8
    Last Post: - 10th November 2009, 08:20
  3. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  4. GPS clock timing !
    By bethr in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 3rd July 2008, 20:11
  5. DS1994 Memory/Time iButton
    By NavMicroSystems in forum mel PIC BASIC Pro
    Replies: 47
    Last Post: - 22nd October 2006, 11: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