GPS to Picaxe connection

donrecardo

Senior Member
Hi
I know its a dumb question but I still have to ask it because I dont know the dumb answer.

I have ordered the Xbee start up pack, ( 2 conect boards and Xbees etc ) which could arrive today or tomorrow.
I already own a gps receiver ( http://www.sure-electronics.net/rf,audio/GP-GS009.pdf )

I have been searching this forum to find how to connect the two together and read and process the data . Most of it seems to make sense to me now except for one thing, hence the dumb question.

The question is why do I need to connect the picaxe to both data in and data out on the GPS unit. I thought that data could only be read from the
GPS receiver not written back to it so why do I need both data in and out connected . surely I only need one way transmision , yet page 3 of the picaxe connect manual shows both Data in and out connected and also in a post from Pauldesign 04-02-2010 he included a pdf " Introduction to GPS and PICAXE.pdf " which also has pictures showing both Data in and data out connected.
So could someone please explain why I need both ?

Regards
Don
 

Chavaquiah

Senior Member
Probably so the Picaxe can tell the GPS what and when it wants to read? ;)

Haven't looked at the datasheet, but that sounds like it, anyway.
 

donrecardo

Senior Member
Probably so the Picaxe can tell the GPS what and when it wants to read? ;)
Thanks for your reply, I see what your saying but I am not sure thats the case . Most of the exaples I have seen are along the lines of ...
serin 2, ("$GPRMC"),b0,b1,b2,b3,b4,b5,b6,b7,

So if I understand it correctly the picaxe will wait untill the GPS sends out the next batch of data starting with GPRMC and then read in the data following it, so I dont see why it needs to acknowlege to the GPS that its ready, I thought the GPS just keeps pumping out data and the picaxe only reads data in after seeing GPRMC , but of course , being new to all this I really cant be sure yet

Don
 

MartinM57

Moderator
However, the controller still has to send configuration commands to the GPS receiver.
If you ever want that facility - it's quite possible to take a GPS unit out of it's box and plug'n'go, receiving a selection of NMEA sentences at some data rate and at some baud.

Even of you want to configure the GPS from the PICAXE, then for a one-off hobby project you could configure the GPS directly (i.e. wired connection) and then plug it into the wireless side of things
 

donrecardo

Senior Member
Thanks both of you for your input

The link to the NMEA manual was very handy .

At the moment my gps is running at 9600 baud and I am receiving sentences on both Orion software and u-blox without a problem

I notice in most of the threads I have read that others are running at a lower baud rate , 2400 and 4800. I was looking through the manual to see if I can
lower it

According to the manual for the GPS http://www.sure-electronics.net/rf,audio/GP-GS009.pdf I have 3 ports,

A USB>Uart bridge based on CP2102
A legacy RS232 port
and a bluetooth simulated Rs232 , however if I am reading it correctly it goes on to say
" The baud rate cannot be altered using the USB or bluetooth ports , only the NMEA output package ," , it then continues on to say that through the RS232 port all parameters can be modified , I assume that includes baud rate .
The problem is , like most modern computers mine doesnt have the old RS232 port , thats why I am using the usb > uart bridge .

Will it be a problem trying to run it at 9600 baud into a picaxe 28x2 /40x2.
My plan was to take the data from the wired conections on the edge of the GPS board , process them through the picaxe and then transmit them to my laptop via an Xbee . ( I dinghy sail on a small lake and wanted to send gps info of my position speed heading etc back to my laptop on the shore of the lake)

Don
 

eclectic

Moderator
re the speed.
I can't see any problem there.
In fact, increase the operating frequency of the 28X2,
for faster processing.

I've very quickly copied a fragment
from a program for my receiver,
which outputs 4800

You can quickly change the Baudrate.

Code:
#picaxe 28x2

' Converted by X2 Conversion Wizard Version 1.0.2

let dirsB = %11111111
let adcsetup = 0
setfreq em32

main:
serin C.0,t4800_32,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18
Ec
 

donrecardo

Senior Member
Hi Eclectic and thanks for the reply,

I am probably showing my ignorance again but do I have it right

When you wrote in your code,

let dirsB = %11111111

Is that setting port B as all outputs ?

and when you wrote

serin C.0,t4800_32,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18

Is that reading in through port C ?

If so would I be better swapping those over as my input data is only at 3.3v and I thought port B was TTL inputs ( better for 3.3v signals )
and port C was Shmidt input so no good for 3.3 v signal
or as is more likely , do I have it all completely wrong ?

Don
 

eclectic

Moderator
Is that setting port B as all outputs ?
yes

Is that reading in through port C ?
yes

better swapping those over as my input data is only at 3.3v and I thought port B was TTL inputs ( better for 3.3v signals )
and port C was Shmidt input so no good for 3.3 v signal
or as is more likely , do I have it all completely wrong ?
No, see below
AFAIK, it should be OK to alter the ports around.

Also, you could use a 3 volt 28X2.
And then bump the operating frequency to em64.

Ec
 

John West

Senior Member
If you ever want that facility - it's quite possible to take a GPS unit out of it's box and plug'n'go, receiving a selection of NMEA sentences at some data rate and at some baud.
.........
That depends on the make and model of the GPS unit. I have some older ones (Motorola) I'm working with that do NOT output anything at all until they are properly configured with the correct configuration commands. Once properly configured however they require no subsequent configuration and will indeed spew data on power-up thereafter - making unidirectional RF transmission systems possible.
 
Last edited:

papaof2

Senior Member
Or you may only want specific NMEA sentences from the GPS or you may want a different update rate, which requires sending the commands to enable/disable the specific messages.

I used an EM406 GPS in a project which only needed the GPRMC sentence and no more than once every 10 seconds (in this instance, they were tracking an animal which doesn't move very fast). GPRMC is enabled, the refresh rate is set, and other sentences are disabled by output commands to the GPS when the PICAXE powers up.

John
 

MPep

Senior Member
Basically Don, ignore the transmit to the GPS (ie GPS rx line). For most purposes, the data output is enough to get you going. Simply read the info into the PICAXE, and do something with it.

I agree that some GPSs can, and maybe need to, be set up for a particular purpose, but the majority of modern GPSs simply require power in, and present data out.

Intersting about 9600 Baud. I suspect that this is done to present a larger amount of data each second, without congesting itself.
 

donrecardo

Senior Member
Thanks everyone for their input

Papaof2 I can understand why its better for the GPS to only send out the sentances that I require but whilst I am making my first ventures into GPS
then speed and efficiency are not of prime importance . As long as I know
where I am (Lat / Lon), my heading , and my speed once every 5 or 10 seconds I will be more than happy ( I doubt my dinghy has ever travelled at more than 10mph so GPS data shouldnt alter that fast )

MPep Thats what I was hoping to hear .
It does indeed seem to work straight out of the box. If I plug a USB lead in the USB>Uart socket and accept the default config of the GPS receiver , once every second it spews out......

01:08:50 $GPGGA,010849.955,5218.8221,N,00154.4668,W,1,11,0.9,145.49,M,,,,*2F
01:08:50 $GPGLL,5218.8221,N,00154.4668,W,010849.955,A,A*4D
01:08:50 $GPGSA,A,3,03,06,07,08,16,18,19,21,22,24,26,,1.5,0.9,1.2*31
01:08:50 $GPRMC,010849.955,A,5218.8221,N,00154.4668,W,0.0,000.0,250510,,,A*79
01:08:50 $GPVTG,000.0,T,,,0.0,N,0.0,K,A*40
01:08:50 $GPZDA,010849.955,25,05,2010,,*5A
01:08:50 $GPGSV,3,1,12,16,28,172,44,21,20,063,42,19,57,287,41,22,48,113,47*7D
01:08:50 $GPGSV,3,2,12,18,37,065,38,06,76,119,41,07,18,286,32,24,49,065,28*74
01:08:50 $GPGSV,3,3,12,03,86,208,33,26,09,045,32,08,15,323,32,15,07,024,26*7E
01:08:50 $GPDTM,W84,,0.000027,S,0.000000,E,0.50,W84*42

I connected my scope to the pin marked GPS Dataout on the GPS receiver and once a second I see a data burst . I haven't yet tried inputting that into a pic chip,
but I assume if I did it would after proccesing give me the same result
If thats the case then I am sure I have more than enough data to work with

Don
 

donrecardo

Senior Member
Which PICAXE are you considering?
I ordered a 40X2 last night . I know it is overkill but figured the better the chip spec the more options I have ,
and of course it could always be used in other applications afterwards . Plus its no more expensive than the 28X2 .

I bought it as the 3v version to better match the GPS receiver which is 3.3v
and as Eclectic ( i think ) said , I get the option of higher speed

I do also have in stock

40X2(5V) 40X1 28X2(5V) 28X1 18X 14M 08M

So I can always try it on one of those once its up and running and free up the 40X2 for bigger jobs

Don
 

MartinM57

Moderator
Good choice - better overkill then be short of a crucial feature.

Here's some 20x2 programs to get you going (not commented fantastically or laid out that well)..

dump_raw_gps.bas
Code:
#picaxe 20x2
#no_data
#no_table
#terminal 38400

setfreq m32

hsersetup B4800_32, %001

do
	do : loop until ptr <> hSerPtr
	sertxd (@ptrinc)
loop
decode_gprmc.bas
Code:
#picaxe 20x2
#no_data
#no_table
#terminal 38400

setfreq m32

hsersetup B4800_32, %001

main:
hserin [8000,nodata],0,18,("$") 'wait for $ then receive bytes into sp
ptr = 0 &#8216;reset scratchpad pointer

gettime: 'GPRMC sentence has the time HHMMSS.sss
b0=@ptrinc : if b0<>"G" then main
b0=@ptrinc : if b0<>"P" then main
b0=@ptrinc : if b0<>"R" then main
b0=@ptrinc : if b0<>"M" then main
b0=@ptrinc : if b0<>"C" then main

get 17, b0
IF b0 ="V" then
	sertxd("No fix", CR, LF)
	goto main
endif

ptr = 6
b0= @ptrinc		'10h
sertxd("Time: ", b0)
b0= @ptrinc		'1h
sertxd(b0,":")
b0= @ptrinc		'10m
sertxd(b0)
b0= @ptrinc		'1m
sertxd(b0,":")
b0= @ptrinc		'10s
sertxd(b0)
b0= @ptrinc		'1s
sertxd(b0)
b0= @ptrinc		'"."
sertxd(b0)
b0= @ptrinc		'100ms
sertxd(b0)
b0= @ptrinc		'10ms
sertxd(b0)
b0= @ptrinc		'1ms
sertxd(b0)

sertxd(CR, LF)

b0= @ptrinc		'"," - ignore
b0= @ptrinc		'"A" - ignore
b0= @ptrinc		'"," - ignore
b0= @ptrinc		'10lat
sertxd(" Lat: ",b0)
b0= @ptrinc		'1lat
sertxd(b0)
b0= @ptrinc		'.1lat
sertxd(".", b0)
b0= @ptrinc		'.01lat
sertxd(b0)
b0= @ptrinc		'"." - ignore
b0= @ptrinc		'.001lat
sertxd(b0)
b0= @ptrinc		'.0001lat
sertxd(b0)
b0= @ptrinc		'.00001lat
sertxd(b0)
b0= @ptrinc		'.000001lat
sertxd(b0)
b0= @ptrinc		'"," - ignore
b0= @ptrinc		'N/S
sertxd(b0)

b0= @ptrinc		'"," - ignore

b0= @ptrinc		'100long
sertxd(" Long: ",b0)
b0= @ptrinc		'10long
sertxd(b0)
b0= @ptrinc		'1long
sertxd(b0)
b0= @ptrinc		'.1long
sertxd(".", b0)
b0= @ptrinc		'.01long
sertxd(b0)
b0= @ptrinc		'"." - ignore
b0= @ptrinc		'.001long
sertxd(b0)
b0= @ptrinc		'.0001long
sertxd(b0)
b0= @ptrinc		'.00001long
sertxd(b0)
b0= @ptrinc		'.000001long
sertxd(b0)
b0= @ptrinc		'"," - ignore
b0= @ptrinc		'N/S
sertxd(b0)

sertxd(CR, LF)
goto main

nodata:
sertxd ("no data", CR, LF)
goto main
 
Top