AXE132 Gets and displays GPS Lat Long from a GPS chip

locky42

New Member
Apologies for being a little long winded:

A number of years back, a PicAxe devotee published a project to link a GPS reciever to an AXE132 so that it displayed GPS Time. I had been using an Arduino to

acquire not just GPS time but also date and its geographic position. I then decided to try and get the PicAxe 18M2 to get and

display the GPS position as well.

Unfortunately PICAXE basic has its limitaions. Though not elegant, I got there in the end.

First getting the full GPS sentence with position:

serin RX,baud,

("$GPRMC,"),@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptr

inc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptri

nc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptri

nc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc

Unfortunately, I could not embed a loop for the 62 bytes aquired and stored in scratchpad by the @bptinc. It is crying out for a function of "@bptinccon( x )" that does x

consecutive @bptrincs.

Having got the bytes into the scratchpad they then needs parsing:

I did it with 3 subroutines:


gosub GetLat
gosub GetLong
gosub GetDate


These find the appropriate bytes, then re-store them in more specific scratchpad locations with the first byte also showing their length. Again, its not elegant but it

works !

GetLat:
;Count to 2nd comma
;Then coppy 10 character ddmm.mmmm,N/S into ptr = 200
let bptr = pStart
let b7 = 0
do until b7 = 2
if @bptrinc = "," then
inc b7
endif
loop
Let b18 = @bptrinc
if b18 <> "," then ; Don't do it if the first comma is followed by another
Let b19 = @bptrinc
Let b20 = @bptrinc
Let b21 = @bptrinc
Let b22 = @bptrinc ; Decimal Point
Let b23 = @bptrinc
Let b24 = @bptrinc
Let b25 = @bptrinc
Let b26 = @bptrinc
inc bptr ; step over comma
Let b27 = @bptrinc ; N or S
Let bptr = pLat ; Sets scratch pad pointer to hold Lat
let @bptrinc = 16 ; Lat string Length
Let @bptrinc = "L"
let @bptrinc = "a"
let @bptrinc = "t"
let @bptrinc = " "
let @bptrinc = " "
Let @bptrinc = b18 ; Degrees dd
Let @bptrinc = b19
let @bptrinc = 210 ; degrees symbol
Let @bptrinc = b20 ; Minutes mm.mmmm
Let @bptrinc = b21
Let @bptrinc = b22
Let @bptrinc = b23
Let @bptrinc = b24
Let @bptrinc = b25
; Let @bptrinc = b26 ; String shortened for LCD
let @bptrinc = 208 ; Minutes symbol
Let @bptrinc = b27 ; N or S
endif
Return

GetLong:
;Count to 4th comma
;Then coppy 10 character dddmm.mmmm,N/S into ptr = 211
let bptr = pStart
let b7 = 0
do until b7 = 4
if @bptrinc = "," then
inc b7
endif
loop
Let b17 = @bptrinc
if b17 <> "," then ; Don't do it if the first comma is followed by another
Let b18 = @bptrinc
Let b19 = @bptrinc
Let b20 = @bptrinc
Let b21 = @bptrinc
Let b22 = @bptrinc ; Decimal Point
Let b23 = @bptrinc
Let b24 = @bptrinc
Let b25 = @bptrinc
Let b26 = @bptrinc
inc bptr ; step over comma
Let b27 = @bptrinc ; E or W
Let bptr = pLong ; Sets scratch pad pointer to hold Long
let @bptrinc = 16 ; Long String Length
let @bptrinc = "L"
let @bptrinc = "n"
let @bptrinc = "g"
let @bptrinc = " "
Let @bptrinc = b17 ; Degrees ddd
Let @bptrinc = b18
Let @bptrinc = b19
let @bptrinc = 210 ; degrees symbol
Let @bptrinc = b20 ; Minutes mm.mmmm
Let @bptrinc = b21
Let @bptrinc = b22
Let @bptrinc = b23
Let @bptrinc = b24
Let @bptrinc = b25
; Let @bptrinc = b26 ; String shortened for LCD
let @bptrinc = 208; Minutes symbol
Let @bptrinc = b27 ; E or W
endif
Return

GetDate:
;Count through the commas.
;The Date will be at the 8th comma
let bptr = pStart
let b7 = 0
do until b7 = 8
if @bptrinc = "," then
inc b7
endif
loop
Let B21 = @bptrinc
if B21 <> "," then ; Make sure its not empty

let B22 = @bptrinc
let b23 = @bptrinc
let b24 = @bptrinc
let b25 = @bptrinc
let b26 = @bptrinc

let bptr =pDate ; Now formate it into an 9 character string at pDate
Let @bptrinc = 8 ' No of characters in Date String.
let @bptrinc = b21
let @bptrinc = b22
let @bptrinc = "/"
let @bptrinc = b23
let @bptrinc = b24
let @bptrinc = "/"
let @bptrinc = b25
let @bptrinc = b26
endif
Return

StringToLCD:
let b8 = @bptrinc
for b7 = 1 to b8
let pinsB = @bptrinc
next
return

Using the pointers:
let bptr = pLat
gosub StringToLCD

let bptr = pLong
gosub StringToLCD

let bptr = pDate
gosub StringToLCD

Along with the appropriate AXE132 control characters, get the strings output to the LCD display.

But on my original Arduino version I also got it to display OS Map Grid reference and that serious number crunching is way beyond a PicAxe.
 
Top