extracting two variables from one long string?
Archiver
Posts: 46,084
Is it possible to extract two pieces of data from one serin string?
Specifically, The NMEA (GPS) sentence that has distance and heading
to a waypoint. Here's an example:
$GPRMB,A,0.09,L,,001,3942.123,N,10413.812,W,0.165,310.4,230803,...
I can get the 165 which is the decimal fraction of distance in
nautical miles, OR, I can get the 310 which is the heading to
waypoint. No matter what I try I can't get both. The GPS ( Garmin
Geko 201) is fixed at 4800 baud. Is it coming in too fast to grab the
310 right after the 165 or am I not setting things up properly?
I tried using [noparse][[/noparse]WAIT(","),....WAIT(".") DEC DIST, DEC WYPT] and many
other scenarios. Can't find any documentation for this.
I am trying to teach myself how the BS2 works, but this has me
stumped.
Thanks,
Jake
Specifically, The NMEA (GPS) sentence that has distance and heading
to a waypoint. Here's an example:
$GPRMB,A,0.09,L,,001,3942.123,N,10413.812,W,0.165,310.4,230803,...
I can get the 165 which is the decimal fraction of distance in
nautical miles, OR, I can get the 310 which is the heading to
waypoint. No matter what I try I can't get both. The GPS ( Garmin
Geko 201) is fixed at 4800 baud. Is it coming in too fast to grab the
310 right after the 165 or am I not setting things up properly?
I tried using [noparse][[/noparse]WAIT(","),....WAIT(".") DEC DIST, DEC WYPT] and many
other scenarios. Can't find any documentation for this.
I am trying to teach myself how the BS2 works, but this has me
stumped.
Thanks,
Jake
Comments
Try: SERIN [noparse][[/noparse]..... WAIT("."), DEC DIST, CommaVal, DEC WYPT]
--- In basicstamps@yahoogroups.com, "Jake" <n0lx@a...> wrote:
> Is it possible to extract two pieces of data from one serin string?
> Specifically, The NMEA (GPS) sentence that has distance and heading
> to a waypoint. Here's an example:
> $GPRMB,A,0.09,L,,001,3942.123,N,10413.812,W,0.165,310.4,230803,...
>
> I can get the 165 which is the decimal fraction of distance in
> nautical miles, OR, I can get the 310 which is the heading to
> waypoint. No matter what I try I can't get both. The GPS ( Garmin
> Geko 201) is fixed at 4800 baud. Is it coming in too fast to grab
the
> 310 right after the 165 or am I not setting things up properly?
> I tried using [noparse][[/noparse]WAIT(","),....WAIT(".") DEC DIST, DEC WYPT] and many
> other scenarios. Can't find any documentation for this.
> I am trying to teach myself how the BS2 works, but this has me
> stumped.
>
> Thanks,
> Jake
Suggestion:
dnb VAR BYTE(12)
SERIN pin,baud,[noparse][[/noparse]WAIT("W,"), STR dnb\12]
This should give you a string of ASCII characters in dnb. For the
example you cited, you'd get:
"0.165,310.4,"
Then you could go through the string and convert the ASCII
representation to a value in software, or just transfer the
character data (comma-delimited) for display, or...
You may need a bigger byte array (>12) if the distance and bearing
values can occupy more digits than your example shows.
If you're using a BS2, you usually can't get away with more than a
WAIT followed by one STR/DEC modifier at 4800 baud. Your Stamp falls
behind the data stream while converting and storing. A BS2p makes
the problem much simpler in terms of speed and storage capabilities.
Another technique some use is to read successive sentences. On the
first pass grab the distance value. On the second SERIN get the
bearing value. Unless you're really moving, any change in values
between samples will probably be more due to system limitations than
actual movement.
Regards,
Steve
On 28 Aug 03 at 9:05, Jake wrote:
> Is it possible to extract two pieces of data from one serin string?
> Specifically, The NMEA (GPS) sentence that has distance and heading
> to a waypoint. Here's an example:
> $GPRMB,A,0.09,L,,001,3942.123,N,10413.812,W,0.165,310.4,230803,...
>
> I can get the 165 which is the decimal fraction of distance in
> nautical miles, OR, I can get the 310 which is the heading to
> waypoint...