androidtimesmartphonentpclock-synchronization

Synchronizing time between smartphone and pc/embedded device


I have to measure and verify the latency of messages being sent wirelessly via WiFi/Bluetooth from smartphone to pc. The distance varies between 5 and 10 meters.

Example: message sent from smartphone at time X, received and processed at time Y. Duration: 35ms.

Since these messages are non-trivial (safety and security commands to further machines) its neccesary to synchronize the time between the smartphone and the pc to the most precise accuracy(milliseconds).

This was an easy task using net time for two PCs connected via LAN, but I'm uncertain with smartphones using iOS/Android..

Is it accurately enough to lets say sync both, smartphone and PC with NTP time, or do you know a better way to synchronize time between them?

From what I read, synchronizing time with NTP provides accuracy from ~ 1 to 20 ms. But this range is too vague..

Does anyone had similar problems?


Solution

  • Must this all be handled over the network or have you considered a physical timing trigger between the two?

    If they are located near each other, I would recommend using a O-Scope. Sending a timing pulse from the phone's headset saying the message was sent. Then a Pulse from the PC that it was received and processed, via serial port or such.

    If you use this route, you would want to take into account the latency between when the SW sends the command and when the pulse is sent out the hardware. I would do this using a tight loop that just toggles the signal, then see what the frequency is. Your latency for each would be half the period. And your total latency would be the difference between the PC and Phone's latency (which could be positive or negative).