GPS2Time - a means of sync-ing your computer clock using a GPS Receiver
 
12 May 2018
 
 GPS2Time - active screen layout
 
Yet another GPS network time synchronization / synchronisation software application for Windows 7+...
 
A FREE one... 
 
(Some people may ask how I make money from this - quite simply, I don't.
Amateur radio applications are my hobby, not my job.)
 
------------------------------------------------------------
 
 
GPS Time-setting background errors explanation extracted from http://www.laptopgpsworld.com/3235-pc-clock-synchronization-using-gps :
 
"Consumer GPS signals. Consumer GPS receivers that are used primarily for navigation or geolocation functions are not designed to provide time synchronization. However, they can be used as a crude substitute in the field if one has the necessary software and is aware of the limits.

The data that is sent from the GPS receiver is a series of standard "sentences" that contain defined data. The data in those sentences are defined by the NMEA 0183 (National Marine Electronics Association standard 0183) or NMEA 2000.

The NMEA 0183 standard sentences allow the GPS receiver to send information related to Time & Date, Geographic Position - Latitude/Longitude, and individual satellite information. It's the Time & Date information that matters here.

The GPS satellites each contain three Stratum One cesium atomic clocks in them. These are highly stable clocks that were originally calibrated with UTC, so the signals that originate from them can be considered a good sync link back to UTC, and therefore a good source of synchronization on their own.

However, there are a few minor hitches in this that need to be understood. Latency is always the killer when trying to sync two or more devices together. That is, essentially, the time it takes for the signal to travel from sender to receiver. In the case of the extremely weak GPS signals, there are many things that will affect this. These are mainly related to atmospheric conditions from high in the atmosphere to anything affecting only local conditions. 

If two devices are close enough together to be connected to the same GPS receiver, say via Bluetooth, it really won't matter because they'll be getting the same signal and by using it will be sync'ed as accurately as that signal will allow.

If they are too far apart to use the same GPS receiver but close enough together that they are affected by the same local atmospheric conditions, say, within a few miles of each other, it still won't be an issue as long as they use the same make/model of receiver and the same software.

If they are so far apart that they are being affected by significantly different atmospheric conditions, all may not be lost. Most GPS receivers support a protocol called WAAS (Wide Area Augmentation System). This is, to keep it really simple, a system of satellites and ground stations that are used to provide GPS signal corrections. These corrections account for GPS satellite orbital drift and clock drift plus signal delays caused by conditions in the atmosphere and ionosphere.

So, if our two GPS receivers that are far apart both have WAAS enabled they will still be pretty close, accuracy-wise, after the corrections are done.
"
In my conclusion at the bottom of this page, you will note that the errors are also dependent on the serial data rate (i.e. the baud rate) of the stream from the GPS receiver. This software will work up to 57600 Baud so synch errors can be minimised. Further, since we are only using one GPS receiver, the more recent the model usually means more satellites can be "seen" to provide greater decoded accuracy - a far call from some of the early receivers that could get signals from maybe only eight.
 
------------------------------------------------------------
 
 
With my recent take-off into FT8 operations on HF, and with the possibility of operating FT8 whilst portable, the need for accurate setting of the notebook computer clock arose. It appears that an error of one second seems to be the maximum allowable such that over-run or under-run of the 15 second transmit or receive period does not occur.
 
As such, WSJT-X needs the system clock to be very close to exactly on time. The data displayed shows how far off the precise time your computer is and that becomes apparent when you look at the DT field info. Most digital operators use a time sync option to keep the clock 'pretty-well exact' by virtue of internet time servers but that is not necessarily practical when portable in the middle of nowhere and in a place without cellular coverage.
 
The well-known GPS system comes to the rescue there as the decrypted NMEA0183 data streams from the GPS receivers contain at least two time sequences -in the GPGGA and GPRMC stream components. I did a quick look around the web for a GPS application that would keep the PC clock up-to-date but found little that was any help.  One application, GPSTIME (https://www.coaa.co.uk/gpstime.htm), looked good until I discovered that it wouldn't open the serial port when set to COM16. The other applications I found were of the "pay" persuasion but since I had written software a few years back called Gridloc, with an enhanced version called GridlocWM, which handled GPS streams and did Maidenhead Grid conversion, paying for an application did not seem right for me.
 
Those two applications are a bit dated now (eg ok for Win95/98/ME/XP) but take up too much screen real estate, and more importantly will not work under Windows 7+ (8,10..) because of the rights required to alter the system clock in these later OS versions. Rather than try to update them, a new more-compact application project was commenced, again using Delphi. I called it GPS2Time, again with the concept of sync-ing the notebook clock from the GPS system on whatever time interval I desired plus adding Lat & Long displays in both DMS and Decimal Degree formats to provide actual location information, plus the Maidenhead Locator value was generated as a side benefit.
 
 
One typical data block from the GPS receiver contains multiple $GPxxx segments with one like 
"$GPGGA,235217.00,2744.52743,S,15257.58943,E,2,11,0.81,99.7,M,37.9,M,,0000*74" 
where the 235217.00 represents 23:52:17 UTC.
 
This is updated each second so that the time then next shows as 235218.00.  Because it is only updated each minute - and the software needs time to decode the data and then (when active) update the Windows system clock - all these add the possibility of accumulated errors in setting the time accurately. The outcome is that on a fast PC, with a high baud rate (as dictated by the GPS device), the errors in time setting are well under one second.
 
By the way,the "2744.52743 S" in the above data string is the current Latitude, the "15257.58943 E" is the longtitude, the "11" is the number of satellites in view, the "99.7" being the estimated receiver height ASL in Metres etc.. A lot of information is conveyed in the total data available from the GPS receiver.
 
The application still needs to be started in "Administrator Mode" - and that worried me for a while until I recalled that my normal internet time control software ( NetTime 3.14 from http://www.timesynctool.com/ ) needed that too, plus many other Windows management applications.
 
I could have changed the software so that it ran as a Windows Service but that would mean that the installation - and any subsequent removal - would be more complicated. This format means copy or delete the file and/or folder and that is all that is required. The data left stored in the Windows Registry is insignificant.  
 
The best news for you is that it is free... like the rest of the application software I have written and have available on this web site (VK4ADC.COM).  I retain copyright and request that only links to the application are made and that the software itself is not placed on any other web site. There will probably be a number of updates to the code as it becomes more widely used and bug reports filter in ( to doug at vk4adc dot com). Any links will thus point to the correct location as the distribution will only ever have one name, only the version number and date will change.
 
The GPS2Time application is in Zip (compressed archive) format as downloaded and all that is needed is to decompress it (preferably) into a new folder named GPS2Time - but it can be any folder name you like.  Make a shortcut to it by right-clicking on the application 'GPS2Time.exe' in that folder and selecting "Send To" then  "Desktop". No complex installation is required, just the one file in the folder. A second one might join it later depending on whether you use the Save Position button on the application.
 
 
 
The application in ZIP format : GPS2Time.zip  (about 320KB in size, expands to GPS2Time.exe around 650KB)
Current version : 1.0.0.7
Version date : 03Sep2018
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
Finally a word of warning : your USB GPS device might be the source of broadband noise across the HF spectrum so if all of a sudden after plugging it in, close down this application and unplug the device and note if the noise disappears. Mine did. It means that you connect it, sync your computer clock, note your Grid Square, close down the software and possibly unplug the USB GPS device rather than leaving it powered up and running.
 
 
Well that descriptive stuff is all nice enough... but how do I use this software ??
 
Firstly, you will need a GPS receiver with either a USB interface built in or a serial version and a spare serial port (totally unusual on any newer notebook PC, usually none are fitted).  The USB GPS receiver is usually in one of two forms - a small dongle that plugs directly into a USB port -or- a square or round receiver with a flylead ending in a USB plug. I favour the latter approach as you might need to take your notebook plus dongle outside to get a clear view of the GPS system whilst a flylead style might give you enough clearance near a window to "see the sats".  The alternative is to have a 5 Metre USB extension lead in your kit and take the dongle (whichever format) outside.  I bought a cheap GMouse VK-162 GPS/GNSS receiver (via eBay) with a magnetic mount and a 1 Metre USB flylead for about $16 including postage and it does all I need it to in this application.
 
Secondly, open Device Manager under Windows, look for Ports and expand it if it is present, then plug in the USB GPS. Windows will eventually install a driver and a new COM port should appear. Note the new COM port value eg COM12.
 
Next, start the GPS2Time application ensuring that it is in "Run As Administrator" mode.  There are two ways of achieving this : 
(1) right-click on the shortcut and select "Run as administrator" from up near the top of the menu options.  
(2) For a permanent setting, right-click on the shortcut and select "Properties" from the bottom of the menu options, select the Compatibility tab, and in the Privilege section, place a tick against "Run as administrator", Apply then Close. Double-click the GPS2Time button. In the ensuing "User Account Control" message box, select the 'Yes' button.
 
 
A number of the boxes are prefilled with the descriptive texts as to what will be placed in each location but the one in the top LHS will always be empty the first time around. Click the down-facing arrow at the end of it and a list of the serial / COM ports that Windows knows about will be displayed. Select the one discovered in the second step. Set the Baud rate value to that matching your GPS receiver specifications. Most seem to be 9600 but some may require the setting to be altered to 4800 or 19200. Mine works at 57600 too, as is apparent from some of these screen captures.
 
 
 
 
Once the Baud Rate box shows the correct value, press the Run button. If data from the GPS is available, the initial textual labels will be replaced by the current UTC time, UTC date, Lat and Long values in the two formats plus Grid Square details. If it does not display these values then either the selected port or the baud rate values are incorrect. Alter one or the other and try the Run button again. If it does not see any valid data within 3 seconds, it will grey out the Run button until another COM port selection is made.
 
NOTE: The mandatory use of the Run button prevents software crashes if the GPS receiver has been unplugged and the derived COM port is not actually available at starup. ( Auto-running can cause serial port issues.)
 
Note that the currently selected serial port value, baud rate and screen position values are retained within the Windows Registry for quicker startup the next time the software is activated on that computer. (The base key is HKEY_CURRENT_USER\Software\VK4ADC )
 
 
 
 
While the software does show how many satellites it can "see", provided the background colour is a shade of green then you can use the "Update Now" button to set the computer's clock. You can also set this software to update the clock automatically at a number of preselected intervals (in minutes) while the computer and this application is running - and the GPS receiver remains active. Select the desired interval and then use the "Update Now" button to setup the next time it will update. The 'Next Update; box will flash with a yellow background each time an update is active then return to a white background.
 
 
 
 
More detail of the two main data streams (GPGGA and GPRMC) can be observed by ticking the "Show Raw" box, and it also shows the quality of the satellite fix. It will show either NIL, GPS or DGPS - with DGPS providing the highest fix rating.
 
The Grid Locator will vary in detail depending on the number of satellites in view. It should typically show a 6-character grid but will expand that to 8 characters if a higher number of satellites (and thus providing a better fix) are seen.
 
 
Click on the Exit button to terminate the application.
 
 
The Save Position button is a simple method of retaining information about where you were when you ran the software. For instance you might have been portable in the bush somewhere - but where exactly ??  The file 'PosnLog.txt' in the same folder as the application is appended when you press this button. A saved data example is : 11/04/2018, 21:57:55 UTC, QG62LG51EV, -27.742123° 152.959780°, 27S 44'31.644" 152E 57'35.208" , 09, 103.1, COM16 where date and time are in UTC - the same as your logbook format - and the grid is fairly precise since we are seeing 9 sats, Lat and Long are there in 6 digit decimal precision. Put those values into Google Maps later and you can see exactly where you were. 
## As from version 1.0.0.3, the PosnLog.txt file is automatically updated if a different sub-grid square (ie 6 char) has been determined.
 
 The View Posn Log button was added near the Save Posn button (from V1.0.0.5) to make it easier to view the contents of the PosnLog.txt file through the use of Windows Notepad, making editing plus copy/paste possible eg if the grid locator needs to be transferred elsewhere - like any logging software. 
 
 
Finally, the true test of the time setting accuracy.
I turned off my NetTime application, purposefully adjusted my computer time back by 
about 20 seconds then ran GPS2Time. The system clock jumped back to display the same time as the GPS time. WSJT-X displayed DT values around -0.2 to -0.8 second on a number of stations on 14MHz. I then closed GPS time and started NetTime. It's sync screen showed an adjustment of +777mS and the DT values jumped to around +0.6 to +0.2 seconds on those same stations.  That was with a baud rate of 9600BPS but there is a trick to be aware of : my Gmouse GPS will also output at 57600 and then the NetTime adjustment was just 9mS when the same process was repeated.  If you can run a high serial baud rate then time setting errors are minimised.
 
 
Version History:
1.0.0.1 : 12/4/18, Initial release
1.0.0.2 : 13/4/18, Updated to use different serial library, remainder of functionality unchanged
1.0.0.3 : 14/4/18, As from version 1.0.0.3, the PosnLog.txt file is automatically updated if a different sub-grid square (ie 6 char) has been determined. 
1.0.0.4 : Not released
1.0.0.5 : 03/6/18, Revised timing arrangements for PC time update sequencing so that it happens immediately on a GPS time decode & display thus reducing errors in time-setting. Added a 'View Posn Log' button so that any saved locations can be viewed (/edited for copy/paste) more easily.
1.0.0.6 : 02/9/18 Reworked the date format so that the displayed date conforms with the Windows regional settings in either dd/MM/yyyy or MM/dd/yyyy style formats. Other formats are possible based on user feedback. Solves invalid time issues for USA users who use the month/date/year style.
1.0.0.7 03/09/18 Added a DST tickbox to allow those in regions where Daylight Saving Time applies to correct for any time offset. In areas where DST does not apply, ticking or unticking does not change the time offset during clock setting.
 
VK4ADC