Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Ads

Discussion Groups

Discussion Groups | BasicX | GPS NMEA $GPRMC =>$GPRMB

Discussion forum for the BasicX family of microcontroller chips.

GPS NMEA $GPRMC =>$GPRMB - "guntis.laurins" - Mar 13 16:03:09 2008

Hello

With DateTimeNMEA example $GPRMC data I can see very well, now I want
to change this code so I can see in $GPRMB protocol Letters R and L,
they ar here, after 3th comma:
$GPRMB,A,0.00,L,,SIGULD,5708.612,N,02450.922,E,25.760,61.5,,V,A*74

On DateTimeNMEA example in Serial_24.bas and Suppert_24.bas I leave as
they where, but in DateTimeNMEA.bas I change to this:

' Accept 4800N81 NMEA from Pin 20
' Continuously Set BX-24 RTC to indicated UTC
' (~250mS delayed) from valid $GPRMC sentence
' Continuously Display RTC

' Tom Becker G...@RighTime.com 2002-08-10
'-------------------------------------------------------------------------------

' uses Serialport_24.bas and Support_24.bas

const bNMEAInPin as byte = 13
const lInSpeed as long = 4800
const bNMEAOutPin as byte = 0
Const Deg As Byte = 176 ' Graadu simbols.
dim tfValid as boolean
dim bLonDM(1 to 12) as byte 'dddmm.mmmm,W
' dim bLatDM(1 to 12) as byte 'dddmm.mmmm,W

dim bUTCDate(1 to 6) as byte
dim bUTCTime(1 to 6) as byte
dim bNMEA_Cmd(1 to 5) as byte
dim Navigate(1 to 3) as byte
dim bChecksum as byte, bRawChecksum(1 to 2) as byte

dim iYear as integer, bMonth as byte, bDay as byte
dim bHour as byte, bMin as byte, sSec as single
dim bSec as byte, strX as string*3, strY as string*3, strZ as string*3
dim bOldSec as byte

dim platumsDD as byte, platumsMM as byte
dim garumsDD as byte, garumsMM as byte

option explicit

'-------------------------------------------------------------------------------

Sub Main()

call OpenNMEAin(lInSpeed) 'input
' main loop
do
call GetNMEA
call Idle
loop

End Sub

'-------------------------------------------------------------------------------

Sub Idle()

Debug.Print " Navigate letter: "; cstr(cbyte(Navigate(1)))
End Sub

'-------------------------------------------------------------------------------

Sub OpenNMEAin(byval speed as long)

call DefineCom3(bNMEAInPin, bNMEAOutPin, bx1000_1000) 'inverted, no
parity, 8 bits.
call OpenSerialPort_3(speed)

End Sub

'-------------------------------------------------------------------------------

Sub GetNMEA()

Dim bNMEAData As Byte, tfSuccess as boolean

'NMEA2.3 from eTrex:
$GPRMB,A,0.00,L,,SIGULD,5708.612,N,02450.922,E,25.760,61.5,,V,A*74
'
$GPRMC,122952,A,5656.4802,N,02409.3489,E,0.0,324.0,190208,5.8,E,A*19

call GetByte_3(bNMEAData,tfSuccess)
if (tfSuccess) Then
if bNMEAData=asc("$") then
bChecksum=0
call GetBytes(bNMEA_Cmd,5)
if (bNMEA_Cmd(1)=asc("G")) and (bNMEA_Cmd(2)=asc("P")) and
(bNMEA_Cmd(3)=asc("R")) and (bNMEA_Cmd(4)=asc("M")) and
(bNMEA_Cmd(5)=asc("B")) then
'case "GPRMB"
call SkipCommas(1)
call getValidity

call SkipCommas(2)
call GetBytes(Navigate,3)

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
Call PutPin(RedLEDpin, LEDon)

Call PutPin(RedLEDpin, LEDoff)
end if
end if

end if
end If

End Sub

'-------------------------------------------------------------------------------

Sub CalcNMEAChecksum()

bRawChecksum(1)=bRawChecksum(1)-asc("0") '0-9
if bRawChecksum(1)>9 then
bRawChecksum(1)=bRawChecksum(1)-7 'A-F
end if

bRawChecksum(2)=bRawChecksum(2)-asc("0")
if bRawChecksum(2)>9 then
bRawChecksum(2)=bRawChecksum(2)-7
end if

if bChecksum<>bRawChecksum(1)*16+bRawChecksum(2) then
tfValid=false
end if

End Sub

'-------------------------------------------------------------------------------

Sub SkipCommas(byval i as byte)

Dim bNMEAData As Byte, tfSuccess as boolean
Do
do
call GetByte_3(bNMEAData,tfSuccess)
if not(tfSuccess) then
call Idle
end if
loop until (tfSuccess)
bChecksum=bChecksum xor bNMEAData
if bNMEAData=asc(",") then
i=i-1
end if
Loop until i=0

End Sub

'-------------------------------------------------------------------------------

Sub GetDigits(ByRef Item() as byte, ByVal length as integer)

Dim bNMEAData As Byte, i as integer, tfSuccess as boolean
for i=1 to length
do
call GetByte_3(bNMEAData,tfSuccess)
if not(tfSuccess) then
call Idle
end if
loop until (tfSuccess)
bChecksum=bChecksum xor bNMEAData
Item(i)=bNMEAData-asc("0")
next

End Sub

'-------------------------------------------------------------------------------

Sub GetBytes(ByRef Item() as byte, ByVal length as integer)

Dim bNMEAData As Byte, i as integer, tfSuccess as boolean

for i=1 to length
do
call GetByte_3(bNMEAData,tfSuccess)
if not(tfSuccess) then
call Idle
end if
loop until (tfSuccess)
bChecksum=bChecksum xor bNMEAData
Item(i)=bNMEAData
next

End Sub

'-------------------------------------------------------------------------------

Sub GetChecksumBytes(ByRef Item() as byte, ByVal length as integer)

Dim bNMEAData As Byte, i as integer, tfSuccess as boolean

for i=1 to length
do
call GetByte_3(bNMEAData,tfSuccess)
if not(tfSuccess) then
call Idle
end if
loop until (tfSuccess)
Item(i)=bNMEAData
next

End Sub

'-------------------------------------------------------------------------------

Sub getValidity()

Dim bNMEAData As Byte, tfSuccess as boolean

do
call GetByte_3(bNMEAData,tfSuccess)
if not(tfSuccess) then
call Idle
end if
loop until (tfSuccess)
bChecksum=bChecksum xor bNMEAData
if bNMEAData=asc("A") then
tfValid=true
else
tfValid=false
end if

End Sub

'-------------------------------------------------------------------------------

Why my debug.print only shows zero or 8 when I was expecting 76 for L
and 82 for R ????

Maybe something is wrong with one of tfValid parts ???



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: GPS NMEA $GPRMC =>$GPRMB - Tom Becker - Mar 14 11:15:59 2008

This is not the way I would handle the field today (if you don't use
the crosstrack error, it wastes six bytes of RAM) but, since the
crosstrack error fields are fixed-length, you might try:

dim Navigate(1 to 7) as byte

Debug.Print " Navigate letter: "; cstr(Navigate(7))

call getValidity
call SkipCommas(1)
call GetBytes(Navigate,7) 'get Crosstrack error and Steer direction
Tom

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



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )