Go Down

Topic: Measuring nanoseconds  (Read 690 times) previous topic - next topic


Does anyone know of any arduino attachments
that can keep track of the amount of nanoseconds that have passed? I know that
there is the Millis() and Micros() function but I would like to have the functionality of a Nanos() function.



"I've gone off the idea of progress. It's overrated."
Arthur Dent


Multiply micros() by 62.5
That is weird math !!

If the OP wants to measure nanoseconds, I guess that's because he needs a precision of a few nanoseconds.

With AVR arduinos  clocked at 16MHz, you can't expect this precision. With an arduino DUE clocked at 84 MHz, the best you can expect is a 12 ns precision. Therefore the question is : what sort of nanoseconds precision are you looking for ?


I need to go as precise as 1 nanosecond. I know the arduino can't do it on its own, but do you know of any realtime clocks or anything that I can connect to it? I've looked but no luck.


Think a little about your problem.
A 16 MHz Arduino executes its fastest instructions in 62.5 ns.
The fastest it can respond to any external stimulus is therefore at least 62.5 ns.

If you need to record shorter times, you'll be looking at external hardware.

A better description of your problem might elicit better answers.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


May 08, 2018, 02:21 am Last Edit: May 08, 2018, 04:52 am by Jimanator
So, basically I am trying to get the difference in time received  between 2 rf pulses from the same source. All I need is a timestamp from each in nanoseconds to be passed to the arduino. The arduino will do the math for the 2 timestamps to get the difference, that part is fine if it is slower. I did the math and as long as the receiver is more than 0.26 meters from the transmitter it  won't be quicker than a nanosecond, so I don't need to worry about picoseconds.

What sort of external hardware do you mean?


May 08, 2018, 04:45 am Last Edit: May 08, 2018, 04:47 am by jremington
To get 1 ns time resolution, you will need some pretty high end hardware for the "front end".

A programmable gate array with a clock rate of 10 GHz or higher should be serviceable.


I did the math and as long as the receiver is more than 0.26 meters from the transmitter it  won't be quicker than a nanosecond, so I don't need to worry about picoseconds.
Surely it's the difference in distance of the two receivers that counts not the distance from the transmitter. If the difference is always considerably greater than 0.3m then you don't need better than nanosecond resolution otherwise...



This is not a Arduino solvable problem.

No technical PMs.
The last thing you did is where you should start looking.


Thanks for all the info. I just don't understand why if a 16 MHz clock can do 62.5 ns, why do I need to jump all the way to 10 GHz to get 1 ns?


May 09, 2018, 12:17 am Last Edit: May 09, 2018, 12:22 am by jremington
Assuming a gate array or computer takes, say 10 processor cycles to recognize and store event times to a resolution of 1 nanosecond (1 GHz rate), then the processor clock must be at least 10 times faster.

The Arduino doesn't "do" 62.5 nanoseconds. That simply the time for one cycle of the processor clock. See above.


You can measure ~nanoseconds with arduino.
You would need an additional piece of hardware, a pulse_width ->voltage converter.


Sometimes phase differences are easier to measure than time differences. Perhaps a phase detector
could be part of the mix - but we need to know much more about the problem.  For instance 2 isolated
RF pulses have very poor temporal resolution if the bandwidth is low or the signal/noise ratio is poor.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up