Interfacing a 20 Channel LS20126 GPS Receiver with an 18M2, 18X or 08M2

orinoco

New Member
Hi guys,

I just bought this little GPS receiver a few days ago from Sparkfun (http://www.sparkfun.com). My problem is that I cannot get anything out of it! No matter what I do I can't seem to be able to read its output with a SERIN command. At this point I should mention that I know nothing about GPS's and the receiver's datasheet leaves a lot to be desired.

Any ideas on how to read it using an 18M2, 18X or 08M2 are welcome, otherwise I'm afraid I just threw $60.00 down the drain - and this is not the time to throw money away :) I need specific code examples especially of the SEROUT (for setup) and SERIN (for data reading) commands.

Thank you in advance for all your help.


-----------------------------------------------
LS20126 description and datasheet:
http://www.sparkfun.com/products/9838
(BTW LOCOSYS, the manufacturer of the LS20126 receiver, don't seem to bother with your questions if you are not a major player - i.e. NOKIA)
 

g6ejd

Senior Member
I use a similar type of module (they are nearly all the same), here's some code to get you going. Check the pin-out for the 18M2, this is using input 0 (zero). You don't have a lot of time to get the data and display it before the next data set arrives, so you could skip some, it does not matter in-practice unless you need every set of data every second. This routine will read the data for you (from up_Tx) and will start when it sees the GPGGA sequence. You can change that for any of the other MNEA sentences, see the data sheet on the GPS. My code outputs to a serial LCD, but you could modify it to output to the serial data port and your PC. You may have to check the data rate as that module looks like it differs from the standard 4800buad - data sheets infers 9600baud, that will be a challenge for an 18M2, you may need to wind the speed up to 16Mhz, but check your Baud settings and be sure you have the correct speed for any given CPU clock, that's where I had my initial problems. So in this example to read 9600baud, you may need to use M16 and serin port,T9600_8, etc

Code:
dirsB = 255 'setup Port-BG as outputs
setfreq m8
Pause 1000

Data_in:
'Use the qualifier "$GPGGA" to input the GGA NMEA sentence.

bptr = $50
For b0 = $50 to $7F
 Poke b0, 0
Next

Serin 0, T4800_8,("$GPGGA,"),@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc

'Time
b0 = $50
peek b0, b10,b11,b12,b13,b14,b15
b10 = b10 & $0F * 10 + 1
b10 = b11 & $0F + b10
If b10 > 23 then
  b10 = 0
endif
If b10 < 10 then serout 6, n1200, ("0") endif
serout 6, n1200,(#b10,":",b12,b13,":",b14,b15)

'LAT
b0 = $5B
peek b0, b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20
serout 6, n1200,("Lat:",b10,b11,223,b12,b13,"'",b15,b16,b17,b18,b20)

'LON
b0 = $68
peek b0, b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21
serout 6, n1200,("Lon:",b10,b11,223,b12,b13,"'",b15,b16,b17,b18,b20)

'STATUS
b0 = $74
peek b0, b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23
serout 6, n1200,("Fix=",b10," ","Sat=",b12, " Alt=",b19,b20,"M ")

goto Data_in
 

srnet

Senior Member
Any compelling reason to use a M series ?

Reading GPSs is so much easier using background receive available on the X2.

Not sure what you were expecting from the data sheet, but it looks more detailed than most GPS data sheets I have seen.
 

Svejk

Senior Member
One of the tricks that I learnt the hard way is that the backup battery _must_ be connected to +V in order to have some output from GPS.
 

g6ejd

Senior Member
That's what I do, knowing the input current from the data sheet I calculated a suitable resistor value to give 3.0V, the same a a cell would provide. A battery is only required when you want to retain satellite and time data.
 

orinoco

New Member
Thank you all for your quick replies and suggestions.

What happened was that in the beginning nothing seemed to help at all. So last night I made no progress.
Today I received a new 28X2 module (not just the chip) and tried everything again. I used g6ejd's code again and this time worked beautifully!!! Four days and nights I am trying to get this to work and it seems that the problem was the chip all along as srnet seemed to imply. I really think that an 18M2, however, should be able to handle a task like that. I used both chips at m16 freq. The 28X2 works flawlessly while the 18M2 does not even seem to be aware that a GPS module is trying to talk to it. :) So, I guess, trying to get this project to work with an 18X is out of the question, let alone an 08M2 :))

This GPS module is actually running at 9600 baud by default, which is also its lowest speed - no 4800 baud here so, naturally, I suspected that the speed could be a problem too but the 18M2 looks like it can handle this speed easily. I tried so many magic tricks and voodoo programming that I almost forgot what I learned in school.

Anyway, things are working fine now and I have accumulated a wealth of knowledge regarding GPS interfacing, thanks to all of you guys, to go with my wealth of PICAXE chips (08M, 08M2, 18X, 18M2, 20M2, 28X, 28X2 module, 40X). This was the first time I had a problem with my initial choice of a chip for a project. I guess it was bound to happen.

PS. The VST pin (which is the backup battery pin) on the GPS module does not seem to affect operation either way (i.e. connected to Vcc or not).
 

srnet

Senior Member
I dont think I did imply that there was a problem with the chip, I just pointed out that its easier to do this with background receive on an X2, the code is less critical speed wise also.

I dont see why an 18M2 or 08M2 would not read a GPS at all, if it does not it points to an error in your code.

As for what you do to the VST pin not seeming to make a difference, it would be wise to check what the datasheet says.

It would help if you posted your code and said what you are trying to achieve with the GPS.
 

g6ejd

Senior Member
Hi Orinoc, just to let you know I receive 9600baud data from one of my GPS modules with an 18M2, but that's about all it can do in the time budget, but I just skip a few GPS sentences as for most purposes it does not matter. In minimum mode I can read for example GPS time and display it and be ready to read the next sentence. If I then try to add some other processing then it starts to skip, but it rarely matters. You may need to extend the number of @bptrinc indirect writes as I estimated the maximum for the string I was reading, in my case GPGGA, some are longer than others. I'm glad it worked for you.
 
Top