3
\$\begingroup\$

first time on stackexchange, hope I'm in the right place. I am working on a project where I need to timestamp an event (which will be detected from an electrical pulse) down to a few tens of nanoseconds and synchronized with GPS (because there will be a couple of those modules that need to be synced together). I looked for a simple arduino/raspberry solution but it seems it won't do better than 1-2 us, far from ~30 ns.

I was thinking of using the 1PPS output (1Hz) of the GPS to get a very accurate time and then find the time interval between this pulse and the sensor's pulse by counting cycles of an external, high precision clock. I have found a clock which will get me under 30ns innacuracy over the 1s PPS(40MHz, 10ppb, 1ps jitter).

Now, the problem is how do I go about counting these clock cycles? My experience on the subject is very close to 0 and so is my teammate's. Any help is very much appreciated.

EDIT: It seems this is very complicated for someone who's only experience with microcontroller is sending data through serial. The perfect product for my application would be something like this: http://www.ti.com/product/TDC7201/description Just connect the two pulses to START and STOP pins and it returns the time interval. The only difference is I would need a 1s measurement (vs 8ms) but with 10-50ns precision (vs 50ps). Basically 1000x longer measurement with 1000x less precision.

\$\endgroup\$
  • \$\begingroup\$ An ATmega328 (the microcontroller in an arduino uno) can time events down to 62.5 ns resolution, not "1 or 2 microseconds". \$\endgroup\$ – jms Oct 16 '16 at 19:39
  • \$\begingroup\$ I think what you want to do is run your processor from the 40 MHz clock, and use an internal timer to measure the interval. The 1PPS signal may not be accurate when the GPS is not synced to satellites. Also, the 1pps signal may have a slow rise or fall time, and this could introduce some timing uncertainty if your switching voltage threshold is not very stable. If I remember correctly, the 1pps is stable in the long term, but may have cycle-to-cycle jitter. So the ideal solution might be some kind of digital PLL. \$\endgroup\$ – mkeith Oct 16 '16 at 19:40
  • \$\begingroup\$ The GPS does have jitter (11 ns for the one I have in mind). The GPS is a must since we need 5 synced modules separated by about 10km. Can you elaborate on "run your processor from the 40 MHz clock, and use an internal timer to measure the interval"? I have read about the 62.5 ns resolution of ATmega by counting cpu cycles but I haven't managed to find how to count it. Even then, the onboard clock doesn't have the required precision (will lose/advance much more than 30ns over 1s). \$\endgroup\$ – user126881 Oct 16 '16 at 19:48
  • \$\begingroup\$ @jms, OP means 30ns absolute error over 1 s time interval. The junky arduino clock is likely 50ppm, which will give you 50us error. \$\endgroup\$ – Ale..chenski Oct 16 '16 at 19:49
  • 1
    \$\begingroup\$ @tomnexus I contacted u-blox today and everyone of their module can do it, even if it is not always mentionned as a feature. For people who might wonder, u-blox modules can timemark an event once every epoch, so once per second for a 1Hz update rate. If two events happen in an epoch, only the last will be timemarked. \$\endgroup\$ – user126881 Oct 17 '16 at 20:45
1
\$\begingroup\$

Counting cycles between PPS pulses is not a good approach. Even using clocks with 10ppb stability, you still need to evaluate the skew between different units.

Using an integrated GPS Receiver with timestamping is a good approach. Note however that it will not be easy to get these 30ns RMS accuracy in real life conditions. 30ns translate to only 9m position accuracy. While most receivers reach this easily for kalman filtered position, you will see more disturbance to your timestamps (where the receiver cannot employ a hidden markov model) unless you also average over multiple events.

Multipath reception is your main adversary (for units some tens of km apart and events within fractions of a second). Multipath will be mitigated somehow by the receiver, but the best thing you can do is use a good antenna (choke ring or similar) and choose a good place. Putting it on a tripod can also help.

Group delay calibration will typically not be needed for 30ns if all your modules use a similar Setup (antenna cable length matters, also amplifiers or similar).

Far better accuracy can be reached if you are able to measure the event in band with the GPS Signals, that means trough the RF frontend of the reveiver. This will relate the timing directly to the received signals and offers the opportunity to cancel off several error sources. If you do not need the result in near real time, you may record GPS signals together with your trigger and postprocess them. This will give high accurary of relative position and time (differential GPS).

\$\endgroup\$
0
\$\begingroup\$

I'm not familiar with the Arduino Uno, but it probably has a counter module that can time intervals. But it will be limited to the clock frequency, which is probably too low for what you want. You'd better switch to an Arduino Due, it surely has this capability and can run at 96 MHz. Study the counter/timer peripheral (datasheet). Use it to capture

  • the interval between the 1s pulses
  • the interval between the last 1s pulse and the event

From these figures you can calculate the accurate interval between the last pulse and the event.

Note that programming the peripheral is not easy. And if your experience in micro-controller programing is zero, you'll first have to get it to a reasonable level. That is not something you learn in a week. If you have basic programming skills and a good instructor a month might be a good guess. And understanding the timer comes after that..

\$\endgroup\$
0
\$\begingroup\$

I worked with an R&D co. that once had a network with similar requirements for synchronous TDM on a shared network. The upstream Multiplexor measured the phase error of a narrow pulse from each "sender" so that not only could the downstream targets be phase locked to the shared bit stream in their own time slot, but phase synchronized due to "Line buildout" or latency or any other phase error. The repeater then sent phase correction commands to each sender when needed to ensure the central point received all in perfect sync.

In order to accomplish anything like this your phase error detector must have greater resolution than the error required and the drift over time of any unsynchronized sender must translate into a time interval that can be corrected within the phase detector span of +/- xx ns. Using ULF/VLF phase detection such as gives greater phase span but when multiplied up to resolution of frequency that gives phase sync in the 10ns region requires either a very stable low phase noise clock or high channel bandwidth.

WWVB is very stable <1e-12 in f but inadequate bandwidth to correct better than a few ms due to 60kHz carrier with a few kHz Bw. Translate this up to ns and your network bandwidth to correct phase errors must be 1e6 higher in frequency.

Start with accurate specs on requirements for each location and determine your phase accuracy that you can achieve in detecting phase error in ns. I doubt any Arduino can resolve this without specialized interface hardware to measure phase error in nanoseconds.

I have designed many different Doppler instruments from VLF to UHF so I am just dealing in generalities here.

\$\endgroup\$
  • \$\begingroup\$ I agree nanonseconds would be out of the question (that would require a ~ 1 GHz clock), but a 96 MHz Due should be able to reach 10's of nanoseconds. \$\endgroup\$ – Wouter van Ooijen Oct 16 '16 at 20:42
  • \$\begingroup\$ I think a 500MHz Cortex might be better suited. \$\endgroup\$ – Sunnyskyguy EE75 Oct 16 '16 at 20:44
  • \$\begingroup\$ Maybe easier, but it might be overkill, and not as easily available. (The Due has a Cortex-M3). \$\endgroup\$ – Wouter van Ooijen Oct 16 '16 at 21:40

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.