ATMEGA328 LCR METER + FREQUENCY METER
ATMEGA328 LCR METER: For a while, I’ve been contemplating creating an LC meter because my current multimeter lacks the capability to measure inductance accurately. Even though my multimeters can measure capacitance, they struggle with precise readings for small capacitance in the range of a few pFs.
While there are plenty of resources available on constructing LC meters with PIC MCUs (such as these: 1, 2, and 3), there is a scarcity of instructions on building one with an ATmega MCU, despite the fundamental principle being virtually the same. Consequently, I decided to document the process of creating an LC meter with an ATmega328p processor and Arduino libraries.
A standard LC meter essentially functions as an LC oscillator with an extensive range. The additional inductance or capacitance alters the output frequency of the oscillator when measuring an inductor or capacitor. Depending on the measurement, we can compute the inductance or capacitance by analyzing the frequency change.
The diagram below illustrates the comparator-based LC oscillator I employed in the LC meter. The oscillator section is relatively straightforward. Most other systems I’ve encountered use the LM311 comparator. However, for this application, any comparator capable of oscillating up to 50 kHz should suffice. I had some spare LM339s on hand, so I incorporated them into the oscillator circuit.
Diagram:
On pin 1, a 3K pull-up resistor should be used, and the feedback resistor should be 100K rather than 10K.
Because we’re really measuring the oscillator’s frequency, we can make a frequency metre out of the same circuit for essentially no extra money. A reed relay is used to switch the measurement from LC to frequency mode, as shown in the circuit above. The second comparator in the schematics above acts as a Schmitt trigger, conditioning the input waveform to improve the accuracy of the frequency measurement. The frequency output from the first comparator is simply fed via the Schmitt trigger when in LC mode. The frequency of the output is determined by:
\[f_0=\frac{1}{2\pi\sqrt{LC}}\]
where
\[L=L_0 + L_{measured}\] and
\[C=C_0 + C_{measured}\]
Choosing a high-precision L0 and C0 improves the meter’s accuracy.
The MCU side of the schematics is as follows:
This circuit can measure inductance across a wide range of values, from a few NH to a few Henrys. I’ve found that it works best for capacitance measurements ranging from a few pF to tens of nF. If the capacitors have a high ESR rating, you may be able to measure significantly bigger capacitors. However, the range limit in capacitance measurement should not be a concern because the precision in the pF range is what matters most.
For the frequency measurement, I used this frequency library. The display is updated every second by default. This setting yields the most precise results. You can easily reduce the update interval, but the measurement precision will suffer.
This project’s Arduino code may be found here (LCFrequencyMeter.zip). If you are using the Arduino IDE instead of the NetBeans IDE, you may need to change the included header files. Please review my prior article on this subject for more information.
In capacitance measurement mode, the non-load reading is utilised to calculate stray inductance (if C0 is accurate), which is then used to compensate for capacitance measurements. In the inductance measurement mode, we assume L0 is accurate, and we utilise the non-load reading (by shorting the test leads) to calculate stray capacitance, which is then used to compensate for inductance measurements.
When using this metre to measure a known 2.22nF capacitor, the capacitance reading looks like this:
The LC metre is seen in inductance mode, measuring a small inductor in this image: