Do you know what time it is?

 
For the non-native English speakers: what time it is
I’m thinking about writing an Android app that requires several devices to do something at the same time. They need to be coordinated to within about 1/50 of a second. It’s not important that they do this thing at a particular time. It only matters that whatever time they do, it is the same for all of them.
Here are some of the devices I have laying around the house.
  • Two old Motorola XPRTs (never liked em).
  • A Barnes and Noble Nook HD.
  • An HP Stream 8
  • and a Galaxy S5.
In this picture, all of them are running Digital Alarm Clock. Note that they all show a different time. The devices all do “get time from network”.  Clearly not within 1/50th.
IMG_4908IMG_4863
So I tried getting the time from GPS using the app GPS Time. I don’t recommend this app. It crashes every time the phone goes to standby as well as other random time. Still, you can see the times still don’t match. (all the pics are clickable for larger versions). All of the times are different.
IMG_4909
Since the app is so unstable, I figured maybe a different app would do better. Perhaps, the inaccuracy is a problem with the app. GPS Status and Tools is much better. (it’s a very nice app; lots of features) Again, all of the times are different, though I think something wasn’t right on the S5. For a while it had trouble connecting with the satelites; that may be because the battery was low.
 
IMG_4914
So I looked around a bit more and came upon several mentions of NTP (network time protocol). Reading about it, it’s specifically intended to give accurate time to computers. The result is very close. The first attempt at photos 1 had only disagreement only in that the Nook is a bit off. When I re-took the pics, I got this one where all the times are different. 2
IMG_4916   One issue I have with using NTP is that it requires an internet connection. I’d like to be immune to that. My next idea (the one I’m likely to go with) is to connect them all through wifi and have them talk to each other. The question is whether there are any elements in the chain that slow things down 3
So I did some experiments using the simple ping command.
  • Pinging from my desktop to my router yields times < 1ms. Great!
  • Pings to my S5 gives values ranging 9ms-100ms. not so good. 9ms was an outlier. 40ms is more common.
  • Pings to Nook are consistently about 4ms. I don’t run nearly as much on the Nook as the S5.
  • On one of the XPRTS, It’s 6ms-200ms. 60ms seems common.
  • The stream 8 usually pings in 3ms.
hmm. not so promising but perhaps an app can mitigate this. ping is likely not the highest priority thing running. According to this article, 1ms is achievable on Java, but it remains to be seen whether it translates to Android’s Java.
That’s as far as I’ve gotten.
What’s the rest of the app going to do? It has to do with SMPTE Timecode. I want to try shooting some multi-angle video; more than one camera at a time and perhaps separate audio. SMPTE Timecode is what the real studios use. It’s a digital encoding of the current time that’s transmitted to each recording device as an audio track. Video editors like Final Cut or Premiere then can automagically align the footage on the timeline using the recorded timecode signal. The problem is that equipment to do this is expensive. Android devices can be found for cheap. Who among us doesn’t have an old phone or two, just sitting in a drawer? There’s is already a timecode app, but it doesn’t include sync between devices. You’d need to distribute the signal from it to each recorder via some sort of transmitter (something you probably don’t have lying around).
Timecode is at a granularity of 30 frames per second (or whatever the video framerate is). Hence the requirement to be within ~1/50th of a second to give a bit of margin.
Kudus, if you’re a less technical reader and you’ve made it to the end.
 
 
Do you know what time it is?

  1. taking photos of especially the stream 8 was pretty difficult. The reflections were hard to avoid. The ones I’m posting were mid evening.

  2. At this point I’m only scoping the problem. I haven’t written any code yet. I haven’t even written an Android app yet, but this is the project I want to use to learn.

  3. my assumption is that if I have high latencies, this will limit accuracy. I also assume that accuracy will be no worse than the latency. So if the app keeps trying until it gets one with good turnaround time, it’d just use that.

Leave a Reply

Your email address will not be published. Required fields are marked *