I need to develop a system where there are 4 sensor boxes powered by USB and they have their internal clock. Each of these boxes are connected to a Linux pc and all these PCs are linked with WiFi. API of the sensor box allows me to read their internal precision clock (uSec accuracy).

I like to synchronize all four clocks of the sensor boxes as close as possible. Hopefully within a few micro seconds of each other and compensate for drift over time. The idea is to use the sensor data that is collected at the same time (The data I receive is time stamped with the boxes' internal clock). The latency on usb bus, WiFi, pc timing are all indeterministic.

Is this possible given my setup?

  • \$\begingroup\$ allows me to read their clock ... which clock are you referring to? ... PCs are linked with WiFi ... are PCs in same room, city,state,country,continent? \$\endgroup\$
    – jsotola
    Jan 21 '18 at 1:41
  • 1
    \$\begingroup\$ IEEE-1588 precision time protocol may be able to come close, well, depending. For better synchronization, look at White Rabbit (developed for CERN, IIRC). The latter uses an FPGA at each node. \$\endgroup\$ Jan 21 '18 at 1:46
  • 1
    \$\begingroup\$ Microseconds over wifi is probably impossible. The delay could change if other wifi equipments try to use the the same channel. Somebody turning on wifi on their phone could change the latency on other networks in the same room. Can you tell us more about the sensors? You could generate a common event at regular interval and use it to synchronize them. \$\endgroup\$
    – pserra
    Jan 21 '18 at 2:04
  • 1
    \$\begingroup\$ network time protocol will keep individual computers reasonably synced up. Not sure about a few us, though. \$\endgroup\$
    – mkeith
    Jan 21 '18 at 3:22
  • \$\begingroup\$ @jsotola I updated the question for clarity. \$\endgroup\$
    – Ktc
    Jan 21 '18 at 4:37

Your best bet is probably not to try to synchronize the sensors, but instead accept that they are only approximately synchronized and look a sensor data when multiple sensors witness the same event to determine the relative skew of the clocks.

Perhaps you can provoke some events to calibrate this.

  • \$\begingroup\$ This is outside the box thinking. \$\endgroup\$
    – Ktc
    Jan 21 '18 at 11:20

The most direct way to get that level of synchronization would be to put a GPS receiver on each node. This gives you an absolute time reference within about ±50 ns at each node, giving you a difference of up to ±100 ns between nodes.

PTP can approach that level of accuracy over a wired network (using extra hardware to accurately timestamp packet arrivals), but I don't think it can do anywhere near that well wirelessly.

However, on rereading your question, you don't seem to be talking about synchronization among the PCs, only about synchronization among the sensor boxes attached via USB to a single PC. I take it that you don't have any control over the design of the sensor boxes themselves; otherwise, you could simply use the recovered USB clock as your timbase, since this is synchronized to a single oscillator in the host PC. Can you describe your constraints in more detail?

  • \$\begingroup\$ GPS is not practical for this application due to indoor etc. The Sensor boxes I purchase and I have no control. \$\endgroup\$
    – Ktc
    Jan 21 '18 at 4:38
  • 2
    \$\begingroup\$ If the only observable in your system is the unsynchronized timestamps that the sensor boxes put on their measurements, and those measurements are transmitted over a USB link that you have no direct control over, then the best you are going to be able to do is going to be on the order of milliseconds, not microseconds -- even if the PCs are sync'd with PTP. You have to face the fact that maybe these particular sensors are not adequate for your application. Since you're telling us nothing at all about these sensors or your actual application, there really isn't any way for us to help you. \$\endgroup\$
    – Dave Tweed
    Jan 21 '18 at 5:16
  • \$\begingroup\$ sensors read a 32 bit value and they attach a 32 bit time stamp for this value. They do this at 1KHz frequency. But you are right too many unknowns and precision control doesn't seem to be practical. \$\endgroup\$
    – Ktc
    Jan 21 '18 at 5:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.