<1us accurate timestamps for trigger signal

I need to create a trigger signal represented by a square wave of 1 Hz up to 1kHz and get UTC timestamps for each rising edge. The timestamps need to be accurate below 1 us.

For this I have a GPS module that outputs a PPS (pulse per second) signal and gives me the corresponding timestamp. This allows synchronisation with an accuracy on the level of a couple dozens ns.

I plan to input capture the PPS signal and have the same timer create a square wave on a different pin.

I tried to do this with an Arduino Zero but the significant jitter of its crystal resulted in deviations of about 20 us between PPS signals.

Is my approach in principal correct? Is there a better way? If not, can you recommend hardware with a more accurate oscillator with which I can meet my accuracy requirements?

That sounds odd. Deviations of a crystal will generally be around 20-30ppm and they won't manifest as jitter, but as variations between individual crystals and drift due to e.g. temperature. Either way, it sounds implausible to me that this would cause 20us delays. Something else is going on; is it possible you're looking at interrupts occurring that delay the execution of your code? Maybe it would help if you posted a minimal implementation that reproduces the problem.

  • This sounds very weird, why ?
1 Like

I originally posted in "Programming Questions": Arduino Zero pulse width measurement inaccurate

In this post there is my code and a sample of the output.

The only interrupts I am using are for the pulse interval and duration.

You're using Serial, so USART interrupts will be occurring from time to time. Also, I'm pretty sure the millis() Timer is also running by default, even if you never call millis() in your sketch. This also generates interrupts. You may have to do another round of digging in the ATSAM datasheet to see how the NVIC prioritizes these (and possible other) interrupts, and you may even have to dig into the Zero Arduino core to see what else may be going on.

Frankly, in a case where you need real-time accuracy, I'd personally start with a little test that doesn't involve any of the Arduino code at all (so use Microchip Studio etc.) so that you're in full control/knowledge of what does and doesn't happen in your uC core.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.