# Inductance meter

## Objective

A traditional multimeter accessible to the hobbyist can measure all essential electric properties, including capacitance. The only property that still remains difficult to measure without extra investments (which can become rather significant) is inductance. Solenoids/coils are an essential part of any analogue circuit and, as opposed to all other discrete components, are often homemade. There are formulae helping to calculate parameters like number of windings, cross-section of the core and so on for a desired inductance to be obtained, but one critically needs to verify the inductance of the final product. This article describes how one can build a rather accurate L-meter at home for probably less than \$10. Here you will find the schematic, PCB layout, micro-controller source code; basically all you need to DIY.

## Description

The L-meter presented here is based on a rather popular solution using the LM311 comparator (see e.g. [1]). It is stripped from the capacitance measuring capability due to micro-controller unit (MCU) source code size limitation. This limitation is dictated by the compiler I have used: MikroC PRO for PIC, ver. 6.0.0, not the MCU itself. The free license of the compiler allows up to 2k of program words (2066 to be exact, and the present code is 2065 program words).

Other solutions omitting the LM311 and using built-in the MCU comparators can also be found (see e.g. [2]).

The MCU used in this project is PIC 16F88. The code given below is also for this MCU. The internal oscillator block is used, working at 4 MHz (selected by the OSCCON register, bits 6-4). The prescaler is set to 1:1 on the watchdog timer (OPTION_REG register, bits 2-0).

## Specs

The L-meter presented here has a lower limit of ~1 µH and an upper limit of ~1 MH (Mega Henry).

Some sources (e.g. [3]) claim lower limits as low as 10 nH, but I personally do not see how this can be achieved with the current solution. For more details see section "Theory and Schematic".

Power source: 6-24 VDC adapter.

## Theory and Schematic

L-meter schematic (Erratum: J1 should receive more than 6 VDC and less than 24 VDC, not 5 VDC as in the schematic)

The working principle of the schematic is as follows:

• A tank circuit consisting of the capacitor C3 and the unknown coil (Lx) will oscillate at a resonance frequency:

$\displaystyle{ f = \frac{1}{2\pi\sqrt{LC}} }$

The schematic here is designed to work as a frequency counter, counting the frequency of oscillation of the aforementioned tank cirquit LxC3. Then if the value of C3 is known the MCU can measure the frequency, calculate Lx and display it on the LCD:

$\displaystyle{ L = (\frac{1}{2\pi f \sqrt{C}})^2 }$

• Without Lx connected, LM311 works as a free running multivibrator with a frequency on pin 7 ~1 Hz. When some Lx is connected, pin 7 on LM311 starts oscillating with the frequency of the tank cirquit. The bigger Lx the lower the frequency. Thus the upper limit of measurement will be limited by the frequency of the free running multivibrator (~1 Hz) and is therefore of the order of 1 MH.
• The rectangular pulses generated by LM311 will then be picked by the MCU, the frequency and inductance calculated and the inductance displayed on the LCD.

Since the primary measured quantity in this project is frequency, we need to count pulses per unit time. Therefore using some kind of a counter mode of the MCU should be in order. PIC 16F88 has such a mode, as a good deal of the other PIC MCUs. This mode is selected in the OPTION_REG register (TOCS bit). When counter mode is selected, Timer0 counts the external clock pulses on RA4/AN4/T0CKI/C2OUT pin (pin 3). The timer/counter can be set to increment either on the rising or on the falling edge of every pulse arriving at RA4/AN4/T0CKI/C2OUT. This is firmware selectable by the T0SE (Timer0 Source Edge) bit of OPTION_REG. The counting range of the counter can be extended by the use of the prescaler or in the firmware. The latter technically does not increase the range of the counter as such, but it allows reaching very high counts. In the code below the latter method is used, since we are interested in counting every single pulse. Using a prescaler would cause inability to measure lower frequencies.

In theory, if the oscillator frequency is 4 MHz (Tosc 0.25 μs), one cycle will be 4 x Tosc = 1 μs. An external clock signal going directly into the counter (pin RA4/AN4/T0CKI/C2OUT), without prescaler, should be high for longer than 2 x Tosc + 20 = 520 ns and low for at least the same time. This gives a total period of 1040 ns. Thus, the maximum input frequeny is 1/1040 ns = 961.5 KHz. If the prescaler is applied, according to the specs of PIC 16F88 the external clock input must be high/low for more than 10 ns. Consequently, the maximum countable frequency on pin RA4/AN4/T0CKI/C2OUT is 50 MHz. This would give a minimum measurable inductance ~10 nH. Why are we getting only 1 µH then? All boils down to the quality of the pulses LM311 in this configuration can give. The rising edge of these pulses has a relatively poor time constant, which results in a relatively slow saturation. Therefore, if the frequency is high enough the pulse will start falling before the rising edge has reached saturation, thus creating a train of jigsaw shaped pulses with an amplitude decreasing with the increase of the frequency, rather than rectangular ones. And for frequencies higher than what Lx < 33 µH can give the pulse becomes so bad that the MCU cannot correctly interpret it. How can one go from 33 µH down to 1 µH for the minimum inductance measurement then? In the prototype I built the critical Lx is 33 µH. Below this inductance the counter begins to generate more or less random numbers. But if one doesn't know that these are random numbers one might take them for real. Here L1 enters the picture. Whenever an unknown inductor is measured, it will be connected in series with L1 (added to it). Thus, at least 33 µH will always be measured and the system will never get into the region of instability due to bad pulse shape. Then an offset of -33 µH is added in the firmware so that if the Lx input is short circuited 0 µH will be displayed. Now when a 1 µH coil is measured, the display will show 1 µH.

If smaller inductances are to be measured the multivibrator part needs to be redesigned, so that correctly shaped pulses are formed at higher frequencies.