I need to count frequencies in the 0.1Hz to 1.99GHz range.
At my disposal is a 16bit counter with an additional overflow bit, a timer accurate to 1uS, frequency dividers and a microcontroller to glue all these together.
The logic I have decided to use is so:
- Condition the input signal to give a 50% duty cycle 5Vpp square wave
- Feed this to the configurable freq. divider so that the freq. is in something more managable
- Feed the above to the 16 bit counter while enabling the counter for a precise amount of time ( PAoT ) using the timer
- Disable the counter after the PAoT period is over
- Read the timer and do post processing to finally obtain the value of the input freq.
Everything is up and running except my ability to quickly decide upon how to select the PAoT period over the various ranges of freq. being measured.
It's obvious that a single PAoT period will not suffice to count over the whole range.
Hence, I would need to group a range of frequencies that I can count using a certain PAoT period.
I need to decide an algorithm that can do this for me.
The constraints that this algorithm should follow are:
i. The 16 bit counter is always an integer and needs to be change ( and be unique ) when the LSB of the input signal changes at the given resolution
For example, if the input freq. changes from a.b Mhz to a.c Mhz, the counter should change as well
ii. The PAoT period needs to be an integral multiple of the microcontroller clock that will be attached to the timer
iii. The 16 bit counter can be made to overflow only once
With all this given, were I to give my algorithm the range of freq. to measure as:
0.1Hz - 99.9Hz
0.01kHz - 999.99kHz
0.01Mhz - 999.99Mhz
it would give the output as follows:
10000mS -> 0.1Hz - 99.9Hz
100mS -> 0.01kHz - 999.99kHz
100uS -> 0.01Mhz - 999.99Mhz
How would one start designing such an algorithm?
Definitely this should be a well known technique to find this out ( for eg - how DSO's decide to use the sampling freq. etc .. )
Points, hints, suggestions and URLs welcome :-)