Measuring frequencies higher than the AVR?

Go To Last Post
19 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would like to explore building a small device that can sample and display 2 or 3 frequencies.  The high range (maybe 30MHz) would exceed the AVR's frequency.  0.1MHz accuracy would be great but I could settle for 1MHz resolution and the refresh rate doesn't need to be fast, 10 seconds would be fine.  Is there a not too expensive circuit, component, or technique that can be implemented to do this?  It's just a hobby project and I think it would be great to have a small display of rough measurements that can be attached directly to it.

 

Thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What voltage is the signal you want to measure?

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can use 74HC74 to count down signals as high as 45MHz down to a few MHz. It would take several and the signal would have to be amplified to logic levels, but I've used the scheme several times.

 

If you count down by 32 (5 counters in cascade), then to resolve 100KHz (0.1MHz), you would need a resolution of 100/32 = 3.125KHz. You would need a crystal for the MCU to get that accuracy. You can also use 74HC inverters biased into linear mode with a feedback resistor and an input coupling capacitor to get the signal amplitude to clock the 74HC74s.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tiny85 maybe others have PLL that can drive the timers up to 64MHz, so maybe use that to capture your freq.
Jim

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rooney wrote:
Is there a not too expensive circuit, component, or technique that can be implemented to do this?
Under-sampling though an anti-aliasing filter must exist along with an accurate sampling clock.

Oscilloscope Systems and Controls | Tektronix

[nearly mid-page, after Figure 27]

If the sample rate isn’t fast enough, high-frequency components can “fold down” into a lower frequency, causing aliasing in the display, as demonstrated in Figure 28.

[edit : scroll down to Equivalent-time Sampling Method]

Convolution | The Scientist and Engineer's Guide to Digital Signal Processing

https://en.wiktionary.org/wiki/convolution#Noun

 

Could try "folding" by your oscilloscope to see what results; a scope may have a 20MHz bandwidth limiter (a lot of anti-aliasing filter)

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Mon. Sep 23, 2019 - 07:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rooney wrote:

I would like to explore building a small device that can sample and display 2 or 3 frequencies.  The high range (maybe 30MHz) would exceed the AVR's frequency.  0.1MHz accuracy would be great but I could settle for 1MHz resolution and the refresh rate doesn't need to be fast, 10 seconds would be fine.  Is there a not too expensive circuit, component, or technique that can be implemented to do this?  It's just a hobby project and I think it would be great to have a small display of rough measurements that can be attached directly to it.

 

Thank you.

Sure, a few choices spring to mind...

a HC4060/LV4060 has a linear stage, followed by a 14 stage ripple divider so you can choose any tap.

HC6323A is a SO8 version, can go up to /8, and has a tristate output that could 

newer options, in SOT353-1  are 74AHC1G4208,10,12,14,15 series parts are /256, /1024, etc - these are small enough you can consider tying one to each timer input for your 3 channels.

Or, a little MCU can be programmed to do a similar task, but is unlikely to hit the MHz range of the 74AHC1G42xx

 

How low do you want to measure ?

~0.1MHz LSB is easy, if you consider a simple 1 second gate time, and a /256 prescaler, a 1MHz Fi has  ~ 3906 edges in 1 sec, so resolves to 0.0256%, and 30MHz resolves to 8ppm

 

If you need more, or better precision at lower frequencies, you can google Reciprocal Counters...  Those capture both time and whole cycles, and calculate Hz = WholeCycles/Time

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Who-me wrote:
Sure, a few choices spring to mind...

Never done it, but it is 2019 not 1999.  A Cortex-M at about 400MHz?  I'd guess there are corresponding capture facilities.

 

How do you ensure a clean 30MHz signal, sparkies?

 

lol -- hook it to a radio with appropriate band, and scan for the noise.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
How do you ensure a clean 30MHz signal, sparkies?

BPF aka a Band Pass Filter! devil

 

 

Jim

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:
BPF aka a Band Pass Filter!

OP didn't really give us a range, just the 30MHz max.  So, say 1MHz - 30MHz -- will your BPF have good characteristics over that range?  How will you make it so that a chip's counter unit will reliably count the edges?  With more modest signals our designer uses one or two Schmitt trigger stages.  Good up to 30MHz?

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:

  A Cortex-M at about 400MHz? 

 

Perhaps, but the OP did mention AVR.... so a simple SOT353 prescaler is a better fit than a 400MHz Cortex M .. 

 

If the OP is prepared to use other MCUs, there is one that already has proven code for 0.5Hz to 40MHz counters here  

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How will you make it so that a chip's counter unit will reliably count the edges? 

Well, it sounds like the OP is building a general purpose frequency meter.

That means the input could be any number of signals, all of different amplitudes, DC off-sets, and noise, etc.

 

Certainly as with most digital signal processing systems it would need a LPF to attenuate the higher frequency noise.

I don't think you need a BPF as it is usually the fundamental frequency one is after, i.e. the lowest frequency component within the signal.

That makes the filtering a little bit easier.

 

Then feed the signal to a DC blocker to remove any DC offset, and then feed it through a gain stage or two to clip the signal.

That is essentially what the Schmitt does, with a little added hysteresis.

 

Sounds like a great project!

 

JC 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

Well, it sounds like the OP is building a general purpose frequency meter.

 

It is never an easy thing...  to make your meter.  S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There was a at902313 based frequency counter on the interwebs many years ago - mainly for a readout for hf receivers. It used an external ttl counter as a prescaler.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
Never done it, but it is 2019 not 1999.  A Cortex-M at about 400MHz? 
+1

 

I'd just pick the right tool for the job in the first place. Don't see much point beating yourself up simply to use an inappropriate piece of equipment!

 

Perhaps there used to be a time when you couldn't find a (cheap!) solution up to the job and you had to fix and bodge - but this is 2019 - Moore's Law has worked in your favour.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Moore's Law has worked in your favour.

I'm not a Cortex person, but a bit of Google work came up with

LPC1768 Timer Input Capture & Frequency Counter Tutorial

http://www.ocfreaks.com/lpc1768-...

 

...where it appears that one can use "timer as counter" pretty much like on AVR8?

 

... In Counter Mode, external signal is used to increment TC every time an edge(rising/falling/both) is detected. This behavior is configured using CTCR. Corresponding bits for Capture channel must be set to zero in CCR. ...

 

... The maximum input signal frequency which can be reliably measured using first method ["gating"] is half of TIMERn_PCLK, since it takes two successive edges of TIMERn_PCLK to detect one edge of external signal. Hence, using a TIMERn_PCLK of 100Mhz we can measure upto 50Mhz signal properly.

That model is an M3.  I'd guess the same facilities are on less expensive models as well?  e.g. LPC1111 M0 at a couple bucks and two 32-bit timers with counter capability.  .  Anyway, with a clean signal and that tutorial the job is done.  As discussed, one would struggle a bit to do it on an AVR8.  lol -- if one is adding external counter circuitry anyway as laid out above, make the external circuitry be a Cortex.  devil

 

Cliff and I had roughly the same comments on the same topic in 2013

https://www.avrfreaks.net/forum/...

 

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Last Edited: Tue. Sep 24, 2019 - 02:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A PIC CTMU can implement a frequency meter, a PIC NCO has precise frequency control, down-convert the signal to within the frequency meter's range.

Some PIC have ACT that's referenced to a 32KHz oscillator or USB SOF.

PIC are common in amateur radio operators' projects.

 

AN1375, See What You Can Do with CTMU

[page 6, right column]

23. Frequency Meter

CTMU - Charge Time Measurement Unit

NCO - Numerically Controlled Oscillator

ACT - Active Clock Tuning

SOF - Start Of Frame

8-bit Peripheral Summary - Developer Help

 

edit : Active Clock Tuning - Developer Help

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Tue. Sep 24, 2019 - 07:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:

...down-convert the signal to within the frequency meter's range.

 

 

So if you down-convert, then can't you use the AVR as originally proposed?

 

Can you still reach OP's desired resolution of 0.1MHz on a 30MHz signal, about 3%, after down-converting?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
Can you still reach OP's desired resolution of 0.1MHz on a 30MHz signal, about 3%, after down-converting?
No as that's too close to the internal clock's accuracy.

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you all for the feedback.  I was wanting to measure the frequency speed of various segments of an old PC (CPU-FPU-BUS) and display them neatly in one place so that as I clock and tweak different aspects I could see the exact current configuration.  The only MCU I'm familiar with is the AVR and I didn't want to go down a new rabbit hole with a different architecture at the moment.  As with many things however I see that there are some $10 1-50MHz gadgets with LCD's readily available.  I guess given the various suggestions provided above I'll try one or more of these premade units and see how I like it.  Then if I want to roll my own I'll follow through with the excellent information you've all provided.  Thanks!