Full Version : Serial GPS NMEA-0183 Decoder (BASCOM)
avr >>BASIC & OTHER AVR LANGUAGES >>Serial GPS NMEA-0183 Decoder (BASCOM)


Admin5- 04-20-2006
Serial GPS NMEA-0183 decoder

CODE

'Forward Arrow
Deflcdchar 0 , 4 , 14 , 21 , 4 , 4 , 4 , 10 , 17

'Upper Right
Deflcdchar 1 , 32 , 31 , 7 , 15 , 29 , 25 , 16 , 32

'Right Arrow
Deflcdchar 2 , 8 , 4 , 2 , 31 , 31 , 2 , 4 , 8

'Lower Right
Deflcdchar 3 , 32 , 32 , 25 , 29 , 15 , 7 , 31 , 32

'Back Arrow
Deflcdchar 4 , 17 , 10 , 4 , 4 , 4 , 21 , 14 , 4

'Lower Left
Deflcdchar 5 , 32 , 32 , 19 , 23 , 30 , 28 , 31 , 32

'Left Arrow
Deflcdchar 6 , 2 , 4 , 8 , 31 , 31 , 8 , 4 , 2

'Upper Left
Deflcdchar 7 , 32 , 31 , 28 , 30 , 23 , 19 , 1 , 32


'$GPGGA,012211.83,4119.6171,N,07730.0636,W,1,03,3.6,00522,M,,,,*36

'GPS Time, Latitude, Longitude Display by Robert J Reeder
'using www.AVRProject.com PCB and null modem connector to
'Magellan 310 GPS.  This uses standard NMEA 0183 codes.

'set up variables

Dim Gps As Byte , X As Byte , Lont(6) As Byte , Latt(6) As Byte
Dim Lat As Byte , Latmin As Byte , Latfrac As Byte , Latns As Byte
Dim Lon As Byte , Lonmin As Byte , Lonfrac As Byte , Lonew As Byte
Dim Timt(6) As Byte
Dim Hours As Byte , Mins As Byte , Secs As Byte

Home
Home
Cls
Cursor Off

Looploop:
Home
Upperline
Startloop:

Gps = Waitkey()
If Gps <> "$" Then Goto Startloop

Gps = Waitkey()
If Gps <> "G" Then Goto Startloop

Gps = Waitkey()
If Gps <> "P" Then Goto Startloop

Gps = Waitkey()
If Gps <> "G" Then Goto Startloop

Gps = Waitkey()
If Gps <> "G" Then Goto Startloop

Gps = Waitkey()
If Gps <> "A" Then Goto Startloop

Gps = Waitkey()
If Gps <> "," Then Goto Startloop

For X = 1 To 6
  Gps = Waitkey()
  Lcd Chr(gps);
  Timt(x) = Gps
  If X = 2 Then Lcd ":";
  If X = 4 Then Lcd ":";
Next X

Timlop:
Gps = Waitkey()
If Gps = "," Then Goto Getlat
Lcd Chr(gps);
Goto Timlop

Getlat:
Lowerline
For X = 1 To 6
Getlat1:
  Gps = Waitkey()
  If Gps = "." Then Goto Getlat1
  Latt(x) = Gps
  Lcd Chr(gps);
Next X

Getlat2:
Gps = Waitkey()
If Gps <> "," Then Goto Getlat2
Gps = Waitkey()
Lcd Chr(gps); " ";
Latns = Gps
Gps = Waitkey()
Gps = Waitkey()

For X = 1 To 6
Getlon:
  Gps = Waitkey()
  If Gps = "." Then Goto Getlon
  Lont(x) = Gps
  Lcd Chr(gps);
Next X
Getlon1:
Gps = Waitkey()
If Gps <> "," Then Goto Getlon1
Gps = Waitkey()
Lcd Chr(gps);
Lonew = Gps


Lat = Latt(1) - 48
Lat = Lat * 10
Lat = Lat + Latt(2)
Lat = Lat - 48
Latmin = Latt(3) - 48
Latmin = Latmin * 10
Latmin = Latmin + Latt(4)
Latmin = Latmin - 48
Latfrac = Latt(5) - 48
Latfrac = Latfrac * 10
Latfrac = Latfrac + Latt(6)
Latfrac = Latfrac - 48

Lon = Lont(1) - 48
Lon = Lon * 10
Lon = Lon + Lont(2)
Lon = Lon - 48
Lonmin = Lont(3) - 48
Lonmin = Lonmin * 10
Lonmin = Lonmin + Lont(4)
Lonmin = Lonmin - 48
Lonfrac = Lont(5) - 48
Lonfrac = Lonfrac * 10
Lonfrac = Lonfrac + Lont(6)
Lonfrac = Lonfrac - 48

Hours = Timt(1) - 48
Hours = Hours * 10
Hours = Hours + Timt(2)
Hours = Hours - 48
Mins = Timt(3) - 48
Mins = Mins * 10
Mins = Mins + Timt(4)
Mins = Mins - 48
Secs = Timt(5) - 48
Secs = Secs * 10
Secs = Secs + Timt(6)
Secs = Secs - 48
'Results stored into
'Hours, Mins, Secs (UTC time)
'Lon, Lonmin, Lonfrac (Longitude degrees, minutes, hundredths of minute)
'Lat, Latmin, Latfrac (Latitude degrees, minutes, hundredths of minute)

Goto Looploop



Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.