## A Surprisingly Accurate Digital LC Meter

This design has been superceded by "V2", which has simpler hardware AND software calibration. You should build that one instead!

### (I didn't expect it to work so well!)

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

### 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 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 ;-)

Click this link to reach the Source Code.

You will also need two other files:

• 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". The "C" range was also checked against a "lab standard" decade capacitance box belonging to the Physics department of the local campus of La Trobe University.

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 polystyrene 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?

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

1. The original idea and the oscillator came from http://www.aade.com/lcmeter.htm
2. The frequency measuring code came from http://ironbark.bendigo.latrobe.edu.au/~rice
3. also http://homepage.tinet.ie/~ei9gq/stab.html
4. Microchip's Web Site provided the Floating Point code essential to the working of the meter. See http://www.microchip.com - search for AN575

ps: Laurie fixes electric floor heating.