Sending NMEA commands to EM-406a GPS Module

hamtech

Member
Hi,
I have built a GPS based regional time clock which doubles as a UTC clock. At present I am receiving all the messages but I only want the NMEA messages "GGA" and "RMC" all others being off. I have tried every thing I can to get them to turn off. See attached test code, which displays UTC Ok, but the commands have no effect on the GPS chip. Elsewhere on the forum this seems to be answered but it does not work for me. I have tried direct commands from PICAXE chip (see code) and from a terminal window in GPSDIAG free software. I have run up against the wall.
Can someone please help???

Many thanks

Bob

Code:
'---------------GPS Receiver Test Code ------------
'
'    USING EM-406A GPS RX MODULE   
'
'  Display UTC Time via  rs232 from GPS rx
'  Uses 20X2 &  4 x 40 char LCD 
'  GPS Input  on pin 8 = C.2 from max 232 
'  GPS Output on pin 6 = C.4 to   max 232
'  LCD Output on pin b.3 serial to  4 x 40 LCD Display (ex 2030)
'
' *** NB GPS Rx runs at 4800 Bps  Inverted to norm e.g. T4800_16 ****
' 
' *** Serial out LCD is 2400 Bps Norm e.g. N2400_16 (MFREQ = 16) ****
' ---------------------------------------

symbol baud = N2400_16
symbol Sout = b.3 ; serial output on this pin 
Symbol gps_in = c.2 ' GPS serial data messages input
Symbol gps_out= c.4 ' NMEA Commands to GPS

setfreq m16



main:

'work on top half of display 
serout Sout,baud,(255,0)  ' select upper 2 lines
pause 100
Serout Sout,baud, (254,1) ' clear upper 2 lines
pause 100
serout sout, baud,(255,0)  ' select upper 2 lines
pause 100
Serout Sout,baud, (254,128)' start pos line 1
Pause 100

serout sout, baud, ("GPS NMEA Selection")

'work on bottom half of display
Serout Sout, baud, (255,1)  ' select lower 2 lines
Pause 100
Serout Sout, baud, (254,1)  ' clear lower 2 lines
pause 100
serout Sout, baud, (254,128)' line 1 pos 1 bottom half
pause 100


serout c.4 ,t4800_16, ("$PSRF103,01,00,00,00,13,10") ' turn off GLL 
serout c.4 ,t4800_16, ("$PSRF103,02,00,00,00,13,10") ' turn off GSA
serout c.4 ,t4800_16, ("$PSRF103,03,00,00,00,13,10") ' turn off GSV
serout c.4 ,t4800_16, ("$PSRF103,05,00,00,00,13,10") ' turn off VTG
serout c.4 ,t4800_16, ("$PSRF103,06,00,00,00,13,10") ' turn off ZDA



data_in:
serout Sout, baud, (254,128)  ' line 1 pos 1 bottom half
' Data in is ASCII Format 
serin c.2, t4800_16, ("$GPGGA"), b0,b1,b2,b3,b4,b5,b6 ' read time into variable 

b1=b1-48:b2=b2-48:b3=b3-48:b4=b4-48:b5=b5-48: b6=b6-48 'subtract 48 to bring to decimal

serout sout, baud, ("UTC = ",#b1,#b2,":",#b3,#b4,":",#b5,#b6)' write time to LCD

goto data_in



goto main
 

neiltechspec

Senior Member
Looking at the datasheet, shouldn't you also be sending the checksum in each of those commands ?.

e.g. Turn off VTG -("$PSRF103,05,00,00,01,*21",13,10)
 

hamtech

Member
Looking at the datasheet, shouldn't you also be sending the checksum in each of those commands ?.

e.g. Turn off VTG -("$PSRF103,05,00,00,01,*21",13,10)

Hi,

I have turned off checksum, as I don't know how to work it out. Is it necessary.

The other thing that confuses me is whether I need brackets and inverted commas either at a comman line or when send from a picaxe!
 

neiltechspec

Senior Member
The way I read the datasheet, only a quick glance, it looks like all commands to the unit need the checksum, you can't turn that off.

The checksum you can turn off is in the messages from the unit.

From the data sheet :-

**Checksum Field: The absolute value calculated by exclusive-OR the 8 data bits of each character
in the Sentence, between, but, excluding “$” and “*”. The hexadecimal value of the most significant
and least significant 4 bits of the result are converted to two ASCII characters (0-9,A-F) for
transmission. First, the most significant character is transmitted.
 

srnet

Senior Member
I have turned off checksum, as I don't know how to work it out. Is it necessary.
I have written code that generates the NMEA checksum when sending out data, its just the hex characters of an XOR of all the bytes between the $ and *.

To make it easier just post the bit between the $ and * here;

http://www.hhhh.org/wiml/proj/nmeaxor.html

Is it necessary ? - Dunno, the manual says not, but you never know.

The other thing that confuses me is whether I need brackets and inverted commas either at a comman line or when send from a picaxe
So check by redirecting the output destined for the GPS to the serial terminal, does it look right ?
 

srnet

Senior Member
The way I read the datasheet, only a quick glance, it looks like all commands to the unit need the checksum, you can't turn that off.
From here;

https://www.sparkfun.com/products/465

Format:
&#65284;PSRF103,<msg>,<mode>,<rate>,<cksumEnable>*CKSUM<CR><LF>

<msg>
0=GGA,1=GLL,2=GSA,3=GSV,4=RMC,5=VTG

<mode>
0=SetRate,1=Query

<rate>
Output every <rate>seconds, off=0,max=255

<cksumEnable>
ble> 0=disable Checksum,1=Enable checksum for specified message
 

hamtech

Member
Guys,

You are right. I misread the info. You do need to send a checksum to the device, though you can turn it off for the PC software end. My mistake..

Thanks for the link to the Checksum calculator. Will give that a try when I get home from work later today.

Much appreciated the help.





I
 

hamtech

Member
Thanks guys, it works now the checksum is inserted. Thank you all for your help. when I have finished the project I will post the code for interests sake.
 
Top