# Inductance/Capacitance Meter Saga

I had a bunch of random inductors in some random drawers and I wanted to know what values they were. These values are quite often not obvious by looking at the device. Color codes for old ones were not standardized and some of the colored rings on inductors can be faded or discolored so that its impossible to tell what they are. Others may be unmarked and any that are hand-wound are just guess work without a meter. So I decided to make an inductance and capacitance meter which would be fairly accurate and work over several decades of value from a few nano-Henries to a few milli-Henries and also from a few pico-farads to about a micro-farad (hopefully). Sounded easy – what could go wrong?
This shows what I went through to do it. It is not a pretty sight, but rather than report the cleaned-up version with all of the screw-ups edited out I thought it would be good to show some of you gentler souls what can happen to the best of intentions when Mr. Murphy intrudes and decides that YOU SHALL NOT PASS!
But really, folks, just about everything that could go wrong with this project, did. I finally prevailed, however. And I also managed to accomplish, erm…, most of my design goals in the process. (!)

## Step 1: Design philosophy

OK, so how do you measure inductance or capacitance, anyway? After thinking about it for a while and researching how others did it, I found that there are three basic approaches:
1 – Tank Resonance: The unknown Lx or Cx is made part of a resonator which used in an oscillator. The resulting frequency of oscillation is measured against a known precise time period and used to calculate the unknown value.

2 – Time Constant: The unknown Lx or Cx is partnered with a known resistor value. This circuit is charged or discharged with an abrupt voltage step. The resulting voltage charging time is measured with a known clock and used to calculate the unknown.
3 – Impedance Measurement (the most common): An AC current of known frequency is driven through the unknown inductor or capacitor and the resulting AC voltage across it is measured. The unknown value is calculated from this.
Both methods #2 and #3 suffer from the same inaccuracy. That is that the unknown inductor or capacitor also has an unknown resistance value that appears in series with it. This is a normal consequence of building real world L’s and C’s from wire and sheet aluminum. This resistance causes charge times and impedances to appear larger than they should and can make ind/cap readings to be as much as 5-15% too big or bigger. To be correctly taken into account, this series resistance would first need to be measured so that it can be figured into the calculation. This would have to be done in different ways for inductors or capacitors and would complicate the unit.
Method #1 does not suffer from this problem. The series resistance could make the oscillator slightly less strong but would not change its resonant frequency.
So I choose method #1. At this point, I must confess that I’m holding out some (vain) hope not to involve a microprocessor. (Ha!!)
The frequency measurement referred to above would suffer from much less calibration error, particularly with low values if what we actually measure is the change in frequency brought about by inserting the unknown into an already working oscillator. So first the frequency of oscillation using a known inductor and capacitor would be measured and then again with the unknown inductor inserted in series with the known one, or the unknown capacitor inserted in parallel with the known one. In each case the frequency of oscillation would be lowered by some small (or not-so-small) amount.
So, the unknown value can be calculated from:
Lx = ( (fo/f)^2 – 1) * L
or
Cx = ( (fo/f)^2 – 1) * C
Where:
Lx and Cx is the unknown
fo is the frequency of oscillation without the unknown inserted
f is the frequency of oscillation with the unknown inserted
L is the known (built-in) tank inductance
C is the known (built-in) tank capacitance
As can be seen from these equations, if the measured freq, f, is the same as the reference freq, fo then the calculations go to zero. This makes sense and would be the case if the test terminals are shorted for an inductance measurement or left open with no component for a capacitance measurement.
Both of these equations can be derived directly from the equation for resonant frequency of a tank resonator:
fo = 1/ ( 2 * pi * sqrt(L * C) )

## Step 2: Choice of (Cheap) Components and (Just as Cheap) Required Development Tools

Firstly, I fully expected to put this thing on a home-made PCB using the toner-transfer method which I did. (pictures follow)
But, after about 15 minutes of cogitation about a hardware-only solution, I realized that insanity lay that way and that a micro would indeed be necessary, 8-(. But, at least I could hopefully brush up my C code skills, 8-), but if driven to it I could resort to good old assembler programming, 8-|, (just like in the Good Old Days). Now, as with some other projects, I wanted to spend minimal money on this unit, so I went to see what uP/uC’s I had on hand. After making a list of available chips I whittled them down to meet the following criteria:
1 – the parts are already in my hot little hands (or drawer)
2 – the development tools are already on hand: (cross-assemblers, device programmer, C compiler for ATMEL 8-bits, Microchips FREE C compiler for PICs)
3 – the chip has sufficient I/O pins and (cough) code space to do the job
This narrowed it down to two PICs from Microchip, the PIC16C57C and PIC16C58B and the ATMEL ATMEGA16. I’ve used the ATMEGA16 before and it is a lovely chip with lots of code space and a wide array of goodies on board but I thought it was overkill so I chose the PIC16C57C which had more I/O than its little brother, the PIC16C58B but only one timer to do several things. With the hard decisions made, I launched into the circuit design with (naive) gusto.
As I said above, the scheme is to insert the unknown into a tank circuit and measure the change in frequency of oscillation. The schematic fragment shown is the oscillator used. It is based on a standard comparator, the LM311 in dip-8 package. This circuit has been used by many for this but I first saw this used on www.radiolocman.com (http://www.radiolocman.com/shem/schematics.html?di=33994). I prototyped it to make sure it would work with a wide range of L and C values and it did. Furthermore, inserting series resistance into the unknown L/C made little difference to the frequency as measured by a (relatively cheap) counter, a Fluke 1910A good to about 5ppm accuracy and seven digits of precision. The math was verified with several known L’s and C’s inserted into an already operating tank circuit. As well, the frequency of oscillation was measured over different power supply voltages from 3.3V to 12.15V with a variation of less than 0.5% from min to max. So far so good.
Now, the PICs are good chips but I had only 1990’s-era cross-assemblers (don’t laugh – they work) for sw until I saw a reference to Microchips FREE C compiler on Lady Ada’s personal website. The chips are UV-erased and my handy Need hams programmer will program them! I had 4 specimens. All of the other parts would be garden variety stuff which I already had as well including a chunk of blank one-sided pcb material. Great!
At this point, I found that my handy 2002 Need hams programmer was dead! I have no schematic of it so tried to get help from the maker. Their website ( www.needhams.com ) didn’t mention the unit so I called them in Florida. (Phone #303-861-8200 ) I could only leave a message with a service but was almost immediately called back by David who was doing tech support (and admitted that he’d rather be doing something else). However he said that they have NO schematics for the unit or any of their products sold prior to 2006 when they suffered a fire and was completely burned out! “We lost everything!” Many blogs say they are out of business but their site is still up AND with new products. However they accept orders ONLY over the phone, now (??). I am here to say that I love that programmer and that all of their products are really great units at very reasonable prices. I would buy from them again in a heartbeat. But the current budget doesn’t allow for it, so after 2-3 hours of probing with no documentation, I find the dead component (a common one), replace it and it works again as before. Whew!
Fortunately my UV eraser is still OK after all these years (last used in early ’90s).

## Step 3: Schematic Explanation

The oscillator is shown in the first picture in this step. Assume that there is a nothing between the test port connectors and that the switch is in C position. Thus the left end of inductor L1 is grounded.
The LM311 is a common voltage comparator. Its output goes high or low depending on the difference voltage between its two inputs ( + , – ). The negative input is automatically biased quite near the positive one by R5. Cap C5 serves to remove any oscillation from this feedback. When the power comes on pin 2 of the chip rises to some voltage between 1/2 and 2/3 of the power supply. The output will be high since pin 3 is momentarily held low by uncharged C5. Once C5 charges up through R5 and gets to the voltage on pin 2 of the chip, the output will go low. The inductor and capacitor, L1, C6 will ring at some frequency, fo causing pin 2 of the chip to ring as well at the same rate. This causes the output to switch at the resonant frequency. The DC voltage on the negative input of the chip will follow that of the positive input. The LC tank will continue to oscillate at fo, as it is driven from the output through R4.
With the switch in C position any capacitance put on the test port will go in parallel with C6. With the switch in L position any inductance on the test port will go in series with L1. In both cases the frequency of oscillation is reduced. It is this reduction that is used in the calculation of the test component value. So I needed some way to remove the test component from the circuit temporarily while the reference frequency is measured. The second picture shows how this is done with a DPDT relay driven from a port on the micro. The micro also needs to know which position the switch is in. This pic should show a connection going from R3 to off-page. This would be connected to another port on the micro.
A complete schematic of the first version of the unit is given next. Now, the PIC16C57C has only one timer and its limited to 8 bits. So if I wanted to count oscillator cycles and have some reasonable resolution I needed to have at least 4 more timer bits. So, I put a 4-bit prescaler counter, U2, between the Lm311 and the PIC which could be read by software. I would generate a fixed gate time to accumulate oscillator counts with a simple buzz loop in the code. This buzz loop would also handle the display digit multiplexing.
Since the micro had to measure the frequency of the tank with no test subject present I needed to momentarily switch the test port out of the circuit. Relay K1 with its DPDT contacts and driver transistor Q1, allow the PIC to do this.
All of the segment and digit drives for the display come directly from the PIC and go through connectors JP1, JP3 to the transistor drivers on the top board. The displays I had were common cathode so all of the segment signals from the PIC are pull-down to turn on while the digit drive signals are pull up to turn on.
Putting the MEASURE button and an LED on the same PIC pin forced me to make a trade-off. That was that when I pressed the button the LED was allowed to come on not under sw control but the sw could turn it off and then on after that and after I raised my finger too. So the LED could be flashed while measurements were being made (that is while my finger was down) yet when the button was released the PIC could still turn the LED off and check the button.
Since the test port and the DPDT switch had to poke through the top of the tin, all of their signals also went through the connectors to the oscillator. This would add some extra wiring (and inductance) to the measurement but could be taken out again in the calculation.
The power supply section is standard stuff and was designed after I scrounged up a 9 VAC wall wart and patched on a connector. The 7805 regulator needed a small heat sink to keep it from smoking.
At about this time, as luck would have it, my wife came to me with a neat round metal candy box (now empty) and said “Why don’t you put it in this?”. So I looked at it and said “Why not?” You can see it in the last picture under my desk lamp. The computer shows the layout in progress.

## Step 4: PCB Creation – Ver A

I finished the hardware design using only parts that I had and proceeded to calmly start a PCB layout for a 4” diam. round board to fit into the candy tin.

It wasn’t very long before I realized that not everything would fit. So I split the circuit into two parts to go onto two round boards that would be stacked on standoffs and arranged for a 24-pin connector to connect the two. Both boards are single-sided copper. I planned to print the legend on the top side, too.