An inductance / capacitance meter by Phil Rice VK3BHR
Almost as published in Amateur Radio magazine, April 2004.
Measuring range is from 0 to >0.1uF for capacitance and 0 to >10mH for inductance.
Expected accuracy is +/- 1% of reading +/- 0.1pF or +/- 10nH
Frank Winter VK4BLF has made a nice printed circuit board for this meter. (It's much nicer than my unit which was constructed on "dot matrix" board.) See http://members.optusnet.com.au/frankwinter/ for details. Frank also has a nice Amp-Hour meter described on his site.
Mark Webster has suitable displays for sale (and at a nice price too!). See http://home.exetel.com.au/marknac/displays.htm
There's also links to a heap of useful information on Mark's page.
Here's some answers to Occasionally Asked Questions!
For those people who want to use a different Ccal capacitor, here's a javascript Floating-Point converter I hacked up (with a lot of help from friends). It converts real numbers into Microchip's 24 bit format. (This may also be useful to anyone who wants to adjust their LC meter to read the wrong value. ;-). Please feel free to grab a copy.
This project (or derivations of it, or vaguely similar LC meters) are available on the web in several different languages. My thanks to the following people for their translations.
Author Language Web Site Marek SP7DQR Polish http://sp7dqr.waw.pl/lcmeter_pl.html Aleksandr Buyevskiy Russian http://www.cqham.ru/lc_meter.phtml Patrick TK5EP French http://tk5ep.free.fr/tech/lcmeter/fr/lcmetre_f.php Volker SM5ZBS German http://www.janson-soft.de/lcmeter/lcmeter.htm
Why?
Several years ago, I built a "one transistor oscillator", which I used to measure small inductance values (by measuring the frequency of oscillation and applying the formula for resonant frequency of an LC circuit). Following from the frequency meter project published in the September 2002 issue of AR, I wondered if I could combine the oscillator and frequency meter to make a direct reading inductance/capacitance meter. I had seen an instrument that did exactly this on the web at http://www.aade.com/lcmeter.htm for $120US and thought "I'd like one of them".How?
The AADE web site gave details of how their design worked and a circuit diagram. This led me to propose a design using their oscillator, but in a slightly different way. Like theirs, mine would measure the free running frequency of an LC oscillator, then successively apply a known capacitance then the unknown inductor (or capacitor). After that, the maths used to calculate inductance or capacitance would be quite different. A brief play with the required formulas showed that it was COMPLICATED!At this time the maths all seemed too hard.
A lucky find!
Then I discovered Microchip Application Note - "AN575 IEEE754 Compliant Floating Point routines" (add subtract, divide and multiply). It didn't take long to load the code into a PIC 16F84, but the 32 bit floating point routines nearly filled the entire chip. This left no room for the frequency measuring, inductance/capacitance calculations and display formatting instructions.At this stage, I found that I could use the Microchip 24 bit Floating Point code and, by being a little careful, could fit it all in and achieve a numerical error of less than 0.1%. Overall accuracy would then be limited by the oscillator behaviour and one "calibration capacitor".
The Hardware!
This is a combination of two stolen designs.The oscillator design originally came from the AADE LC meter web page. It uses an LM311 comparator with positive feedback to make a parallel LC oscillator with digital output. It seems to oscillate readily over a wide range of L and C values. Hopefully, it follows the "well known formula for resonant frequency".
The frequency measuring part is a cut down version of the September 2002 Frequency Meter article from AR. The original idea for this came from the web pages of Eamon Skelton, EI9GQ.
Most of the components were mounted on a prototyping board (the sort that has copper donut lands spaced on a 0.1 inch grid.
Heres a link to a fuzzy photograph and an overly large sketch of my layout. Naturally, your layout will depend on available components.
The Software
This was the hard part (and the fun part) of the project. Luckily, it's easy to duplicate and the copies work as well as the original.The program takes two measurements when "zeroed". First the oscillation frequency is measured using only the internal inductor and capacitor (F1). Then a standard capacitor (Ccal=1000pF +/- 1%) is added in parallel and the frequency is measured again (F2).
The program then goes into a repeating loop where it measures the frequency of the oscillator using the internal inductor and capacitor and whatever unknown external inductor or capacitor is connected (F3). Some serious maths (formulae 4 and 8) is performed each time to calculate the unknown external component value. This value is then scaled in engineering units and formatted for display.
After getting quite a few requests for the source code, I have decided to make it public. I am never going to get rich selling it. If you get rich, I don't want to know! (If you have fun with it, I do want to know ;-)
You have a choice of seven versions. (I would avoid the first, even though it works OK ;-)
Assembler source code | Hex PIC code |
---|---|
lc004.txt an "early" version, only for the 16F84 | lc004.hex |
lc628.asm ported to the 16F628 by Egbert, PA0EJH | |
lc006.txt A version for both the 16F84 and the 16F628, incorporating modifications by Egbert, PA0EJH | lc006.hex for the 16F84 lc006b.hex for the 16F628 |
lcmeter.zip Andreas Winter has improved the program by:.
| lcmeter.zip |
lc006d.txt A "two range" version by Cristi Morariu Click here for a short article describing Christi's version, complete with pictures and diagrams. | |
LC006d32.txt A "32 bit" version by Cristi Morariu Click here for a copy of Cristi's email describing this version. | |
lc007.txt (25th. October 2005) A version for both the 16F84 and the 16F628. This incorporates error checking of ALL floating-point calculations. (Every single + - * & /) | lc007a.hex for the 16F84 lc007b.hex for the 16F628 |
LC Meter Version 2. (15th. November 2007) Revised hardware, using a 16F628 to replace the 16F84 and the LM311. Performance is no better or worse, but the circuit is marginally simpler AND there is a PC board layout for it and it has software calibration too! |
- p16f84.inc which comes with the Microchip Asembler.
- FP.TXT which has, in the past, been found on the Microchip Web site. See http://www.microchip.com - search for AN575. The file you really want is called FP24.A16. Take out the subroutines FLO1624 and INT2416, which aren't used.
The Fine Print (Software Warranty)
This code comes with no warranty and no support. It worked for me and a lot of other VKs. If it works for you, that's GREAT. If you get rich selling it, I don't want to know!Getting Started
To aid initial troubleshooting, the PIC program includes a test mode which is entered by shorting link LK1 and pressing "zero". The PIC will now repeatedly count oscillator cycles for 0.1 second and display the result. With just the 82uH inductor and 1000pF in circuit (no external component, no calibration capacitor), the oscillator will run at about 550KHz and the display will show around 55000 If the frequency is too high (anything over 655.350KHz), the display will show "Over Range". If the oscillator isn't running, the display will show "0".For best accuracy, the free running frequency should be 10% to 15% below 655KHz. If it is too close, it may accidentally overflow the PIC's internal 16 bit count. You may need to adjust the inductance to get get the frequency right..
A second link, LK2, connects the calibration capacitor. The oscillator should then run at about 394KHz.
A third link, from pin 10 of the PIC 16F84 to ground (LK3), caters for "badly behaved" displays. If your display only ever shows 8 characters (ie. no pF, nF or uH as appropriate) then try grounding pin 10 of the PIC.
Operation
In practice, it's a bit like an ohm meter. For an inductor, just short the leads and press the zero button, then connect the unknown inductor. For a capacitor, zero it with the leads open, then connect the unknown capacitor. The meter can be zeroed with an unknown component connected. For subsequent components, it then indicates the difference (+ or -) from the original component value. Great for matching parts!How Accurate?
Accuracy depends on the user doing the "right thing" and on the unknown component being of fairly high Q. The PIC's internal program relies on the setting of the L/C switch being appropriate for the component. Since all the PIC is doing is measuring the frequency of the oscillator, any strange component that allows the oscillator to work will be reported as an inductor or a capacitor depending on the L/C switch. For example a 22 Ohm resistor is reported as a 3.14uH inductor or a 119nF (0.119uF) capacitor. This isn't even remotely correct! When the unknown component has high Q (as you usually want in a tuned circuit) AND the L/C switch is set correctly, the prototype generally shows errors of less than 1%.I checked the accuracy of the LC Meter against an old Marconi bridge, for capacitors of 33pF to 0.22uF. For inductors, I only checked values from 475uH down to 60uH. Below that value, the Marconi bridge was a bit "cranky".
While the LC Meter is self calibrating, errors depend a little on the components used in the oscillator LC tank (L and C on the circuit diagram) and on the "standard" capacitor (Ccal), which should be 1000pF to within 1% or better.
The worst errors occurred when using a ferrite bobbin style choke from a switchmode power supply for "L". Here the error was less than 1% for capacitors below 3300pF and 2% for inductors less than 475uH. The error climbed to 3% for 0.22uF capacitors.
Surprisingly, the best accuracy used a "moulded" choke scrounged from an old TV. Here, the error was less than 1% for capacitors less than 0.22uF and less than 1% for inductors less than 475uH.
In all cases, I used a 1000pF styroseal capacitor for the oscillator tank "C". A "greencap" would be a suitable substitute but a ceramic capacitor may not be a good choice. Some of these can have high losses.
I have no reason to suspect any strange non-linearities in the readings for low value components. Small component values are, in theory, directly proportional to frequency difference (when the part is added to the oscillator). The software inherently follows this proportionality. The only way I can verify this is to construct some small L/C tuned circuits and measure their resonant frequency - and I haven't got round to doing that yet.
Conclusion
With the aid of a little easily copied FREE software, you can have your own (possibly) accurate inductance and capacitance meter. With the worst possible set of components from the junk box, accuracy should be better than 3%. If you are lucky, accuracy should generally be better than 1%. It's now possible to design a tuned circuit, construct it and have it resonate on the right frequency first time, every time.Still got a question or two about the project?
Here's the OAQ - answers to Occasionally Asked Questions! Please check this out before emailing me. It might just answer your question. I will put more answers here as they materialise (in answer to emailed questions ;-).References
- The original idea and the oscillator came from http://www.aade.com/lcmeter.htm
- The frequency measuring code came from http://ironbark.bendigo.latrobe.edu.au/~rice also http://homepage.tinet.ie/~ei9gq/stab.html
- Microchip's Web Site provided the Floating Point code essential to the working of the meter. See http://www.microchip.com - search for AN575
No comments:
Post a Comment