GPS project question


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2007
    Posts
    3

    Default GPS project question

    HI
    I'm currently working on a GPS based project. I am relatively new to PB programming. I am able to parse out the string and now I am trying to get the distance between 2 GPS Modules. I have an algorithm to complete it but I am unfamiliar with floating point operations. The distances will be relatively small, less than 800meters. Here is what I need the code to do..with obvious errors b/c of the floating point and the overflow issues.
    TRISB.0 = 1 ' Set PORTB, pin 0 to an input
    OSCCON = %01100010
    ADCON0 = %00011100
    ADCON1 = %01111111

    GPSin VAR PORTB.0 'pin 8

    'Allocate Variables for GPS:
    TimeOut CON 3000
    baudGPS CON 188 '16572 + 8192 (bit 13)
    dist var word
    bearing Var byte
    time var byte(10)
    x var word
    y var word
    lat_min var word
    lat var word
    latitude var word
    long_min var word
    long var word
    longitude var word
    bearing1 var byte
    bearing2 var byte
    lat1 var word
    long1 var word

    gps:

    serin2 PORTB.1,188,[wait("GPGGA"),str time\8,wait(","),skip 2, dec2 lat,wait("."),_
    dec4 lat_min,wait(","),bearing1,wait(","),skip 3,dec2 long,wait("."),dec4 long_min]
    'next serin2 for other GPS-----------------------------------------------------
    lat1 = 2832 'these are used for simulating the data from GPS2
    long1 = 5320
    '-----------------------------------------------------------------------------

    latitude = abs(lat1 - lat_min)
    latitude = latitude*1847
    latitude = latitude/100
    longitude = abs(long1 - long_min)
    longitude = longitude*1591
    longitude = longitude/100
    dist = sqr(latitude*latitude + longitude*longitude)


    gosub gps1
    pause 500

    Any help or suggestions will be greatly appreciated.

    Matt

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by mjp130 View Post
    I have an algorithm to complete it but I am unfamiliar with floating point operations. The distances will be relatively small, less than 800meters. Here is what I need the code to do..with obvious errors b/c of the floating point and the overflow issues.
    Download the floating point libraries at MeLabs or even Microchip, or even make some up yourself using nothing but ASCII characters, one digit position per byte. There's nothing that says that your method would be any less inferior to any libraries already out there, especially if you made it yourself and it suited your needs.

  3. #3
    Join Date
    Jul 2007
    Posts
    3

    Default

    When I look at the floating point libraries I seem to get completely lost and I find it difficult to follow. Do you suggest a website or any other source where I might be able to catch up to the curve.

    Thanks for the quick reply
    Matt

  4. #4
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by mjp130 View Post
    When I look at the floating point libraries I seem to get completely lost and I find it difficult to follow. Do you suggest a website or any other source where I might be able to catch up to the curve.

    Thanks for the quick reply
    Matt
    Nope, the only thing I can suggest is to 'relearn your math' (I'm not saying you can't add or anything, just rethink it)
    Break what you think is complicated down to the simplest parts you can think of and build it back up...

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Why using float anyways??? it's just slow and bloat your code for nothing.

    Is this as this hard to figure out 12.34 is the same f thing than 1234 but with a point?

    Just an idea from an old guy so far
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Jul 2007
    Posts
    3

    Default

    When I try to shift everything I run into a overflow problem -- I have to square the solution to calculate the distance so the multiplication can only exceed #188. Is there any way to make a variable greater than word (16bits)? Or how would I make a new variable which takes over after 65k?

    Thanks

  7. #7
    Join Date
    Jun 2007
    Posts
    24

    Default Div32

    Hi,

    Have a look at the DIV32 Maths operator. This may help.

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. Replies: 1
    Last Post: - 27th July 2008, 07:14
  3. GPS clock timing !
    By bethr in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 3rd July 2008, 21:11
  4. Pic GPS project Demo
    By Art in forum GPS
    Replies: 0
    Last Post: - 28th October 2007, 04:05
  5. gps project
    By chuckad in forum GPS
    Replies: 2
    Last Post: - 9th February 2007, 03:52

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