Well, I didn't post my code because I do something a little different. I convert from deg min.min to deg.deg so I can perform some math on the waypoints. My code is very ugly and sometimes confuses me.
I think it is very helpfull for people to be able to write code, and "make it their own". That is the only way they will be able to progress, and really make the code do things they want. So I try to give enough data for people to start playing around with the parts of code. The link to MeLabs sites GPS code is a fully functional code that will not have to be reverse engineered. Only needs to be edited slightly to read different digits by changing the skip 34, and a few other small things.
I suggest you ignore pretty much everything I have written below this line for now, and get your hands fully around the above code by playing around with the serin2 command, and seeing what you can get to print out to your computer.
This is NOT the code that I suggest playing around with, but if you must see it, here is a snippet. Darrell and others would probably say they needed a lot of toilet paper and a few Amodiums to go with it. If after seing it, you don't get sick to your stomach, I will try to explain the garbage. I would not say it is advanced. It is just too messy to explain properly. There are a couple errors I need to fix, with a few parenthesis in the wrong place, etc.
This is assuming you use an array called gpsdata.....
Code:IF gpsdata[char_A] = "A" Then 'was 9, Needs to be 13 for EB-85A lathome_hi = ((gpsdata[char_A+2] - 48) *10)+((gpsdata[char_A+3] - 48)) lathome_low = ((((gpsdata[char_A+4] -48)*1000)+((gpsdata[char_A+5]-48)*100)+((gpsdata[char_A+7]-48)*10)+(gpsdata[char_A+8]-48))*5)/3 lathome_min = ((((gpsdata[char_A+9]-48)*10) + (gpsdata[char_A+10]-48))*5)/3 'lathome_min lathome_min = lathome_min + 33*((((gpsdata[char_A+4] -48)*1000)+((gpsdata[char_A+5]-48)*100)+((gpsdata[char_A+7]-48)*10)+(gpsdata[char_A+8]-48))*5)//3 tempbyte = lathome_min /100 lathome_low = lathome_low + tempbyte lathome_min = lathome_min //100 if gpsdata[char_A+12]=78 then north =1 '="N" lonhome_hi = ((gpsdata[char_A+14]-48)*100)+((gpsdata[char_A+15]-48)*10)+(gpsdata[char_A+16]-48) lonhome_low = ((((gpsdata[char_A+17]-48)*1000)+((gpsdata[char_A+18]-48)*100)+((gpsdata[char_A+20]-48)*10)+(gpsdata[char_A+21]-48))*5)/3 lonhome_min = ((((gpsdata[char_A+22]-48)*10) + (gpsdata[char_A+23]-48))* 5)/3 lonhome_min = lonhome_min + 33*((((gpsdata[char_A+17]-48)*1000)+((gpsdata[char_A+18]-48)*100)+((gpsdata[char_A+20]-48)*10)+(gpsdata[char_A+21]-48))*5)//3 tempbyte = lonhome_min/100 lonhome_low = lonhome_low + tempbyte lonhome_min = lonhome_min//100 if gpsdata[char_A+25] = 87 then west = 1 'check to see if we are W or E char 87 = "W"
Ok, now you got that, have your wife or girlfriend grab you another roll of toilet paper, and we will move on to checksums.....
I also, purposely did not go into check sums. You really only need to worry about checksums if your life, or your equipment is at risk because of the way you are using your GPS data. The reason it can be important, is that the NMEA sentences can be rather long. The one you are working with is in the neighborhood of 70 to 80 characters, though I have not counted. There are plenty of chances that by transmission through wires, or wireless, that one bit here or there could be missed, giving you a completely different location. Your equipment might not realize there was an error, unless it compared the checksum from the gps to its own calculated checksum on the data received.
Basically, the checksum is a sum of all the data in the NMEA sentence. It does something similar to adding up all the ascii codes.
I have some example code from an RCAP autopilot project, but this too is not really important if you are not making an autopilot, a hazard avoidance product, etc. So it can pretty much be left out of the equation for most applications.
Code:DoCS: i = 0 ' Initialize the position counter While gpsdata[i] != "*" ' Count everthing until the * cs = cs ^gpsdata[i] ' XOR for checksum i = i + 1 ' Increment position counter Wend ' A quick and easy atoh function ' Make it a seperate label if we add more atoh conversions in the future LookDown gpsdata[i+1],["0123456789ABCDEF"],tempbyte gpscs = tempbyte * 16 LookDown gpsdata[i+2],["0123456789ABCDEF"],tempbyte gpscs = gpscs + tempbyte ' Flag bad data "V" if checksum doesn't add up. ' Or if the sentence is less then 20 chars long ' Which means there is no active waypoint to go to. ' Should be "A" otherwise. IF (cs != gpscs) OR (i < 20 )Then gpsvalid = 0 Else gpsvalid = 1 EndIF Return
Bookmarks