NMEA Parsing, wot am I doing wrong?

yachtbits

New Member
Right, the following is supposed to extract just the speed numerics from the VTG string. It is supposed to extract the tens, units and tenths and then output just this via serout. Decimal point is omitted.

It isn't working but & I'm not sure why.
Any thoughts anybody??

----------------------------------
'speed extractor
'extracts speed (knts) from VTG string, checksum is not used.
'31/01/2007
'$GPVTG,000.0,T,000.0,M,111.1,N,2222.2,K,A*hh<CR><LF>

main:

setfreq m8 ' run at 8MHz to allow reading serial data at 4800bps

nmea: serin 3,t2400,("$GPVTG,000.0,T,000.0,M,1"),b1,b2,b0,b3
' read speed value x10 into b1, b2, b3

sertxd(#b1,#b2,#b3,13,10) 'output numerics as serial string
pause 500
goto nmea

--------------------------------------------

 
 

hippy

Ex-Staff (retired)
By using the # in the SERTXD you are outputting the decimal values of the characters you stored in b1, b2 and b3 in textual format.

If you received, "$GPVTG,000.0,T,000.0,M,123.4,N,2222.2,K,A*hh" you have "2", "3" and "4" stored, but you are sending out "505152".

Remove the #'s and see if that improves things. If not, it would help if you could give an example of what results you are actually seeing or a better description than, "it isn't working"; my crystal ball and third eye only have limited powers.

Edited by - hippy on 03/02/2007 01:08:07
 

ljg

New Member
In addition, your qualifier might not be doing what you think.

As written, Serin will sit in a loop forever until the exact string --"$GPVTG,000.0,T,000.0,M,1" is received, that's not very likely to happen in the real world. It would only be happen if you were heading true North and magnetic north at he same time, and your speed in knots was between 100 and 200, There aren't many places in the world where you can do that, and that's some boat.

Look for just "$GPVTG," instead. that will get you to the right nmea sentence. Then read the variables in turn, discarding or writing over the ones you don't want.

Here's an example upand_at_them gave me a while back when I was having similar problems.

<code><pre><font size=2 face='Courier'>
GetLatitude:
' use b0 to skip over decimal point
serin 0,N4800,(&quot;$GPGGA,&quot;),b0,b0,b0,b0,b0,b0,b0,b1,b2,b3,b4,b0,b5,b6,b7,b8
sertxd(&quot;Lat: &quot;, b1,b2, &quot;deg&quot;, b3,b4, &quot;.&quot;, b5,b6,b7,b8, &quot;min&quot;, 13,10)
return </font></pre></code>
 

yachtbits

New Member
Firtsly, thanks for your responses, reading them made me realise how vaige my first post was. Important detail missed out. I'll try to get it a bit more detailed if/when I need more help.

Larry, dead right, what I should have said is &quot;for testing, I am generating a VTG string from another 08M with a VR connected to change just the speed output!&quot; lots of &quot;b0's&quot; to be added once it works.

Speed wise, we are looking at about 75knts but may need upto 120knts! Yes, boats.

hippy, your crystal ball obviously works the #'s were my problem, (along with a couple of other silly mistakes now resolved)

This bit now works.

This is all part of a datalogger program for powerboat racing. Hopefully logging rpm, speed and accellerometer.

cheers
www.hensonracing.com

 
 

pmolsen

Senior Member
There is an excellent post here:
http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=4724

for reading all the data in one pass.
eg. here is a snippet of working code from a program of mine that reads the time and date:

setfreq m8 ; run at 8MHz to allow reading serial data at 4800bps
serin gps,t2400,(&quot;$GPRMC,&quot;),b1,b2,b3,b4,b5,b6,#w6,b7,#w6,#w6,b0,#w6,#w6,b0,#w6,#w6,#w6,#w6,b8,b9,b10,b11,b12,b13
if b7 &lt;&gt; &quot;A&quot; then gpsnolock ; GPS not yet locked on to satellites

hrs = b1 - $30 * 10 + b2 - $30 ; convert to decimal
mins = b3 - $30 * 10 + b4 - $30 ; convert to decimal
secs = b5 - $30 * 10 + b6 - $30 ; convert to decimal
dd = b8 - $30 * 10 + b9 - $30 ; convert to decimal
mm = b10 - $30 * 10 + b11 - $30 ; convert to decimal
yy = b12 - $30 * 10 + b13 - $30 ; convert to decimal


 

sivann

New Member
Some GPS don't have a fixed-length response. Take a look here, I've made a program that checks all possible string lengths and parses all typical NMEA data:
http://www.softlab.ntua.gr/~sivann/gps2dtmf/

 
 
Top