Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


USB Flakey?

Posted on 2012-09-08
Medium Priority
Last Modified: 2012-09-14
I have an inexpensive GPS receiver that I am using as a local clock driver for NTPD, the Network Time Protocol (NTP) daemon, running under Windows 7 64-bit.  NTPD is also connected, thru another computer, to 9 stratum 2 NTP servers located on the East Coast, USA.  What NTPD on this computer sees is the smoothed, best reading from the  9 NTP servers, other computers on my local network, and the GPS clock.  If NTPD's output is plotted, it looks like a straight line horizontally across the page +- ~6 milliseconds (ms) around 0 offset, which is the readings from the 9 NTP servers.  Superimposed on this is a sawtooth wave +- ~60 ms, which is the GPS driver output.  The GPS output starts about 60 ms ahead of real time, slowly descends over a little over 24 hours to ~ -60 ms below real time, varies wildly between -60 ms and +60 ms around 0 offset real time for about 2 hours, and finally settles at +60 ms offset to begin the cycle again.  You can see a plot of this data here (https://skydrive.live.com/redir?resid=92A71A1C4B64FD41!271&authkey=!ABrUBy4aS7e7sME).  This sawtooth pattern continues forever, unless the computer is rebooted, in which case the GPS output restarts at +60 ms offset ahead of real time and continues its descent to -60 ms below 0 offset.  The GPS output is once every 16 seconds; i.e., 1/16 Hz.  The GPS unit sends its signal as a standard NMEA RMC ASCII string via USB to a Prolific USB-to-Serial (RS232) bridge.  The NTPD clock driver -> WAITS <- for the signal (actually the CR/LF pair at the end) at the Windows serial API and records the exact system time received.  In other words, the GPS output appears to be actually being received at the offsets shown in the plot, i.e., in a sawtooth pattern.  The question is, what is the source of the varying GPS signal received times, the USB driver or the GPS clock device?  A trace of the USB output looks like the GPS string is actually being received a few ms later every 16 seconds, but according to the USB specs, that is not possible.  USB in interrupt mode is supposed to be polling the device at exactly the same time every cycle.  The fact that a computer reboot restarts the sawtooth pattern at its apogee, and that a reboot (probably) does not affect the GPS device, seems to point to USB as the culprit.  However, a good GPS NTP clock can cost $1,000 or more; the one I have cost $35.  Does anyone know if USB does schedule its polling in interrupt mode a few ms later every scheduling interval, and then later tries to rectify its error?  Does anyone know how to fix this error, or even approach debugging it?
Question by:CElliott2
  • 2
  • 2
LVL 84

Accepted Solution

Dave Baldwin earned 1500 total points
ID: 38379759
In another recent question, the asker had to abandon use of a USB-to-Serial (RS232) bridge because he could not get the timing to be predictable.  USB is a packet/network protocol and RS232 is a character protocol.  The USB controller will collect some data, create a packet and send it.  At the receiving end, the data will be sent out the RS232 port presumably without delay.  A lot of people have had trouble with USB-to-Serial (RS232) adapters because they expect the timing to match that of a regular serial port and it doesn't.

Author Comment

ID: 38382560
Thanks for your comments.

"The USB controller will collect some data, create a packet and send it."

This is not what is occurring.  The USB device is sending the data at sub-millisecond intervals in packets of 1, or at very most, 2, bytes per packet.  An NMEA RMC ASCII string is, on average, 72 bytes long.  One would think that the GPS device would send the whole string in one packet, but the USB trace I have inidcates only 1 or occasionally 2 bytes are arriving per host polling request.

That being said, I agree that the problem is probably the USB-to-serial bridge, but writing one's own driver is a lot of learning and work to undertake just on speculaton and guess work.
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38383886
Why are you using a USB-to-serial bridge?  Is it the GPS unit that has a serial port on it?  If so, have you tried connecting to it thru a real serial port?

Writing a USB driver virtually requires the cooperation of the chip manufacturer.  The people who have asked about it here have usually found other ways to achieve their objectives because they couldn't find enough info to do it.

Author Comment

ID: 38400705
"If so, have you tried connecting to it thru a real serial port?"

Very few new mobos have RS232 ports.  But, yes, I have with an old model GPS device; the drift (sawtooth wave) was not there, but the jitter was about +- 20 ms.

What I am looking for is a device for less than about $40 that someone can just buy, install the driver, plug in, install NTPD, and have accurate time +- about 10 ms.  The people on the NTP questions mailing list (who are all about time to the nanosecond all the time) would not be content with this, but most mortals and many companies would.  This would not be good enough for the ISPs, backbone networks, and power companies, but neither is NTPD, to hear many people tell it (because of inherent jitter in interrupt response times, etc.).

Your idea is a good one though, and I will look into it.  Thanks for all your help.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dropbox has a relatively new feature called Smart Sync.  This feature allows Dropbox Professional (not plus) and Dropbox Business (if enabled) users to store information in Dropbox WITHOUT storing any files on their computer.
Most folks would know the basics of how Dropbox works, so that’s not the purpose of this article. Security is what it’s all about, so here I’ll share how I choose to secure my Dropbox Account and the Data it contains.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question