How to get Heading from Parallax VON1513 GPS Module?
Hey All! I'm using the Parallax Gps Module(This one) in a robotics project. I have been able to get Lat and Long points using:
But I cant seem to figure out how to "serin" the head(which is a word and has a value of $09). I know it is two bytes, but how do you receive them and then combine them to create the heading from the gps module? All help or suggestions are appreciated!
Thanks,
Tyler
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
GetLat = $05
GetLong = $06
VAR
long stack[30]
OBJ
GPS : "FullDuplexSerial"
PUB Main
GPS.start(5, 5, 00, 9600)
cognew(GetGpsData,@stack)
PUB GetGpsData
repeat
GPS.str(string("!GPS")) ' GPS command header
GPS.tx(GetLat) ' for latitude
WriteVal
Debug.str(string(","))
GPS.str(string("!GPS")) ' GPS command header
GPS.tx(GetLong) ' for longitude
WriteVal
Debug.str(string(13))
PRI WriteVal | Degrees, Minutes, MinutesD, Dir
WaitCnt(ClkFreq / 10 + Cnt) ' 1/10 second wait
Degrees := GPS.rx ' Retrieve bytes from GPS
Minutes := GPS.rx
MinutesD := (GPS.rx << 8) | GPS.rx
Dir := GPS.rx==1
if dir == -1 ' If Dir = -1, prepend - sign
Debug.str(string("-"))
Debug.dec(Degrees)
Debug.str(string("."))
workVal := (Minutes * 1000 / 6) + (MinutesD / 60)
Debug.dec(workVal)
But I cant seem to figure out how to "serin" the head(which is a word and has a value of $09). I know it is two bytes, but how do you receive them and then combine them to create the heading from the gps module? All help or suggestions are appreciated!
Thanks,
Tyler

Comments
SomeVar := (GPS.rx << 8) | GPS.rx
This places the values returned in two successive byte reads from the GPS into a single variable. The first byte is shifted up by eight bits; the second byte takes the lower eight bits. Viola! A 16-bit value, suitable for framing and catching fish.
Do note that heading is inaccurate if the module is not moving. Anything under 5-10 MPH cannot be trusted.
-- Gordon
The numbers defiantly aren't in degrees, but they seem consistant in that one direction yields the same number. Is there a way to convert these numbers into degrees or have I done something wrong here is my code for the capture:
PUB GetGpsData repeat GPS.str(string("!GPS")) GPS.tx(GetLat) WriteVal Debug.str(string(",")) GPS.str(string("!GPS")) GPS.tx(GetLong) WriteVal Debug.str(string(",")) GPS.str(string("!GPS")) GPS.tx(GetHead) WaitCnt(ClkFreq / 10 + Cnt) Head := (GPS.rx << 8) | GPS.rx Debug.dec(Head) Debug.str(string(13)) WaitCnt(ClkFreq / 10 + Cnt)Thanks,
Tyler
-- Gordon
Thanks,
Tyler