Page 1 of 1

Tutorial on interfacing a GPS chip with microcontroller

Posted: Thu Oct 25, 2012 4:22 pm
by SevenZero
Here is the circuit diagram and a working code (in Basic). Code is not so good, you can simply convert it to C.
1.GIF
1.GIF (24.14 KiB) Viewed 4769 times
If you are from Sri Lanka, you can buy all these components from TRONIC.LK.

Code: Select all

      $baud = 9600
      $crystal = 11059200
      Config Lcd = 16 * 2

      Config Lcdpin = Pin , Db4 = P0.2 , Db5 = P0.3 , Db6 = P0.4 , Db7 = P0.5 , E = P0.1 , Rs = P0.0
      Rem with the config lcdpin statement you can override the compiler settings

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

'GPS Time, Latitude, Longitude Display

'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
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
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);
Gps = Waitkey()
Gps = Waitkey()
Gps = Waitkey()
Locate 1 , 11
Lcd "Sat:"
Gps = Waitkey()
Lcd Chr(gps);
Gps = Waitkey()
Lcd Chr(gps);

Goto Looploop

Re: Tutorial on interfacing a GPS chip with microcontroller

Posted: Thu Oct 25, 2012 4:24 pm
by SevenZero