Inductance Meter for Small Inductances

Part 2: Circuit Description


Continued from Part 1 -- Introduction and Concepts.

Detailed Circuit Description

The circuit description is based on the full schematics, and I suggest that these are downloaded and available to best follow the description:
  Part 1     Oscillator Section  
  Part 2     Wave shaper and AGC  
  Part 3     Microcontroller Section  

1. Oscillator Section

The oscillator follows the outline given in Part 1: Q1 and Q2 form an emitter-coupled oscillator whose combined emitter current is controlled by Q3. The control voltage is derived from the amplitude (Section 2) and forms a low-gain automatic gain control (AGC) that stabilizes the amplitude of the oscillation. Trim potentiometer P1 allows to adjust the overall amplitude to optimize detectability in the desired inductance range.

Q2 is mirrored by Q4, and the emitter current of Q2 (which also contains the oscillatory component) is equally found at the emitter of Q4. The resulting voltage drop across R2 is stripped of its DC component with C4. Q4 is primarily a means to draw the oscillation from Q1/Q2 with a high impedance presented to the oscillator core. C4 couples the oscillation into a conventional common-emitter one-transistor amplifier stage around Q5. R3 and R4 determine the DC operating point of Q5, and R6 stabilizes the operating point through negative DC feedback. C5 ensures that the emitter of Q5 is AC-coupled to ground. The AC signal, amplified approximately 20x, is drawn from the collector of Q5.

In extension to the principle schematic, the full schematic includes power supply bypass capacitors (C6...C9). A selector switch was provided to select different capacitors for the resonant LC tank. The selector switch also provides logic levels for the microcontroller to read the switch position. Larger inductors may cause significant transients when the switch is actuated while the circuit is powered, and these transients ar absorbed by the Zener diodes Z1 and Z2.

2. Wave Shaper and Automatic Gain Control

The signal from the collector of Q5 is split (C12 and C13) and fed into the wave shaper and the AGC circuit, respectively. The wave shaper is nothing more than a comparator with a square-wave output. The comparator also ensures that the output voltage swings from 0V to 5V, irrespective of the input signal amplitude. The comparator (U2) is a high-speed device (TLV3601) with rise and fall times and with propagation delays in the low nanosecond range. Minimum pulse width is specified as 1.25ns, which provides plenty of reserves toward higher frequencies. R16 and C25 form a weak lowpass filter (3dB cutoff at 700kHz) that, together with a ferrite bead in the input path, attenuates harmonics. Both inputs are biased to 2.5V from a shunt reference (Z3), and R11 with R14 adds a weak hysteresis of approximately 1.5mV to the comparator. The square wave output of U2 can be processed directly by digital circuit components.

Along the second path (C13), the signal is again stripped of its DC component (with R12) and rectified (D1). D1 together with R13 and C22 form a peak detector that is buffered with op-amp U1a. The output of U1a therefore carries the amplitude of the oscillator sine wave reduced by the forward voltage of D1 (not very relevant, because the forward voltage threshold acts on small amplitudes where the amplitude gain is maxed out anyway). From the output of U1a the amplitude can be read by the microcontroller. In addition, the amplitude is subtracted from a 2.8V reference point and amplified 10x (U1b). By using the output of the inverting amplifier U1b as the input to the oscillator current source Q3, negative feedback is established that allows to attenuate large-amplitude oscillations.

This section also contains the power supply. The circuit is insensitive to supply voltage variations from about 9V to 12V, and three, 18650 Li-ion cells (or a 12V wall adapter) are suitable to provide the supply power. The circuit draws less than 40mA. For the digital part, a 7805 linear regulator (U3) is used, and its input further decoupled from the analog section with R7 and D3. The decoupled almost-12V supply (designated 12VA) is also used for U1, which prevents unwanted feedback along the power supply loop.

3. Digital Section and Microcontroller

At the core of this section is a microcontoller (MCU) of the PIC18F series. It features a 16-bit hardware counter, which serves as the central part of a frequency counter. Although the microcontoller is capable of handling 10MHz and above, a frequency divider is provided to lower the input frequency -- this was considered for increased robustness of the counter. Two divide-by-two flipflop circuits with high-speed logic (ALS series, U4) reduce the maximum design frequency of 10MHz to maximally 2.5MHz. U5 divides the frequency by another factor of 8. The maximum frequency input to the MCU is now well below 500kHz, and the 16-bit counter would not overflow in a 100ms measurement interval.

One input to the MCU's built-in analog-to-digital converter is used to measure the amplitude of the oscillation (from U1a via R21 and C27). Two of the three selector signals from the LC tank capacitor selector switch are evaluated, and a pushbutton is also provided. The pushbutton, as well as the LED D4 have been provided "just because" with initially no dedicated purpose. A LCD is provided, and the CPU can be programmed in-circuit at the programming header CN3.

4. Microcontroller Software

In the early design stages, we used an oscilloscope to measure the frequency and calculate the inductance. The purpose of the MCU is to automate this task and display the inductance directly. To measure the frequency, the oscillator signal (specifically, the output of U5) is connected to the MCU's 16-bit timer/counter module TMR1. Another timer/counter, TMR0, is programmed to create a 100Hz reference signal from which the 200ms gate is derived. At the start of the gate period, TMR1 is reset. It counts the pulses at its input, and after 200ms, the value is read out. Due to the five divide-by-two stages in U4 and U5 and the 200ms gate, the timer value needs to be multiplied with 160 to yield the accurate frequency in Hz. At some point, we used the pushbutton to display the frequency, and the pushbutton has kept that function since.

We can now return to the LC tank frequency equation,

\[f = \frac{1}{2 \pi \sqrt{L C} } \]

and solve it for the unknown inductor L:

\[L = \frac{1}{(2 \pi f)^2 C } = \frac{a}{f^2}\]

The constants can be combined into a lump coefficient \( a \). This is important, because I based the computation on a 32-bit integer math library that I developed for high-speed applications. Of course, the use of floating-point math with, for example Arduino C, is entirely possible as an alternative approach, especially since there is no time-critical element in the software apart from the 200ms gate. With a 32-bit integer division available, the frequency scaling factor of 160 can be moved into the coefficient \( a\). Furthermore, \( a \) can be scaled to yield the inductance in units of 100nH. We now have

\[L = \left( \frac{1}{(2 \pi)^2 C } \cdot \frac{10^7}{160^2 \cdot 16^2} \right) \cdot \frac{1}{\hat{f}^2} \]

where C is given in pF and \( \hat{f} \) is the value read directly from TMR1, i.e., the frequency scaled down by 160, which is in turn divided by 16 (i.e., actual frequency in Hz, divided by 2560) to prevent numerical overflows. For the three capacitor values, we found \( a \) as

In addition to computing \( a / \hat{f}^2 \), formatting it and displaying it, the software also displays a raw value of the oscillator amplitude, which can be understood as a form of "confidence level", whereby smaller amplitudes allow a lower confidence in the accuracy of the result, because the oscillator produces only a low amplitude. In fact, when this value falls below a certain threshold (specifically, a value below 100mV at the ADC input), the software assumes that no inductor is connected. The LED (D4) was programmed to light up whenever the input threshold of the ADC is exceeded.

In in Part 3 of this article, we'll now cover the prototype and the final device.