GPS into picaxe

trinity

New Member
Hi, I'm having a tough job getting this to work, so if any of you out there are using a picaxe connect and a GPS moduule, read on.

I want speed over ground in KPH and Altitude. I wrote the code below but it just sits there and waits, so it is not reading the data. I have looked with a scope, signal is there OK, on pin 16, but it won't budge. At this point I'm wondering if it is something silly, but I can't see what. If you have this set-up, or would like to comment, go ahead. The GPS is working fine with LSviewer and is set to only send these two 'words'.

init:

serout 6,N2400,(254,1) 'clear LCD
pause 30
serout 6,N2400,(254,128,"Chip running")
pause 1000
serout 6,N2400,(254,1) 'clear LCD
pause 30

main:
serout 6,N2400,(254,128,"Main Loop start")
Pause 1000
serout 6,N2400,(254,1) 'clear LCD
pause 30
serin 7, N4800, ("$GPVTG,"), b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b1,b2,b0,b4
'total of 26 charcaters to dump before the data we actuall need, KPH up to 99.9!!
serout 6,N2400,(254,128,"KPH=",#b1,#b2,".",#b4) 'show it on LCD
Pause 100 'now do the elevation buried behind 48 b0's!!
serin 7, N4800, ("$GPGGA,"), b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b1,b2,b0,b4
serout 6,N2400,(254,128,"Ele=",#b1,#b2,".",#b4) 'show it on LCD
pause 100
goto main
HELP!!!

Gareth
 
Gareth,

Should you possibly use "true" serial, you are using "N2400" for the output to the LCD, and "N4800" to read from the GPS. Try substituting "T4800" and see if that works.

Also verify the baud rate, it's often selectable (My handheld is at least) between 9600 and 4800 baud.

Perhaps you could skip the $GPVTG and $GPGGA qualifiers and just see if it reads the data. Maybe it's never seeing those strings, so the program is pausing, waiting for something that will never come.

Hope that helps!
 

hippy

Ex-Staff (retired)
Also drop down to ...

serin 7, N4800, ("$GP,"),b0,b1,b2

and see if you can get any acknowledgement that the commands are being received. You could use DEBUG or SERTXD if available to check this.
 

trinity

New Member
Thanks, it needed T not N and the spaces in the B0 list (one at the start of the second row) was screwing up the LCD.
Listing below works fine!! Phew!!
There REALLY should be some demo code to use with this setup (come on REV Ed!!) it would have saved me about 5 hours frustration, but hey, I've learnt a lot!!

main:

serin 7, t4800, ("$GPVTG,"),b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b1,b2,b0,b3
'total of 26 charcaters to dump before the data we actuall need, KPH up to 99.9!!
'now do the elevation buried behind 48 b0's!!
serin 7, t4800, ("$GPGGA,"),b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b5,b6,b0,b7
serout 6,N2400,(254,1) 'clear LCD
pause 30
serout 6,N2400,(254,128,"KPH=",b1,b2,".",b3) 'show it on LCD
serout 6,N2400,(254,192,"Alt=",b5,b6,".",b7) 'show it on LCD


goto main

Gareth
 

hax

New Member
I can confirm that


GetSpeed:
serin 2,N4800,("GPRMC,"),b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b6,b7,b8,b9,b10,b11,b12,b13
pause 1000
return




will give you the speed in knots. Just use debug to figure out which values you need.

Also make sure that the GPS is locked on to satellites. You can check by running this:



CheckSatFix:
serin 2,N4800,("$GPGGA,"),b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0
return

If b0 = "1" after this line, then you have a valid fix. If not, then you don't and you can't rely on any info you get from most of the other strings.

Hope this helps.

-Phil

 

trinity

New Member
Yes, it's all 'simple' now...although I note you are using N4800. My unit won't read that...I needed T4800?? I'm using a PICAXE supplied GPS and the config routine LSViewer does not allow any protocol adjustments, just the speed, set to 4,800.
Sat Checker useful too, I added that straight away!!

Gareth
 

trinity

New Member
Next task is to integrate it with the data logger, hope I have enough variables...and then get the GPS to directly address a xbee so we can have live telemetry!!
(see www.trinityschoolracing.co.uk)

All good stuff...

Gareth
 
Top