It will depend on the clock rate of the board you use. A 16MHz clock will let the hardware quantize pulse widths of 0.0625us. Read their datasheets and find out what their timers can do for you. You don't want to measure this in software. The $4USB Raspberry Pi Pico has a 125MHz clock, and could get you 8ns resolution.

Answer from aMike on Stack Overflow
🌐
Arduino Forum
forum.arduino.cc › other hardware › science and measurement
Measuring nanoseconds - Science and Measurement - Arduino Forum
May 7, 2018 - 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 Nan…
Discussions

Return time in Nanoseconds
Hi, My project is range finding by calculating time difference between transmission and recieving at light speed. I understand the resolution won't be great with most boards at 16mhz and ESP at 160mhz. In C++ there is a library chrono that gives time in nanoseconds. Will it work in Arduino? If not ... More on forum.arduino.cc
🌐 forum.arduino.cc
19
0
November 16, 2021
Nanosecond time measurement with Arduino due
Hello, I'm new to Arduino due. For my project I need to measure time in nanosecond fineness. (Like measuring the travel time of radio waves in air). If I go into a little detail, I have boards such as Raspberry Pi 3 B+, Arduino DUE, Esp32. In the tests I made at home, DUE gave an accuracy of ... More on forum.arduino.cc
🌐 forum.arduino.cc
19
0
April 3, 2022
Are we able to get nanosecond function or handle under nanoseconds in Arduino Due
I want to use Arduino Due to achieve more accurate timing, specifically in the range of 50 to 500 nanoseconds. I tried using the micros() function, but it can only handle intervals of 3 microseconds, and I'm getting very unstable values in my digital signal outputs. More on forum.arduino.cc
🌐 forum.arduino.cc
19
0
December 5, 2023
Any cheap way to measure times down to nanosecond accuracy?
LDRs are way too slow for this, their response rate is in the milliseconds . Here's a youtuber who made his own measurement if you want some ideas More on reddit.com
🌐 r/arduino
11
7
November 19, 2021
Top answer
1 of 1
1

Yes, it should be. At least according to the Cortex M3 Technical Reference Manual that I think I downloaded from ARM. (DDI0337E_cortex_m3_r1p1_trm.pdf)

In section 11.5 of said manual, there is a register called DWT_CYCCNT (Data Watchpoint and Trace Cycle Count Register) which is incremented once per clock cycle when the appropriate flag of the DTW_CTRL (DWT Control) register is set.

This flag is unset on reset of the CPU so it needs to be set manually (unless it is done by the Arduino IDE, but checking the header files of the IDE, it doesn't look like it as unlike many other CPU registers, there is no Arduino REG_ define for these registers).

This untested code should be usable as the basis for your own code. I suggest you add some serial initialisation in there and dump the value of currentCycles to the serial log to test it. I am away from my hardware at the moment so can only test that it compiles.

#define REG_DWT_CTRL (*(unsigned int*)0xE0001000U)      /* Data Watchpoint and Trace Control Register */
#define REG_DWT_CYCCNT (*(unsigned int*)0xE0001004U)    /* Data Watchpoint and Trace Cycle Count Register */

#define CYCCNTENA ( 1 << 0 )                            /* DWT CTRL Cycle Count Enable Bit */

void setup()
{
    REG_DWT_CTRL |= CYCCNTENA;
}

void loop()
{
    unsigned int currentCycles = REG_DWT_CYCCNT;
}

Edit: Note that the counter is a 32 bit register, so at 84 MHz it will reset every 51.13 seconds. It is a read only register so writing to it will have no effect (you cannot manually reset it that way).

🌐
Arduino Forum
forum.arduino.cc › projects › general guidance
Return time in Nanoseconds - General Guidance - Arduino Forum
November 16, 2021 - Hi, My project is range finding by calculating time difference between transmission and recieving at light speed. I understand the resolution won't be great with most boards at 16mhz and ESP at 160mhz. In C++ there is a library chrono that gives time in nanoseconds. Will it work in Arduino? If not ...
🌐
Instructables
instructables.com › circuits › arduino
6.25 Nanosecond Resolution Timer for Any Microcontroller! - Instructables
September 27, 2017 - 6.25 Nanosecond Resolution Timer for Any Microcontroller!: While designing a solid state replacement for a vacuum-tubes-and-CRT radar display subsystem, I was stuck at getting a suitable system to time the period between the synch pulse and ...
🌐
GitHub
github.com › earlephilhower › arduino-pico › discussions › 650
Nanosecond resolution with the Pico · earlephilhower/arduino-pico · Discussion #650
Theoretically the Pico's 133(+) MHz should give us about 8 ns of time resolution. With some computational overhead what could the limit to this resolution be in practice? Are <100ns reasonable?
Author   earlephilhower
🌐
Arduino Forum
forum.arduino.cc › projects › programming
Are we able to get nanosecond function or handle under nanoseconds in Arduino Due - Programming - Arduino Forum
December 5, 2023 - I want to use Arduino Due to achieve more accurate timing, specifically in the range of 50 to 500 nanoseconds. I tried using the micros() function, but it can only handle intervals of 3 microseconds, and I'm getting very unstable values in my ...
Find elsewhere
🌐
Reddit
reddit.com › r/arduino › any cheap way to measure times down to nanosecond accuracy?
Any cheap way to measure times down to nanosecond accuracy? : r/arduino
November 19, 2021 - There are even components measure distance based on TOF measurements: https://www.st.com/en/imaging-and-photonics-solutions/vl53l0x.html, the VL523x is available as developer board and a lot of Arduino examples are out there. Some of those can measure distance up to 800cm and there are even libraries: https://github.com/pololu/vl53l1x-arduino.
🌐
Arduino Forum
forum.arduino.cc › forum 2005-2010 (read only) › hardware › troubleshooting
Delay in nanoseconds - Troubleshooting - Arduino Forum
June 29, 2010 - Hello everyone: I have a problem and need to generate a delay of 12.5 microseconds, but I have not found a way to do it. DelayMicroseconds function, type only accepts integer numbers, so I can only mean a delay of 12 m…
🌐
Arduino Forum
forum.arduino.cc › projects › general guidance
Timing 2 pulses in nano seconds? - General Guidance - Arduino Forum
November 20, 2021 - I am in the middle of a project for school and need to measure the time difference in between 2 pulses that are being fed in via interrupt pins. The 2 pulses are slightly out of phase and coming of a Hall effect or opti…
Top answer
1 of 3
5

The smallest time interval you can measure using the Arduino Due's built-in hardware is roughly 23.8 nanoseconds.

The smallest time interval you can measure using the Arduino Uno's built-in hardware is roughly 62.5 nanoseconds.

Arduino Due timers

The Arduino Due uses an Atmel SAM3X8E microprocessor. It has 3 identical Timer-Counter peripherals, each of which has 3 independent timer channels. On the Due, these are the best way to measure small amounts of time if you want resolution in nanoseconds. Each Timer-Counter can use different clock sources as input - these determine the increments of time the Timer-Counter can measure. The fastest clock source is MCK/2, the master (system) clock divided by 2.

On the Arduino Due, MCK is 84MHz.

This means that the smallest interval of time the Timer-Counter can measure is 2 / 84,000,000, or about 23.8 ns.

You can read more about the SAM3X8E Timer-Counters in the SAM3X8E reference manual, section 37, page 868.

Here's an Open Source library that provides a nice API to the Arduino Due's Timer-Counters. Here's a pretty clear explanation of how the SAM3X8E timers work, an alternative to reading the SAM3X8E reference manual.

You can also write ARM assembly code to measure durations in nanoseconds, but the Timer-Counters will probably have higher resolution.

Arduino Uno timers

The Arduino Uno uses the Atmega328 microprocessor. It has two Timer/Counters which can use different clock sources as input - the fastest source is FCLK_I/O (system clock, 16MHz). This means the smallest interval it can measure is 1 / 16,000,000 seconds or 62.5 nanoseconds.

You can read more about the timers in the AVR datasheet, Section 16, page 141. Or check out this summary of how to use the AVR native timers.

2 of 3
2

Arduino Uno/Nano micros() function (4us resolution), and my replacement function with 0.5us resolution:

I can't answer the question about the precision of the core Arduino micros() function when used on a Due. However, I wanted to present my work on the Arduinos using the Atmega328 microcontroller (such as the Uno, Nano, Ethernet, etc), as it may be helpful to others too.

Here it is: "I wrote a "libary" to get 0.5us precision on a "micros()" replacement function, so that I can get repeatable results reading a PWM or PPM signal, to within 1us. I searched all around the internet and could not find something comparable (or that was easy to use, and maintained the Arduino's ability to write PWM signals via the Servo Libary), so I think this is my first real contribution to the world of Arduino and Radio Control."

The code is downloadable here: http://electricrcaircraftguy.blogspot.com/2014/02/Timer2Counter-more-precise-Arduino-micros-function.html

🌐
Reddit
reddit.com › r/arduino › how to get nano second precision
r/arduino on Reddit: How To Get Nano Second Precision
October 13, 2020 -

Hi, I'm working on my final year project which is really time sensitive. I need to be able to measure time stamps as precise as the nano second region. This is because my project is looking to track distances using RF signals. I'm using a Time of Arrival localisation scheme and so I'd need time of flight and speed of the waves.

By my calculations, to get an accuracy of around 30m I'd need time stamps as accurate as 100ns. So far I've been using micros() to get these timings but they're obviously not accurate enough.

Using an arduino uno clocked at 16MHz, id expect it be able to measure this, however I don't know how to do this.

I've made peace with the fact that I probably won't be able to get it done in time, however I am still curious if it is at all possible.

🌐
Arduino Forum
forum.arduino.cc › projects › programming
Read time differences in nanoseconds - Programming - Arduino Forum
December 7, 2011 - I then need to compare the time between the signals (ie time1 - time2 = value) Can the arduino record time in nanoseconds? Or would there be an alternative way for me to achieve the same goal? In linux basically I echo to the serial port and every time the carrier detect pin is active I record ...
🌐
Arduino Forum
forum.arduino.cc › official hardware › mega › due
nanos() [time elapsed since program start in nanoseconds]? - Due - Arduino Forum
November 27, 2013 - hi everyone! In my current application I'd like to be able to have access to timing in the 10 to 100 ns range. So I started digging around in the micros() source code and came up with the following: uint32_t nanos( void ) { uint32_t ticks ; uint32_t count ; SysTick->CTRL; do { ticks = SysTick->VAL; } while (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk); // GetTickCount() is millis() uint32_t load= (SysTick->LOAD + 1 - ticks); uint32_t milliS = GetTickCou...
🌐
Arduino Forum
forum.arduino.cc › projects › programming
how to give delay of 1 nano seconds - Programming - Arduino Forum
August 8, 2016 - Is their any operation which takes time less than nop so we can give delay of 1ns. Actually I want to use it to calculate time in pure nanoseconds required for the execution of particular process or sketch. Also I want t…
🌐
Stack Overflow
stackoverflow.com › questions › 20732460 › nanosecond-measurement-in-arduino-using-clock-gettime
c++ - nanosecond Measurement in arduino using clock_gettime - Stack Overflow
arduino · nanotime · Share · Improve this question · Follow · asked Dec 22, 2013 at 18:11 · PrinceOfEgy · 2122 silver badges55 bronze badges 7 · 1 · For reference, 84 MHz =~= 11.9 ns/cycle.
🌐
Arduino Forum
forum.arduino.cc › other hardware › leds and multiplexing
Blink with nanosecond resolution delay - LEDs and Multiplexing - Arduino Forum
October 29, 2020 - Arduino example sketch "Blink" allows you to specify "delay()" between state changes in microseconds. Using "delayMicroseconds()", that delay can be specified with microsecond resolution. I did need a multiple MHz blink, and thus a nanosecond delay between state changes (for utilization ...
🌐
Blogger
nznano.blogspot.com › 2012 › 02 › arduino-nanosecond-signal-delay.html
NZ Nano: Arduino Nanosecond Signal Delay - Blogger.com
These digital delays use oscillating clocks to do the timing but in the lab we only wanted resolution down to a nanosecond scale. For this, I used the Arduino nanosecond delay generator which is capable of delaying a signal by 4 ns to 10 ms.