Discussion forum for the BasicX family of microcontroller chips.
Hello !
This message is primarily adressed to Tom Becker .
I used the DateTimeNMEA.bas ( found SerialPort_24.bas but I didn't find
the Support_24.bas , though it only drived the onboard leds O:-)
The code worked great !
After studying the code for a couple of hours ... I still wasn't sure
that what i should do to get the speed reading from the $GPVTG line ....
I haven't used multitasking code before , so the code was a bit blurry
to me ....
What is the easiest way to get speed (km/h) from GPVTG line ??
Can I use mostly the same variables allready in the DateTimeNMEA.bas ??
In my application I only need the Speed to be displayed but the accurate
clock won't hurt to have ...
This is the output seen from my Leadtek Smart Antenna at 4800bps @ 1Hz
$GPRMC,164222.734,A,6010.8528,N,02500.7029,E,0.00,,220306,,*12
$GPVTG,,T,,M,0.00,N,0.0,K*7E
Speed, i think, is displayed on the $GPVTG line after M,0.00 is knots
and N, 0.0 is km/h .
What happens to the speed reading after 100km/h is it still 104.7km/h
or does the output change to 104km/h ?
Thank You very much !!
- Mikael Karstikko
Why are you using the VTG sentence for speed? The RMC sentence has speed
in knots. It's after the ,E, in the msg that you show:
$GPRMC,164222.734,A,6010.8528,N,02500.7029,E,0.00,,220306,,*12
which is 0.00 in this case. I think, but I may be wrong, that this speed
is the true point to point 3 dimensional speed whereas the speed in the
VTG sentence is the horizontal component of the RMC speed.
Paul
Mikael Karstikko wrote:
> Hello !
>
> This message is primarily adressed to Tom Becker .
> I used the DateTimeNMEA.bas ( found SerialPort_24.bas but I didn't find
> the Support_24.bas , though it only drived the onboard leds O:-)
> The code worked great !
> After studying the code for a couple of hours ... I still wasn't sure
> that what i should do to get the speed reading from the $GPVTG line ....
> I haven't used multitasking code before , so the code was a bit blurry
> to me ....
>
> What is the easiest way to get speed (km/h) from GPVTG line ??
> Can I use mostly the same variables allready in the DateTimeNMEA.bas ??
> In my application I only need the Speed to be displayed but the accurate
> clock won't hurt to have ...
>
> This is the output seen from my Leadtek Smart Antenna at 4800bps @ 1Hz
> $GPRMC,164222.734,A,6010.8528,N,02500.7029,E,0.00,,220306,,*12
>
> $GPVTG,,T,,M,0.00,N,0.0,K*7E
> Speed, i think, is displayed on the $GPVTG line after M,0.00 is knots
> and N, 0.0 is km/h .
> What happens to the speed reading after 100km/h is it still 104.7km/h
> or does the output change to 104km/h ?
>
>
> Thank You very much !!
>
> - Mikael Karstikko
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
> What is the easiest way to get speed (km/h) from GPVTG line?
You can use the RMC sentence handling as a model to add a second
condition. You'll need to discard seven fields (skip seven commas),
find the next comma and feed the intervening ASCII expression to ValueS
to get a numeric value. For example:
if (bNMEA_Cmd(1)=asc("G")) and (bNMEA_Cmd(2)=asc("P")) and
(bNMEA_Cmd(3)=asc("V")) and (bNMEA_Cmd(4)=asc("T")) and
(bNMEA_Cmd(5)=asc("G")) then 'case "GPVTG"
call SkipCommas(7)
call GetBytesUntilNextComma (write this procedure yourself) 'get item
do
call GetBytes(bRawChecksum,1) 'discard but checksum
loop until (bRawChecksum(1)=asc("*"))
bChecksum=bChecksum xor bRawChecksum(1) 'remove * from checksum
call GetChecksumBytes(bRawChecksum,2)
call CalcNMEAChecksum
if tfValid then 'data valid
'*do what you want with course and speed here*
end if
end if
> ... does the output change to 104km/h ?
The data format will not change, so I'd expect 104.7.
Paul points out that Speed Over Ground is the same in RMC and VTG - and
RMC is a better choice, I believe. Check the VTG data when you are
moving without a destination, and with a destination. SOG in VTG might
only be there when heading for a destination. It's always there in RMC,
but you'll need to extract it and convert it to km/hr.
TOm
Probably the best argument for using the speed from the RMC sentence is
that your program will do less parsing. I believe the Leadtek device
auto polls 5 sentences. If you only use the RMC, you can skip parsing
the other 4 sentences which will save a lot of code and processing.
Paul
Tom Becker wrote:
>> What is the easiest way to get speed (km/h) from GPVTG line?
>>
>
> You can use the RMC sentence handling as a model to add a second
> condition. You'll need to discard seven fields (skip seven commas),
> find the next comma and feed the intervening ASCII expression to ValueS
> to get a numeric value. For example:
>
> if (bNMEA_Cmd(1)=asc("G")) and (bNMEA_Cmd(2)=asc("P")) and
> (bNMEA_Cmd(3)=asc("V")) and (bNMEA_Cmd(4)=asc("T")) and
> (bNMEA_Cmd(5)=asc("G")) then 'case "GPVTG"
> call SkipCommas(7)
> call GetBytesUntilNextComma (write this procedure yourself) 'get item
> do
> call GetBytes(bRawChecksum,1) 'discard but checksum
> loop until (bRawChecksum(1)=asc("*"))
>
>
Thank You Tom and Paul ! You are both right ! The RMC string is the easiest way , I was just too tired yesterday to see that ... I just needed to add two lines to the existing code to extract 4 digits ... Now it seems to be working . Altough the decimal point does change place , i noticed that the byte value for the decimal point is 254 so i figured this would work . Haven't got to try it yet in movement but during the weekend i'll install the gps in my car ... ( if this works. .. ) dim speed(1 to 4) as byte dim totspd as single 'Calculating if speed(2) >10 then totspd = totspd + (csng(speed(1))*10.0) + (csng(speed(3))*0.1) + (csng(speed(4))*0.01) ' decimal point 1.23 end if if speed(3) >10 then totspd = totspd + (csng(speed(1))*100.0) + (csng(speed(2))*10.0) + (csng(speed(4))*0.1) ' decimal point 45.6 end if totspd = totspd * 1.852 ' convert knots to km/hr debug.print "Speed : " & fmt(totspd, 1) Does it look like it would work .. ? Is the data allways 4 digits long or does it increase in lenght as speed increases ?? I programmed the gps to output only RMC and VTG lines but i can ignore the VTG line as You pointed out . You have been a great help ! Next time You visit Finland Saunas are on me ! - Mikael Karstikko
Mikael,
The length could be 3 characters (3.0 knots) or as many as 5 characters
if the speed max for the device is 999.9 knots which I think is the
reporting max for this device.
Check the ValueS procedure in the System Library. You can simply extract
the speed component as a string and then use ValueS to convert it to a
single. Something like this:
dim qChar as string * 1
dim Speed Str as string
dim totspd as single
dim Success as boolean
call GetQueue(queue, qChar, 1)
do while (qChar <> "," )
SpeedStr = SpeedStr & qChar
call GetQueue(queue, qChar, 1)
loop
call ValueS(SpeedStr, totspd, Success)
If (Success = true)
debug.print CStr(totspd)
debug.print SpeedStr
else
debug.print "Conversion failed"
end if
Paul
Mikael Karstikko wrote:
> Thank You Tom and Paul !
> You are both right !
>
> The RMC string is the easiest way , I was just too tired yesterday to
> see that ...
> I just needed to add two lines to the existing code to extract 4 digits
> ... Now it seems to be working .
>
> Altough the decimal point does change place , i noticed that the byte
> value for the decimal point is 254 so i figured this would work .
> Haven't got to try it yet in movement but during the weekend i'll
> install the gps in my car ... ( if this works. .. )
>
> dim speed(1 to 4) as byte
> dim totspd as single
>
> 'Calculating
> if speed(2) >10 then
> totspd = totspd + (csng(speed(1))*10.0) + (csng(speed(3))*0.1) +
> (csng(speed(4))*0.01) ' decimal point 1.23
> end if
> if speed(3) >10 then
> totspd = totspd + (csng(speed(1))*100.0) + (csng(speed(2))*10.0) +
> (csng(speed(4))*0.1) ' decimal point 45.6
> end if
> totspd = totspd * 1.852 ' convert knots to km/hr
> debug.print "Speed : " & fmt(totspd, 1)
>
> Does it look like it would work .. ?
>
> Is the data allways 4 digits long or does it increase in lenght as speed
> increases ??
> I programmed the gps to output only RMC and VTG lines but i can ignore
> the VTG line as You pointed out .
>
> You have been a great help !
> Next time You visit Finland Saunas are on me !
>
> - Mikael Karstikko
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>