Well, then...........
There are a couple different ways to do it. I'm going to show you the Serin2 example, because that is the gps example that MeLabs gives.
Another good way to do it is to read the entire NMEA sentence into an array like this, then worry about parsing it later:
but we will stick with serin2 for now.Code:HSerin 200, Main, [WAIT("$GPRM"), STR gpsdata\MAXDATA\13]
Here is MeLabs gps example for reading speed.
http://melabs.com/resources/samples/...d/read_gps.bas
You would have to adjust to get degrees minutes and then do a conversion for seconds
For instance, their ...
means wait till it sees $GPRMC that begins the NMEA sentence, skip 34 characters to the speed tens digit, put it in variable "tens", then read next speed digit and put in variable called "digits", then skip the "." and read the last decimal into a variable called "tenth".Code:SerIn2 GPSin,baudGPS,Timeout,Nogps,[wait("$GPRMC"),skip 34,DEC1 tens,DEC1 digits,skip 1,DEC1 tenth]
You would have to adjust the skips to match the digits you want to get.
If your NMEA sentence was similar to above (some add more resolution and are of slightly different format), then you could use:Code:$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A Where: RMC Recommended Minimum sentence C 123519 Fix taken at 12:35:19 UTC A Status A=active or V=Void. 4807.038,N Latitude 48 deg 07.038' N 01131.000,E Longitude 11 deg 31.000' E 022.4 Speed over the ground in knots 084.4 Track angle in degrees True 230394 Date - 23rd of March 1994 003.1,W Magnetic Variation *6A The checksum data, always begins with *
Now, you need to convert decimal minutes to seconds .... am I right this time? Because the GPS will output in decimal minutes, not seconds.Code:SerIn2 GPSin,baudGPS,Timeout,Nogps,[wait("$GPRMC"),skip 11,DEC2 lat_deg,DEC2 lat_min,skip 1,DEC3 lat_min_dec ... then same for longitude]
So, to convert decimal minutes into seconds:
lat_seconds = lat_min_dec * 6
so, using the NMEA sample above: 038 * 6 = 228
When you print this out to your computer, you print a "." in between the twos
and get 2.28 seconds. This part just prints the seconds out through the serial port.
The dig specifies which digit you want to print of the variable called seconds. Rightmost digit is 0
Code:DEBUG DEC lat_seconds dig 2,".",DEC lat_seconds dig 1, DEC lat_seconds dig 0,13,10





Bookmarks