28501 gps
mmoreland
Posts: 89
How does the 28501 GPS module and a BS2p derive or interpret the time/date information (hr:min:sec and month day year that print when the program is running) from the data it receives from satellites? What is the essential time/date information that's transmitted?
Comments
The GPS satellites send 37k messages at 50 bits per second. The message consists of frames, where some data is repeated as often as every 30 seconds but other parts may go the full 12.5 minutes between repeats. The message contains a lot of stuff, including but not limited to:
- Time, as week number since Jan. 6 1980 (10 bits, i.e. rolls over after 1023) and time within the week. The time is not corrected for leap seconds and is as of now 15 seconds ahead of UTC.
- Almanac data, which are reduced-precision ephemeris data for all the GPS satellites.
- Ephemeris data, full-precision, for itself only.
- Telemetry data (housekeeping).
- Satellite ID.
The ephemeris data is needed to calculate where the satellite is. When you know the time and position of at least 3 satellites you'll be able to calculate where you are.
As it takes time for the ephemeris data to come around, and it takes time to find the satellites in the first place (and when you find one you'll have to wait for the almanac data to come around so that you can get an idea of where the others are, and thus their doppler shift and frequency, and when you find it you have to wait for its ephemeris data), then you have the reason for why it can take a while to get first lock.
-Tor
http://www.tronico.fi/OH6NT/docs/NMEA0183.pdf
According to the manufacture's spec, The ZDA sentence is not available in this model.
Date and time are available in the RMC sentence.
http://forums.parallax.com/showthread.php?129914-Parallax-GPS-sensor-PMB-688-1PPS&highlight=1pps
This is true. I am, however, wanting to use ddmm info in another place, so I've used GET to put it in some variables. The problem I've run into is that the RMC string changes length due to changes in number size a few places to the left of the date, so I can't reliably obtain the ddmm figures as they move from location to location. Normally they are in locations 50-53, but some times they are in locations 49-52 and occasionally in 48-51. If there's another way around this problem, I'd be happy to learn it. That's why I hoped to get the ZDA string. mm
So, count the commas.
With $GPGLL, the position of date and time in the sentence do not vary.
Then set up a loop that WAITs for a comma 8 times and then capture the date data into your array.
Or
WAIT for "$GPRMC,"
SKIP the next 38 characters
WAIT for a comma
WAIT for a comma
capture 6 bytes date data into your array
Any new developments?
How do you fare now?
SERIN GPSpin, T4800, [WAIT("GPRMC,"), SKIP 43, WAIT(","), SPSTR 4]
GET 0, d, dd 'get two day bytes from GPS
GET 2, m, mm 'get two month bytes from GPS
and for getting the hour of the day, I used the following:
SERIN gpspin, T4800, [WAIT("GPRMC,"), SPSTR 65]
GET 0, h, hh
and both have worked just fine. I've been able to save all the data to variables and use them elsewhere. It has been a perfect solution. Thanks. There is a statement in the SERIN line from the GPS sample program following "T4800" that is "3000, No_GPS_Data with a few lines of code below beginning with No_GPS_Data: a pause and a goto, and as long as that statement is in the SERIN line, I can't get the program to leave the GPS section and go on to the section that checks the inclinometer and the section that runs the motor, so I just took it out, but I think that's not really the right way to do it since there could be a time when there was no GPS data. Does any of that make sense? Do you have any suggestions? mm
Since time and date are in the RMC sentence you should be able to collect that data with one SERIN.
The time data is/are the first 6 characters after "$GPRMC,"
"Speed over the ground" and "Track angle in degrees", two data fields of RMC are variable length, I thought (and the cue to count commas.) Maybe it's the Speed field, not a fixed number of characters.
However, the point's moot since this is for a fixed position installation. I read in another subject of yours related to this that this is for positioning a solar collector/array.
If the SERIN Timeout is used then, given a threshold without data, the program should branch to a subroutine that reports that it cratered. Then it could go back to that SERIN or END (or you decide.)
Assuming all's well, though, the line immediately after the SERIN should be a routine where you proceed to work with the data collected.
PE -- In a similar vein, I capture all of this information:
PA VAR Byte (2) 'dd latitude
PM VAR Byte (2) 'mm
PD VAR Byte (3) '.mmm leaves off last dp
NS VAR Byte (1) 'NS
MA VAR Byte (3) 'ddd longitude
MM VAR Byte (2) 'mm
MD VAR Byte (3) '.mmm leaves off last dp
EW VAR Byte (1) 'EW
TM VAR Byte (6) 'hhmmss no frac time
AV VAR Byte (1) 'A or V, VAL or INVAL
with one line (and a lot of formatters) --
I don't know why they didn't make the speed and/or track angle fields fixed i]is it both?[/i with leading zeros (as w/ lat & lon).
In case "comma counting" is too slow, you could count the periods (2) after the E/W character and then set up a WAIT for a comma where the next character will be the first of the date.
GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W,6A
GPSpin PIN 0
T4800 CON 500
d VAR Byte
dd VAR Byte
m VAR Byte
mm VAR Byte
day VAR Byte
mon VAR Byte
date VAR Word
Initialize:
PAUSE 250 ' Let DEBUG open
DEBUG CLS ' Clear the screen
Main:
SERIN GPSpin, T4800, 2000, No_GPS_Data, [WAIT("GPRMC,"), SKIP 43, WAIT(","), SPSTR 4]
No_GPS_Data:
PAUSE 2500
GOTO Initialize
GET 0, d, dd
GET 2, m, mm
day = ((d-"0")*10)+(dd-"0")
mon = ((m-"0")*10)+(mm-"0")
date = (mon-1*30)+(mon/9+mon/2)-(mon MAX 3/3*2)+day
DEBUG "Day of the year is ", DEC date,CR,CR
SLEEP 15
When the "No_GPS_Data" label is placed immediately after SEROUT, the program recycles endlessly between the command and the label. If the label is placed at the end of the program but before SLEEP, it executes the code that follows SEROUT, but it never sleeps. If I put it after the SLEEP command, it works fine, but I suspect the isn't doing anything.
In the fuller set of code, there are a number of subroutines. If the label is placed before the subroutines, they never execute, but if it's placed at the end after all the subroutines, it's ineffective in assuring the routines have GPS data to use.
The BS Manual asserts (p. 415) that in order to use the Timeout, Tlabel, arguments, Fpin must be specified, but in the example on p. 408, no Fpin is specified. However, in the example, the Tlabel ends with a DEBUG. It doesn't contain a GOTO as my use does. Any idea what I'm doing wrong here?
One last item...I just added a DEBUG to the Tlabel. The program executes, gives me a day of the year, sleeps for 15 seconds and then executes the Tlabel argument with the DEBUG statement that there is no GPS data despite the fact that there is data. mm
What's happening is that if it has good data it executes the very next line of executable code - which is, in your example the first line of the No GPS Data routine". You have to jump over that
Your list of variables has numbers in parentheses...what is that? Perhaps you'd say something about what's happening in your string of formatters above.
$GPGLL,3723.2475,N,12158.3416,W,161229.487,A*2C
Given:
SERIN 9,188,[WAIT("GLL,"),STR PA\2,STR PM\2,SKIP 1,STR PD\3,SKIP 2,STR NS\1,SKIP 1,STR MA\3,STR MM\2,SKIP 1,STR MD\3,SKIP 2,STR EW\1,SKIP 1,STR TM\6,SKIP 5,STR AV\1]
It's for a BS2, no scratchpad ram, so everything goes into VARs/VAR arrays [the parentheses with the VAR declarations mean: Array!]
Most of the SKIPs are skipping commas, the SKIP 5 skips over the decimal and 'frac' seconds of the time and the following comma.
PA array captures 3 7
PM array captures 2 3
skip period
PD array captures 2 4 7
skip 5 comma
NS captures N
skip comma
MA array captures 1 2 1
MM array captures 5 8
skip period
MD array captures 3 4 1
skip 6 comma
EW captures W
skip comma
TM array captures 1 6 1 2 2 9
skip period 4 8 7 comma
AV captures A
Mike
There is probably nothing wrong with the unit other than getting a good signal.
Mike