GPS2Time - a means of sync-ing your computer clock using a GPS Receiver
 
Started 12 May 2018
 
 
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.
 
 
 
This is the error in time recorded with version 1.0.0.16 over a period of some 6 hours. Note the +/- 500mS axes  (orange) and the actual offset values in red. Well and truly within the 1 second requirement for FT4 & FT8 operation.
 
Note the presence of the time adjustabilty from +5 to -5 second of UTC (/correct time). This should be enough range to advise anyone on digital modes to check their clock setting !!!
The Zero/Reset button is a quick way to remove any offset.  The clock will automatically be updated as you press the up/down buttons - there is no need to press the Update Now button.
V16 now has 115200 baud available too..
 
 
 This is a full data grab from screen for V16 and shows the comparison software details : NTPMonitor V5.16.50 after editing the clocks.txt file to include local NTP sources. 
 
 
 
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" (Win7 to 10 etc)  - 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.
 
Be warned : If you are contemplating buying a "VK-162 GPS mouse" via eBay then read the following :
'
You might be interested in a problem I have encountered, when I tried to buy a ‘backup’ VK-162. 
The first ‘VK-162’ I bought on eBay works well – I repeated the order but what arrived was marked differently – instead of just ‘G-Mouse’ it is marked ‘G-Mouse’ then on the next line ‘BD&GPS’.   I can’t get any PC to even recognise this second VK-162 as a USB device.
I bought a 3rd one and it’s the same as the 2nd one – neither of them work!   I think the BD refers to the Chinese Beidou No.1 satellite, so maybe these BD&GPS ones are not U-blox 7 inside, but some Chinese clone?  I can’t find any driver software for them at all, so they are probably duds....
73    Chris    GM3WOJ
'
 
 
The application in ZIP format : GPS2Time.zip  (about 320KB in size, expands to GPS2Time.exe around 690KB) ** Note must be run as Administrator under Win7 to 10, but as a normal user under Windows XP. { other Windows releases not known }
Current version : 1.0.0.23
Version date : 7th  December 2019
 
{{{ -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
There is also an  XP-only version available here : GPS2TimeXP.zip    ** Note must be as a normal user under Windows XP. { new version ZIP at 30th October 2019,  mostly tested, some Windows Region setting issues may remain }  Now has variable time offset options as well as calibration. Read the GPS2TimeXP.txt file in the ZIP to find out more. Note that you must select Baud, COM and then Run in that order when first executed.  (11Oct19 change was purely to solve on-screen re-sizing issue)
 
If you want to run the calibration option, I suggest downloading and doing timing comparisons using NTPMonitor from
https://www.satsignal.eu/software/ntpmonitor.5.1.6.zip and adjusting it's clocklist.txt file to local NTP sources in your locality.

 

 

Note the layout has been altered (V16) but functionality remains similar.

 

Note that the XP version has an option to adjust the computer time backwards or forwards by 5 seconds in one second increments, and that becomes obvious when you see the detail in the UT Offset box (red ellipses). Note that the blue ellipses show only 2 seconds difference yet the offset is set to 3 seconds - that is a result of an internal timer that only updates the computer time display each second.  Use the About GPS2TimeXP button and read some brief info to take note of.

NOTE# : If your GPS2TimeXP version shows the UTC offset is one second out as normal, you can EITHER set  up the software in CAL mode (read the txt file) OR use Windows Explorer to navigate to the gps2timexp.reg file that is contained in the most recent ZIP and was extracted into the folder with the executable, right-click and select Merge. Approve any questions and the Windows Registry will be updated to solve the one-second offset issue.  The .reg file contains only 3 'data' lines and can be opened by Notepad if you want to check it.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- }}}  
 
 
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 ??  NOTE THAT SCREEN IMAGES BELOW ARE NOT BEING UPDATED AND REPRESENT EARLIER VERSIONS ONLY.
 
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.  Try the setting at 115K and see if the GPS data updates, if it doesn't then step down one speed to 56K and try that. Keep reducing the baud rate until it show GPS data changing each second, easiest noted if Show Raw is ticked.
 
 
 
A very timely notification :
EVERY TIME YOU START THE SOFTWARE, YOU MUST RESELECT THE COM PORT !!
 
 
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. 
 
In release V1.0.0.8, an optional /LOG command can be included in the command line for the GPS2Time application - for most this will be in the properties of the shortcut..   So the properties' Target detail might be something like C:\gps2time\GPS2Time.exe /LOG  and its presence becomes obvious by the presence of  small box that appears over the dividing centre line which initially contains a capital L. 
 
 
One of the best things about this option is that it can capture initial data strings from the GPS or GPSDO device, and these data strings can help solve any issues. For instance my little GPS device gives me lines like
"
$GPTXT,01,01,02,u-blox ag - www.u-blox.com*50
$GPTXT,01,01,02,HW UBX-G70xx 00070000 FF7FFFFFo*69
$GPTXT,01,01,02,ROM CORE 1.00 (59842) Jun 27 2012 17:43:52*59
$GPTXT,01,01,02,PROTVER 14.00*1E
$GPTXT,01,01,02,ANTSUPERV=AC SD PDoS SR*20
$GPTXT,01,01,02,ANTSTATUS=OK*3B
$GPTXT,01,01,02,LLC FFFFFFFF-FFFFFFFF-FFFFFFFF-FFFFFFFF-FFFFFFFD*2C
"
 
The /LOG option creates a text file named GPS2Time.log which contains mostly GPS raw entry information (in effect a data capture) with a few extracted data lines interspersed. The maximum allowed file size is 50KB and any of this logging is automatically stopped once the file reaches this size.  This state reflects in the small box that appeared over the dividing centre line which then contains a capital S. 
 
To re-start this feature, the application must be stopped, GPS2Time.log file must be manually deleted, and then the application re-started.
 
 
 
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.
 
The higher the baud rate value, the more accurate the time setting process is..... 
 
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.
1.0.0.8 25/05/19 Added a /LOG option for easier data capture. 
1.0.0.9 27/05/19 Changed the serial port trigger arrangement to allow the software to work with a range of products with non-fully-NMEA-compliant data structures. The full maidenhead is now available as soon as DGPS is detected. 
1.0.0.10 29/05/19 Input coding changed so that CR or CRLF sequences are completely ignored and should allow operation with more GPS device streams. Readability of the /LOG data file is reduced but software operation is better.
1.0.0.12 30/5/19 The date formatting routines have now been revised and should now show as a date based on your Region settings in Windows.  There are two more logging options /IO and /SERIO which both produce data files based on the I/O data - these are to assist me find why the software is not working for YOU.
1.0.0.13 13/6/19 The IO routine stream handling has been rewritten to solve issues with GPS units and USB/serial adapters that chop the GPS data stream into small pieces, even as small as 1 character bytes. The floating point error being seen by users in some European countries was traced to their using a comma (,) as a decimal point separator, as set by the Windows Region settings. This has now been resolved.
1.0.0.14 14/6/19 The "Run as Admin" warning message displays only once now. The application's size constraints are now activated meaning that it can be shifted on screen but not resized.
 
1.0.0.16 10/9/19 Some screen layout changes, more coding changes inside the application. One important change is that any advance or retard of computer time is done automatically as the up/down Seconds Adjust (RHS) is changed - there is no need to manually set the time with each change. The Reset (or Zero) button has been added as a quick way of clearing any time offsets you may have made.  Typical offset errors noted are in the order of 80mS to 150mS with baud rate of 115200 baud. 
Still 1.0.0.16... 16/9/19  Fixed NONE error on initial startup.
1.0.0.17  2/10/19 Been working on resolving Regional settings issues/errors  and this release seems to have them solved for all Language settings tried.  Ditto the XP version, same issues but different code, hopefully now fixed.
1.0.0.18 13/10/19  Changes added to provide automatic clock update 10 seconds after the GPS time and date are decoded, only after an initial program startup. Manual button operation is not now required to make the initial clock update code operate.
 
1.0.01.9 22Oct19  Improvements have reduced the timing inaccuracy as from this release. The variation is now in the order of +70 to 90mS at 115KB and +90 to100mS at 4800 baud (referenced by NTPMonitor), all due to a revision of checking which string set comes first - the GGA or RMC - and using only the first to arrive to read the time from. The processing of the GPS data was changed to make things happen quicker too. A number of other changes including re-evaluating available serial ports when the down arrow on the COM port selection box is activated, clearing some old values when the Run GPS button is pressed, the automatic updating of time at 5, 10 and 15 seconds after that same button is pressed etc.. Lots of small changes to improve the operation.  The WSJT-X software now shows DT (delta time) variations averaging -0.1 to 0.0 to (+)0.1 seconds most of the time for reasonably accurately-timed stations..
 
1.0.0.22 3Dec19 Now handles $GN formats as well as $GP data from GPS receivers..
1.0.0.23 7Dec19 V22 but with some unwanted debug code removed (oversight !!!). Added an Rxd (received data) status indicator. If it does not flash = no GPS data being detected.
 
 
 
 
VK4ADC