Published in the wake of the article
Making our own NTP-server Stratum-1 .
The article was told that you can use an external GPS receiver connected via a serial port (COM) to determine the exact time and synchronize the local time of the computer. But, as experience shows, not everything is so simple. Why? Let's try to figure it out.
The time from the receiver, for example, such as we use GARMIN GPS 35-HVS is transmitted via two channels. The first is the usual RS-232 serial channel over which NMEA standard time is transmitted, the second is the usual discrete PPS signal, routed to one of the overhead signals of the same RS-232.
Let's start with the description of NMEA. This is a plain text protocol, in which one after another packets are of the following types: WPL, AAM, APB, BOD, BWC, RMB, RTE and all others. Specific packages that will go in each case depends on the type of GPS receiver and its settings.
To work with the receiver we will use the program
NMEATime . We will use the
FreeSerialPortMonitor program to view the packets going through the serial port.
Turn on, look:
')
At this moment, the following packages come from the receiver:
$GPGGA,082407,5609.0341,N,04713.1558,E,0,00,,,M,,M,,*50
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,10,05,40,063,,10,28,049,,13,01,349,,15,04,116,*73
$GPGSV,3,2,10,16,38,301,,18,12,186,,21,52,236,,24,74,092,*7F
$GPGSV,3,3,10,29,60,125,,30,09,176,,,,,,,,,*79
$GPRMC,082408,V,5609.0341,N,04713.1558,E,000.0,000.0,301209,011.2,E*68
$GPGGA,082408,5609.0341,N,04713.1558,E,0,00,,,M,,M,,*5F
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,10,05,40,063,,10,28,049,,13,01,349,,15,04,116,*73
$GPGSV,3,2,10,16,38,301,,18,12,186,,21,52,236,,24,74,092,*7F
$GPGSV,3,3,10,29,60,125,,30,09,176,,,,,,,,,*79
$GPRMC,082409,V,5609.0341,N,04713.1558,E,000.0,000.0,301209,011.2,E*69
$GPGGA,082409,5609.0341,N,04713.1558,E,0,00,,,M,,M,,*5E
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
The order in which they are generally not defined.
We are interested in GPGGA and GPZDA packages.
$ GPGGA, 123519,4807.038, N, 01131.000, E, 1.08.0.9.545.4, M, 46.9, M ,, * 47
This package in its first field contains the current time in UTS format with an accuracy of a second. In the example, this is 12 hours, 35 minutes, 19 seconds.
$ GPZDA, 201530.00,04,07,2002,00,00 * 60
This is not only the time to within a second, but also the date and current time zone. In the example, this is July 4, 2002, 20 hours, 15 minutes, 30 seconds.
Now it is worth mentioning how to improve the accuracy of determining the current time. Very simple. Need to use the PPS signal. In my case, it is there and is connected to the CTS serial signal This signal is interesting because its front coincides with the beginning of the current second, and having received it, we can assert that the zero millisecond is now going. The PPS signal is not always present, but only if there are a sufficient number of satellites in view of the antenna. On my receiver for this you need 3 satellites.
It should be clarified that I deal with this task in relation to automation equipment for power engineering, which is produced by the company in which I work. There, the PPS input state is polled at an interval of 0.83 milliseconds, respectively, the device time is synchronized with such accuracy.
That's basically it.