16 MHz Timer using arduino

Arduino Newbie here,
I am currently doing a project that requires fast timing, a resolution of 62.5 nanoseconds seems to be good enough for now. For this I would need a 16 MHz timer. I have the Arduino uno and a few extra 16 MHz Crystal oscillators but I can’t seem to find a way to achieve this using the Arduino, do I need extra components or is it possible with just the Arduino and some extra 16MHz Crystals. If I need extra components I would appreciate guidance on what I need to use or do.
I have done some research on the forum but all I can find seems to be relevant to real time clocks and lower frequencies, rather than just a high frequency timer,
Thanks a lot and sorry for any inconvenience.

Tell what the project is. Your question makes no sense.

The input capture function of Timer1 can be used to time events with the 16 MHz clock.

See this tutorial and scroll down to "Timing an interval using the input capture unit".

By "capturing" the 1 PPS output of a GPS module, you can measure the actual clock frequency of the Arduino to a few nanoseconds resolution.

Thanks, I will try this soon and see what results I get.

jremington:
The input capture function of Timer1 can be used to time events with the 16 MHz clock.

See this tutorial and scroll down to "Timing an interval using the input capture unit".

By "capturing" the 1 PPS output of a GPS module, you can measure the actual clock frequency of the Arduino to a few nanoseconds resolution.

I have had a look at this, it looks like it should work, but do I need to wire up extra components. I presume so because currently I am getting no output. If so please explain as I am new to arduino. Thanks

"No output" from what? If you have questions about code, post the code using code tags and explain the problem.

Posting hints in "How to get the best out of the forum".

I’m pretty sure I’ve misunderstood something somewhere. I was trying to just test the code shown on the tutorial but I think I need to wire some external components to the Arduino to make the code on the tutorial work. Am I right? Otherwise how do I test this code to see it in action.

I'm pretty sure I've misunderstood something somewhere. I was trying to just test the code shown on the tutorial but I think I need to wire some external components to the Arduino to make the code on the tutorial work. Am I right? Otherwise how do I test this code to see it in action.

Yes, you need to provide input pulses to pin 8. The specific code referenced with Reply #12 "Timing an interval using the input capture unit" will measure the time between two rising edges to a resolution of 62.5 nanoseconds.

What signals/events are you actually trying to time with your program?

The input signal to pin 8 needs to be digital, 0 to 5V and the source must have ground in common with the Arduino.

Ahh so I have to provide the starting/stoping pulse through pin 8. Correct?

To answer your question @cattledog:

Basically I’m trying to time the speed it takes for radio signal to travel a certain distance to create a TOF rangefinder. Although 16 MHz won’t be fast enough for now it is the fastest clock I currently have access to (once I get a relatively good prototype of my project I might get a better one). I am also hoping to try and improve accuracy by sending the signal back and forward several times and finding the average (I will account for delay).

Pin 8 of the input capture unit latches and stores the current count in the TCNT1 register, so to time events, you need to capture two successive pulses and calculate the difference.

In 62.5 nanoseconds (the time between ticks of a 16 MHz clock), radio waves travel about 20 meters. How do you plan to emit and detect the radio signals?

You want to use a Arduino Uno to time the speed of radio waves traveling at or near the speed of light?
Your thing is to make a radio wave based TOF thingy.

What RF frequency will you be using?

I expect you'll want a something in the EHF or '?' range for directionality. Perhaps transmitting in the 700 nanometers (frequency 430 THz), to 1 millimeter (300 GHz) range to compete with LIDAR TOF devices?

Or will you be using lower frequency transmissions and using a scheme like LORAN-C or OMEGA with LOP (lines of position) to determine 3D position in relation to the transmitters?

Or will you be generating a nice strong pulse of RF, that will reflect off an object and returns to the transmitter for processing?

jremington:
Pin 8 of the input capture unit latches and stores the current count in the TCNT1 register, so to time events, you need to capture two successive pulses and calculate the difference.

In 62.5 nanoseconds (the time between ticks of a 16 MHz clock), radio waves travel about 20 meters. How do you plan to emit and detect the radio signals?

Yes, 18.75ish meters. This is quite a lot but I’m hoping to get a better faster oscillator (e.g. 100MHz). And also a ping pong method.
Ping pong method works like below:

Basically if taking (for example) a measurement of 8.3cm you would send it back and forth a number of times (say 1000). This would make it 83 meters. Then with a resolution 18.75 meters you would get 75. Divide this by 1000 and you get 7.5cm, only about a cm off.
And I am aware I will still get more interference/delay because I am sending it so many times, but am hoping the bad is outweighed by the good.

To answer your second question with apc220 radio transceivers. I already have a working code that sends a signal back and forth between the two receiver/transmitters.

Idahowalker:
You want to use a Arduino Uno to time the speed of radio waves traveling at or near the speed of light?
Your thing is to make a radio wave based TOF thingy.

What RF frequency will you be using?

I expect you'll want a something in the EHF or '?' range for directionality. Perhaps transmitting in the 700 nanometers (frequency 430 THz), to 1 millimeter (300 GHz) range to compete with LIDAR TOF devices?

Or will you be using lower frequency transmissions and using a scheme like LORAN-C or OMEGA with LOP (lines of position) to determine 3D position in relation to the transmitters?

Or will you be generating a nice strong pulse of RF, that will reflect off an object and returns to the transmitter for processing?

Yes, I am currently just using the common 430MHz radio with a device at the other end to return the signal and provide directionality. Apc220s are what I am using for the radio transmitting/receiving

Great learning project!

Thanks, it’s for a school Design and tech project

electronicdtcreator:
Ping pong method works like below:

Basically if taking (for example) a measurement of 8.3cm you would send it back and forth a number of times (say 1000). This would make it 83 meters. Then with a resolution 18.75 meters you would get 75. Divide this by 1000 and you get 7.5cm, only about a cm off.

I'm not clear on how you intend to send the signal "back and forth a number of times".

One interpretation is reflecting the signal ala a radar system, but it's not apparent how one would count the number of "bounces" and signal losses would be very high.

A second interpretation is that the signal is sent back and forth with the radios operating a repeater of some sort, that is receiving the signal and then resending it. In this case any uncompensated delay through the repeater is multiplied by the number of passes and it's hard to see how those errors don't overwhelm any useful measurement on a short baseline.

What span of ranges are you interested in measuring? The wavelength at 433 MHz is about 0.7 m, and I don't see time of flight techniques making much sense for ranges that aren't large relative to the wavelength.

You will also face the fourth power law. Since EM waves intensity falls as the square of the distance, the returning signal from a reflection also follows the inverse square of the distance. The inverse square of a square is 1/d4. In other words, you will observe a dramatic decrease in return signal with distance. If you expect to cover a range of distances, now you need a huge dynamic range in your receiver, in order to detect the signal threshold adequately. What receiver do you plan to use that will accomodate that?

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