How to measure frequency using avr - Page 1
Forum section: electronics / beginners

author: amateur_25
author_rank: Regular Contributor
timestamp: September 30, 2012, 10:47:31 pm
content: I'm trying to build a lc meter I want to know how do I go about messuring the resonant frequency so I canobtain the unknown inductance/capacitance. The design is from this sitehttp://electronics-diy.com/lc_meter.php.

author: vk6zgo
author_rank: Super Contributor
timestamp: October 01, 2012, 02:45:04 am
content: 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.

author: Psi
author_rank: Super Contributor
timestamp: October 01, 2012, 03:49:55 am
content: His url doesn't work because there's a full stop on the end.http://electronics-diy.com/lc_meter.phpThere 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.

author: amateur_25
author_rank: Regular Contributor
timestamp: October 01, 2012, 10:15:03 am
content: 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

author: firewalker
author_rank: Super Contributor
timestamp: October 01, 2012, 10:27:39 am
content: AVR205: Frequency Measurement Made Easy with Atmel tinyAVR and Atmel megaAVR.http://www.atmel.com/Images/doc8365.pdfhttp://www.atmel.com/dyn/resources/prod_documents/AVR205.zipAlexander.

author: Thor-Arne
author_rank: Unknown
timestamp: October 01, 2012, 03:08:28 pm
content: Quote from: amateur_25 on September 30, 2012, 10:47:31 pmHi.Take a look athttp://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/, that's a frequency counter library for the Arduino.

author: amateur_25
author_rank: Regular Contributor
timestamp: October 01, 2012, 05:59:29 pm
content: 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?

author: bingo600
author_rank: Super Contributor
timestamp: October 01, 2012, 06:07:39 pm
content: Original avr meterhttp://cappels.org/dproj/nlglcm/Pretty%20Good%20LC%20Meter%20Project.htmlAn improved onehttp://cappels.org/dproj/EvenBetterLCMeter/Even_Better_LC_Meter.html/Bingo

author: Thor-Arne
author_rank: Unknown
timestamp: October 01, 2012, 06:13:20 pm
content: Quote from: amateur_25 on October 01, 2012, 05:59:29 pmYes, 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.

author: amateur_25
author_rank: Regular Contributor
timestamp: October 02, 2012, 11:31:46 am
content: 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 thefrequency 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

author: Thor-Arne
author_rank: Unknown
timestamp: October 02, 2012, 01:06:31 pm
content: Quote from: amateur_25 on October 02, 2012, 11:31:46 amI think that should be right.Quote from: amateur_25 on October 02, 2012, 11:31:46 amThat 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?Quote from: amateur_25 on October 02, 2012, 11:31:46 amIt'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 datasheethttp://www.nxp.com/documents/data_sheet/74HC_HCT191_CNV.pdfsay 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.

author: bingo600
author_rank: Super Contributor
timestamp: October 02, 2012, 07:36:56 pm
content: Quote from: Thor-Arne on October 02, 2012, 01:06:31 pmI'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

author: Thor-Arne
author_rank: Unknown
timestamp: October 02, 2012, 08:02:02 pm
content: Quote from: bingo600 on October 02, 2012, 07:36:56 pmYes, 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.

author: vk6zgo
author_rank: Super Contributor
timestamp: October 03, 2012, 06:45:58 am
content: 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.