GPS010 - UBLOX6 - EXAMPLE1.BAS error

MartinM57

Moderator
From EXAMPLE1.BAS progarm for GPS010/UBLOX6 GPS unit...
Code:
  ; $GPGLL,4916.45114,N,12311.12437,W,225444.00,A,A*xx
  ;        `--' `---' | `---' `---' |`-----' --  \
  ;        #w1  #w2  w3 #w4   #w5  w6 w7-w13 #w14 w15
  serin [2000,mainloop], B.6, T4800, ( "$GPGLL," ), #w1,#w2,w3, #w4,#w5,w6, w7,w8,w9,w10,w11,w12,w13, #w14,w15
...but it was showing a perfect latitude for my position but longitude was about 200m wrong

Finally realised the error (by Saleae'ing exactly what was coming from the UBLOX)...if the decimal fractions of minutes (w2 and w4) are over 65535 they don't fit into word variables and the latter sertxd's to the Terminal are incorrect. This also had a knock to my subsequent conversions to decimal degrees for, say, Google mapping.

So, are there any code gurus out there that want to take the challenge:
- read the GPGLL sentence correctly interpreting it for display on the Terminal
- converting the degrees, minutes, (decimal) fractions of a minute in the sentence to decimal degrees (degrees in one word variable, fractional degrees in another will be fine :))
 

Captain Haddock

Senior Member
Longitude 200metre wrong, check what datum is used, wgs84 and osgb36 can be that far out if you are comparing with os based maps, wgs84 is the standard gps datum, the offset varies with base position.
Latitude will usually be fine.
 

MFB

Senior Member
Yes, I would quite like someone to do this as well. When I asked for more working examples, Hippy replied that this is a 3rd party product and Rev-Ed would be no better than the rest of us at producing support code.
 

hippy

Ex-Staff (retired)
The best way to handle variable length data streams is to use background receive. Once you have captured a packet you can locate fields of any size within the packet and then process them as required.

Example2.Bas shows how to grab a particular message and then find the fields within it. There should be other examples on the forum for doing similar with other GPS systems.
 

srnet

Senior Member
Gosh me a guru, at last.

When I did the Distance and Direction calculation I initially converted the (background received) GPS string data into the ASCII representation of decimal degrees.

However it eventually proved pointless, as to calculate the distance between two points, you really only need the minutes difference, as long as you know the distance a minute represents.
 

MartinM57

Moderator
Longitude 200metre wrong, check what datum is used, wgs84 and osgb36 can be that far out if you are comparing with os based maps, wgs84 is the standard gps datum, the offset varies with base position.
Latitude will usually be fine.
Nope, it's a software problem - trying to put a value greater than 65535 into a word variable. Manual calculation of the UBLOX output gives lat and long results to within a handful of metres. I'm not using any OS mapping either...
 

MartinM57

Moderator
Yes, I would quite like someone to do this as well. When I asked for more working examples, Hippy replied that this is a 3rd party product and Rev-Ed would be no better than the rest of us at producing support code.
In that case, example1.bas needs to either be fixed or withdrawn as it can produce invalid output
 

hippy

Ex-Staff (retired)
There's another potential problem as well -

$GPGLL,4916.1, ...
$GPGLL,4916.01, ...
$GPGLL,4916.001, ...
$GPGLL,4916.0001, ...
$GPGLL,4916.00001, ...

Read by SERIN, using #w2 for the decimal fraction, they would all put the value 1 into w2.

Using #w2 for is great for skipping fields of digits to get at later data but doesn't really work at all well for determining the value or magnitude of decimal fractions unless the data stream suits that.

One could just take the first digit after the decimal point and calculate with that. That should give roughly 200m accuracy at the equator. For more accuracy background receive parsing is the way to go.
 

g6ejd

Senior Member
I find it slightly amusing that if you use google earth and go to Greenwich, you can see the 0 meridian line but actually 0 longitude is about 125M away to the east - why because WGS84 is the best average match to the earth's shape. So if you want to fly by helicopter and land on the Greenwich meridian, you would have to do it visually!
 
Last edited:
Top