GPS project question

1. ## 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

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. Originally Posted by mjp130
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. 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.

Matt

4. Originally Posted by mjp130
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.

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. 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

6. 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. ## Div32

Hi,

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