Could you help me?

Status
Not open for further replies.
Hello professor, I use Arduino Micro hardware and the freqCount library to measure the frequency, and the maximum frequency can only reach 8MHz, may I ask why? Can we get higher frequencies? If so, how? thank you
 
The processor is clocked at 16MHz so can only sense one transition every 62.5ns, 8MHz has one transition every 62.5ns.

Use a faster processor. A Teensy springs to mind given which forum this is :)

Or use a pre-scaler chip (such as divide-by-10 or divide-by-16).

Professor??
 
sorry, my friend.why 8MHz has one transition every 62.5ns? and It has to do with the clock rate of the processor, right? Does it have anything to do with timer T1?
 
Draw a square wave and count the transitions per complete cycle. You'll see there are two transitions for each complete
cycle. Hz is just cycles per second. So 8MHz has 16000000 transistions per second.

The microcontroller samples the input upto 16M times a second, so can only count transitions upto that rate.
Clocked logic samples inputs on a clock edge and is blind to anything happening faster than the clock period.

In the analog world this is know as the Shannon sampling theorem, ie you have to sample faster than 2f to
correctly represent a waveform of frequency f.

In practice you won't get reliable reading of frequency as the input starts to approach 8MHz due to jitter in the
signal and clocks, I'd suggest treating the limit as somewhat less than 8MHz for reliable counting with a 16MHz
clock
 
The AVR chip you are using simply can not count an external signal faster than half its clock frequency. Its clock is 16 MHz. It does not support a faster clock and still give USB communication. The only clock speeds for that chip are 8 or 16 MHz.

To count higher, you should use a faster board. Teensy 3.2 or 4.0 would be a better choice.
 
Why can you not hear the answer? The hardware you are using simply can not use an external signal to its timer which is higher than half its clock frequency (16 MHz). No matter how many times you ask, the answer will always be the same. It is a hardware limit of the chip.
 
What does it mean to have two transformations per cycle?

I don't know, I never mentioned transformations.

Transitions is what I was talking about. Logic signals transition between HIGH and LOW and back again. These
are also known informally as edges (rising edge, falling edge). Each cycle has to have both a rising and falling edge - so
two edges per cycle.

Microcontrollers (and other synchronous clocked logic chips) sample incoming signals synchronous to their internal clock
rising edge typically using a string of synchronization flip-flops.
 
> Can we get higher frequencies? If so, how? thank you

You could add a flip-flop clock divider circuit. But I second the recommendation to just use a teensy 4.0.
 
See Answer in post #2...

As has been answered several times in this thread: This is the limits of your hardware.

You can not expect that your hardware which runs at 16mhz is going to be able to detect an IO pin changing more than 16M states of the IO pin, And A cycle has two changes: High to Low to High
or Low to high to low... depending on which way you wish to measure. So 16/2 = Max frequency of 8 Megahertz...

How to go faster with just that hardware. You can not... Except maybe with one caveat, which is trying to overclock the Pro Micro, such as mentioned in:
https://github.com/Phasip/SparkfunProMicro-Overclock/blob/master/README.md

If you really want to better understand why, you should probably download an Atmega32u4 reference and read through it.

Sounds like a lot of work and makes it far less reliable and sounds like maybe 20mhz... So you could maybe get 10mhz sample...

But as the others have suggested, you are far better off getting faster hardware.

If you are still wishing to pursue this, I would suggest that you ask this up on a forum that is more applicable to the Arduino Micro, such as the Arduino forum.

Good luck
 
Let me try to explain with an Analogy:
Say you spin a coin 10 times per second and take photos of it.
-If you take 20 photos per second you will see half the time being heads, the other half Tails. From this you can figure out it is spinning around 10x per second!
-But If you take 10 photos per second you will see it always being heads. You see no difference between the photos and have no clue if its even spinning at all!

So to be able to spot from photos that the coin is spinning you need to be making them at least twice as often as it is spinning.


The same applies here. A single "clock-cycle" is like a single full spin of the coin, except instead of heads and tails it goes ON and OFF.
If the controller is to successfully count the cycles it needs to be twice as fast to spot it going ON and OFF. Simply no getting past that.


If you want to get past this limit you'd either need something that count more often (e.g. a way faster Teensy) OR you need to slow down the signal so it can be counted (e.g. a Flip-Flop Frequency Divider)
 
Status
Not open for further replies.
Back
Top