Author Topic: How to measure frequency using avr  (Read 15529 times)

0 Members and 1 Guest are viewing this topic.

Offline amateur_25Topic starter

  • Regular Contributor
  • *
  • Posts: 106
How to measure frequency using avr
« on: September 30, 2012, 10:47:31 pm »
I'm trying to build a lc meter I want to know how do I go about messuring the resonant frequency so I can
obtain the unknown inductance/capacitance.  The design is from this site http://electronics-diy.com/lc_meter.php.
 

Offline vk6zgo

  • Super Contributor
  • ***
  • Posts: 7699
  • Country: au
Re: How to measure frequency using avr
« Reply #1 on: October 01, 2012, 02:45:04 am »
The link doesn't work!

I am not an "AVR-literate" person,but if you are only reading fairly low frequencies,it shouldn't be that hard.
There are quite a few people on this forum who play with AVRs,so maybe one of them will pick up this thread.

Another possibility is to use the soundcard of your PC,plus some readily available software.
In the past,analog frequency meters have also been used in this sort of LC meter.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10220
  • Country: nz
Re: How to measure frequency using avr
« Reply #2 on: October 01, 2012, 03:49:55 am »
His url doesn't work because there's a full stop on the end.
http://electronics-diy.com/lc_meter.php

There are many options to measure frequency, you can;

- Use your input frequency to clock one of the AVRs timer then compare the counts in a given time with a different hardware timer running at a fixed clock.

- Use an AVR timer to count at a faster rate than your signal and read the time-stamps from the input capture unit pin which your input signal is connected to.
 
And i'm sure there are other combinations too.
On some AVRs you can clock the timers from an external clock that's faster than the AVR cpu. (within reason)
And some have a builtin 64Mhz PLL clock which can be used on the timers.
« Last Edit: October 01, 2012, 04:02:21 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline amateur_25Topic starter

  • Regular Contributor
  • *
  • Posts: 106
Re: How to measure frequency using avr
« Reply #3 on: October 01, 2012, 10:15:03 am »
Sorry I forgot to mention am using the arduino platform. What is my easiest option? Ideally I want to use an atmega8 / atmega328 if possible? These are the only chips I have. I don't mind buying different ones if it makes it easier for me though. Thanks for your help!!

I f I have not misunderstood the datasheet the external clock source for the timers is where you usually put a crystal for the main cpu clock. Hence it already used by the 16MHZ crystal . 

What I'm struggling on is how they've managed to measure the frequency without any extra hardware? IT's only using 4MHz crystal and probably some timers which seem to be a similar spec to the ones used in the ATmegas
« Last Edit: October 01, 2012, 10:17:54 am by amateur_25 »
 

Offline firewalker

  • Super Contributor
  • ***
  • Posts: 2452
  • Country: gr
Re: How to measure frequency using avr
« Reply #4 on: October 01, 2012, 10:27:39 am »
AVR205: Frequency Measurement Made Easy with Atmel tinyAVR and Atmel megaAVR.

http://www.atmel.com/Images/doc8365.pdf
http://www.atmel.com/dyn/resources/prod_documents/AVR205.zip

Alexander.
Become a realist, stay a dreamer.

 

Offline Thor-Arne

  • Supporter
  • ****
  • Posts: 500
  • Country: no
  • tinker - tinker, little noob.....
Re: How to measure frequency using avr
« Reply #5 on: October 01, 2012, 03:08:28 pm »
I'm trying to build a lc meter I want to know how do I go about messuring the resonant frequency so I can
obtain the unknown inductance/capacitance.  The design is from this site http://electronics-diy.com/lc_meter.php.
Hi.

Take a look at http://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/, that's a frequency counter library for the Arduino.
 

Offline amateur_25Topic starter

  • Regular Contributor
  • *
  • Posts: 106
Re: How to measure frequency using avr
« Reply #6 on: October 01, 2012, 05:59:29 pm »
Thanks for that. There's a preamp on the input. Do I still need the preamp for my lc meter? What does it actually do? 
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 2032
  • Country: dk
 

Offline Thor-Arne

  • Supporter
  • ****
  • Posts: 500
  • Country: no
  • tinker - tinker, little noob.....
Re: How to measure frequency using avr
« Reply #8 on: October 01, 2012, 06:13:20 pm »
Thanks for that. There's a preamp on the input. Do I still need the preamp for my lc meter? What does it actually do?

Yes, you still need the rest of the electronics. The Arduino library is just a frequency counter, the LM311 is generating a frequency that can be measured. You'll have to code the rest yourself.
 

Offline amateur_25Topic starter

  • Regular Contributor
  • *
  • Posts: 106
Re: How to measure frequency using avr
« Reply #9 on: October 02, 2012, 11:31:46 am »
Sorry to bother you but there's still one thing that been poundering about in the back of my head.
Am I correct in saying the frequency am trying to measure for my lc meter is called the resonant  frequency?

Whatever it's called according to my calculations when am measuring a 10nH inductor with the 1000pF calibration capacitor then the
frequency I'll be measuring is 50MHz. That many mangitudes higher than the claimed 8MHz on the web page you linked to.

I saw a similar project use a 74HC191 logic chip, would this do the job for me? If not could you recommend me a cheap alternative
« Last Edit: October 02, 2012, 11:33:36 am by amateur_25 »
 

Offline Thor-Arne

  • Supporter
  • ****
  • Posts: 500
  • Country: no
  • tinker - tinker, little noob.....
Re: How to measure frequency using avr
« Reply #10 on: October 02, 2012, 01:06:31 pm »
Sorry to bother you but there's still one thing that been poundering about in the back of my head.
Am I correct in saying the frequency am trying to measure for my lc meter is called the resonant  frequency?

I think that should be right.

Whatever it's called according to my calculations when am measuring a 10nH inductor with the 1000pF calibration capacitor then the
frequency I'll be measuring is 50MHz. That many mangitudes higher than the claimed 8MHz on the web page you linked to.

That doesn't sound right, I think 50 MHz is way to high frequency to measure with something that only has a 4 MHz clock. Anyone else have some thoughts on this?

I saw a similar project use a 74HC191 logic chip, would this do the job for me? If not could you recommend me a cheap alternative

It's possible to design a LC meter using logic chips, however i think you can just forget about measuring 50 MHz with that one to. The datasheet http://www.nxp.com/documents/data_sheet/74HC_HCT191_CNV.pdf say maximum frequency is 36 MHz.

I'm not an expert on these designs, but I doubt the PIC @ 4MHz can handle 10 times higher frequency than the Atmega @ 16MHz.
It wouldn't surprise me if there was a typo on web page and it should be uH instead of nH. 10 uH would give you ~1.6 MHz, which seems like a more realistic frequency.

That said, I'm no expert. I just wanted to point you in the general direction of the Arduino frequency counter. You should probably look at the different circuits and compare what the difference is.
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 2032
  • Country: dk
Re: How to measure frequency using avr
« Reply #11 on: October 02, 2012, 07:36:56 pm »
I'm not an expert on these designs, but I doubt the PIC @ 4MHz can handle 10 times higher frequency than the Atmega @ 16MHz.

I'm an AVR guy my self , but i think i read that the PIC has an 8-bit hardware input capture prescaler , that actually enables it to measure frequencies up to 50Mhz wo. external divider chips.

Maybe that's what they indicate.

/Bingo
 

Offline Thor-Arne

  • Supporter
  • ****
  • Posts: 500
  • Country: no
  • tinker - tinker, little noob.....
Re: How to measure frequency using avr
« Reply #12 on: October 02, 2012, 08:02:02 pm »
I'm an AVR guy my self , but i think i read that the PIC has an 8-bit hardware input capture prescaler , that actually enables it to measure frequencies up to 50Mhz wo. external divider chips.

Maybe that's what they indicate.

Yes, that would explain the ability to sample such a high frequency.

And that would stop the possibility to use an AVR in this circuit.
So as I see it; only solution is to look at one of the other links you posted and adapt some of what's described there.
 

Offline vk6zgo

  • Super Contributor
  • ***
  • Posts: 7699
  • Country: au
Re: How to measure frequency using avr
« Reply #13 on: October 03, 2012, 06:45:58 am »
I very much doubt if the LM311could oscillate at 50MHz.
A possible method is to add the inductor under test in series with a known inductor,& measure how far the frequency shifts.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf