PDA

View Full Version : Connecting GPS Engine Board to PC Serial Port



srspinho
- 27th April 2006, 15:44
Hi Friends,

Hi friends,

I have a GlobalSat ET-102 with serial output

Im connecting it to PIC microcontroller (please, see conde bellow) and Im just receiving not valid GPGGA messages. (only GPGGA messages all the time)
Im not sure if my PIC software is ok or not. So, I Would like to connect the GPS board to my PC serial port in order to check the messages with GPSInfo.exe supplied by the GlobalSat
Im connecting the GPS gnd to serial port Gnd and the GPSs TXA pin to RXs serial port.
Is that right and enough ?

PIC => 16F877a @ 10 Mhz

My Code :

Define LCD_DREG PORTA
Define LCD_DBIT 0
Define LCD_RSREG PORTB
Define LCD_RSBIT 4
Define LCD_EREG PORTB
Define LCD_EBIT 5

define OSC 10

Rem Variables

hh var byte

'Allocate Variables for GPS:
tens VAR BYTE 'GPS results
digits VAR BYTE
tenth VAR BYTE
knots VAR WORD
fps VAR WORD
fpm VAR WORD
GPSin VAR PORTB.1


''''''''''''''''''''''''''''''''''''''''''''
' Variable Definitions
''''''''''''''''''''''''''''''''''''''''''''
'
timeH var byte(2)
timeM var byte(2)
timeS var byte(2)

latD var byte(2)
latM var byte(2)
latS var byte(2)
latH var byte

lonD var byte(3)
lonM var byte(2)
lonS var byte(2)
lonH var byte
sats VAR BYTE(2)
sats2 VAR BYTE(2)
sats3 VAR BYTE(2)
sats4 VAR BYTE(2)
sats5 VAR BYTE(2)
sats6 VAR BYTE(2)
sats7 VAR BYTE(2)
sats8 VAR BYTE(2)
sats9 VAR BYTE(2)
sats10 VAR BYTE(2)
sats11 VAR BYTE(2)
sats12 VAR BYTE(2)
Dia var byte(2)
Mes var byte(2)
Ano var byte(2)


spdI var byte
spdD var byte(2)

head var byte(3)

mon var byte(2)
day var byte(2)
yr var byte(2)

stat var byte
G var byte
D var byte
M var byte
A var byte
F var byte
GPGGA_IN var word


TEMPWORD var word
REPEAT var byte
DEBOUNCE var byte
CMDACK var byte


teste = 1
INTCON 0.7 = 1 ' START THE WHOLE THING RUNNING
Pause 500

inicio:
lcdout $FE,1
lcdout "inicializando-", dec teste
Pause 30


GPS:


timeH = 0
timeM = 0
timeS = 0
stat = 0
sats = 0
latD = 0
latM = 0
latS = 0
latH = 0
lonD = 0
teste = 0

Rem Reading some data in order to test

SERIN2 GPSIN,188,2000,Nogps,[WAIT("$"),str sats\1, STR sats2\1, STR sats3\1, STR sats4\1,_
str sats5\1, str sats6\1,str sats7\1, str sats8\1,_
str sats9\1, str sats10\1, str sats11\1, str sats12\1,_
skip 5, str dia\2, str mes\2, skip 26, str ano\2 ]



lcdout $FE,1
disp:

lcdout $FE,1, sats, sats2,sats3,sats4, sats5, sats6, sats7, sats8, sats9, sats10,sats11, sats12, dia, mes, ano
lcdout $FE, $C0, latD,"-",latm,"-",lats, "-",lath, "-",lond,
Pause 10000

GoTo GPS
Nogps:
LCDOut $FE, 1
LCDOut "No GPS"
Pause 2000
teste = teste + 1
LCDOut $FE, 1
GoTo inicio

Thanks

Srgio Pinheiro (Brazil)

Darrel Taylor
- 27th April 2006, 23:31
Hi Srgio,

It's difficult to receive NMEA sentences by parsing them directly with SERIN2.
Especially if you want to do anything with the data, such as print it out on an LCD.

There is no time between sentences. The next sentence starts coming in immediately after the last one. So, when you take the time to display the results, you miss the beginning of the next one.

The GPS receiver will start sending sentences as soon as it's powered up, so it's easy to miss the first one. From there you will only catch every other sentence.

For example, with the following sequence, The first RMC will be missed do to start up time. So, the first sentence to be received will be the GGA. The next one (GSA) gets missed while displaying the GGA, so it sees GSV next. After that it catches the last GSV and skips the next one which will be another RMC. So, it never sees an RMC sentence, which is the one you want the most.


<pre>$GPRMC,130717,V,5128.7968,N,00143.4973,E,084.3,112 .1,200106,,,N*61<br>$GPGGA,130718,5118.7968,N,00043.4973,E,0,00,,00638 .1,M,050.8,M,,*53<br>$GPGSA,A,1,,,,,,,,,,,,,,,*1E<br>$GPGSV,3,1,09,02,32,307,00,04,66,250,48,07,04,220, 00,10,01,282,00*71<br>$GPGSV,3,2,09,13,81,200,00,16,04,066,00,20,29,100, 45,23,60,065,52*71<br>$GPGSV,3,3,09,24,45,169,37,,,,,,,,,,,,*4D
</pre>
You say that you only get GGA's. It's possible that your receiver only sends RMC and GGA since the others just give useless info about the satellites. So the example might not fit perfectly with your symptoms. Once you get it hooked up to the PC, you should be able to tell.

With that said, if you want to recieve just the RMC, you can change the wait modifier to look for the whole sentence name.
<pre>SERIN2 GPSIN,188,2000,Nogps,[WAIT("$GPRMC"),str sats\1 ....</pre>This will insure that it never gets skipped. If you also want to read the GGA you should have a second SERIN2 that looks for that one immediately after the RMC. Now you've got some time to calculate and display before the next RMC comes in.

Also, keep in mind that some of the fields are variable length. You can't always rely on everything being in the same place all the time.

The best way to parse NMEA data is to receive the entire sentence into a buffer using the USART and interrupts. Then, calculate the checksum by xoring all the bytes together, and compare it with the checksum in the sentence. If they aren't the same, dump the data. Then run through the buffer and "count commas" to seperate the fields. Using this method, you won't miss a thing, and there's plenty of time to do it, and run the rest of your program too.

As for hooking it up to the PC, Yes, GPS TX to the PC RX, and vice versa. You'll also need a MAX 232 or equiv. If the receiver uses 5v levels.
<br>

srspinho
- 28th April 2006, 12:10
Thank you very much, Darrel !