normfly@gmail.com
New Member
Hey everyone,
Here's my GPS example for a u-blox NEO-6M GPS. They're cheap on ebay. I could only get it to work on a 20x2 chip.
Here's my GPS example for a u-blox NEO-6M GPS. They're cheap on ebay. I could only get it to work on a 20x2 chip.
Code:
'
'NMEA ref: [URL]http://www.gpsinformation.org/dale/nmea.htm#ZDA[/URL]
'
'init
#terminal 19200 on
setfreq m16
symbol GPSTX = c.2 ' Orange cable
symbol blueLED = c.4
symbol greenLED = B.7
symbol GPSlock = b20
symbol KPH = b21
symbol tempNum = b22
symbol SatNum = b23
'vars
symbol baud = T9600_16
GPSlock = 0'no lock
symbol MinSats = 6
strt:
gosub Acquire
gosub GetTime
gosub GetPosition
gosub GetHeadingSpeed
gosub GetNumOfSat
'gosub showallgpsstrings
gosub LEDStatus
pause 100
goto strt
'------------------------------------------
ShowAllGPSStrings:
serin GPSTX, T9600_16,("$GPRMC"), b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10
sertxd ("##",b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10 ,"#" ,13,10)
return
Acquire:
serin GPSTX, T9600_16,("$GPRMC,"), b0,b1
if b1 = "V" THEN'do time yet
sertxd (" - No signal", 13,10)
GPSlock = 0
else'time aquired
sertxd (" - ACTIVE", 13,10)
GPSlock = 1
end if
return
GetTime:
serin GPSTX, T9600_16,("$GPRMC,"), b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11
if GPSlock = 0 then'no data yet
return
end if
sertxd ("Time ", b0, b1, ":", b2, b3, ":", b4, b5, 13,10)
return
GetPosition:
serin GPSTX, T9600_16,("$GPGLL,"), b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11
if GPSlock = 0 then'no data yet
return
end if
sertxd ("Latt ", b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b11, 13,10)
if b11 = "N" then'north lattitude
serin GPSTX, baud,("N,"), b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12
else'south lattitude
serin GPSTX, baud,("S,"), b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12
end if
sertxd ("Long ", b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b12, 13,10)
return
GetNumOfSat:
serin GPSTX, T9600_16,("$GPGSV,"), b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16'number of satelites
SatNum = b4 - $30 * 10
SatNum = SatNum + b5 - $30
if GPSlock = 0 then'no data yet
return
end if
sertxd ("# of Satelites ", b4, b5, 13,10)
return
GetHeadingSpeed:
serin GPSTX, baud, ("$GPVTG"), b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16
if GPSlock = 0 then'no data yet
return
end if
if b1 = "," then''not moving
sertxd ("Speed 0", 13, 10)
low b.7
else'moving
sertxd ("Heading ", b1, b2, b3, b4, b5, 13,10)
sertxd ("Speed ", b13, b14, b15, b16, 13,10)
if b14 = "." then'slower than 10KPH
tempNum = b13 - $30
else'faster than 10KPH
'100ths
tempNum = b13- $30 * 10
'10ths
tempNum = tempNum + b14 - $30
'not an erroneous reading & enough Satelites / error keeps last KPH
if tempNum < 150 and SatNum >= minSats then
KPH = tempNum
end if
end if
if KPH >= 20 then
sertxd ("Faster than 20 KPH")
high greenLED
else
low GreenLED
end if
end if
return
LEDStatus:
if GPSLock = 0 then'no lock slow blink LED
'blink LED slowly
toggle blueLed
pause 150
toggle blueLed
elseif SatNum < minSats and GPSlock = 1 then'les than min sats, turn on fast blink LED
'blink LED
high blueLED
pause 50
low blueLED
else'lock and enough Satelites solid LED
high blueLED
end if
return
Last edited by a moderator: