An Even Better LC Meter Based on the AVR ATTINY861

An improvement over “A Pretty Good LC Meter.”  Enhanced capacitance self calibration, accurate operation without precision components, and only one micro controller.
Downloads
Download or view the WINAVR main source file: lcm.c
Download the complete package including the LCD library: Even-Better_LCM.zip (LCD Library provided with Peter Flurey’s permission)
Download Gerd Sinning’s: LCcalc tools for Windows (See bottom of page).
Find updates at http://www.projects.cappels.org
Introduction
If this picture (above) looks a lot like the Pretty Good LC Meter also on this web site, that’s because its the same meter, but with some significant improvements. At this point, its a good idea to read the  Pretty Good LC Meter page because the rest of this page is based upon the Pretty Good LC Meter, and the Pretty Good LC Meter page explains how to build the meter. I have left the Pretty Good LC Meter page intact because it is a complete project and if one wants to build an LC meter based on the ATTINY2313 or AT90S2313, this is a very good project for that.
After building and using the Pretty Good LC Meter for a few months, I came to understand some ways in which it could be improved.  Here is what I corrected or improved upon:

• Improved accuracy at higher capacitance.
• Capable of accurate operation without precision components.
• Reduced drift of capacitance accuracy.

lc meter top
To do all these things, I need more flash memory for program space to perform computation. The flash in the ATTINY2313 of the original design was full with the basic LC meter program, so the first order of business was to get a controller with small footprint that has lots of flash – that turned out to be the ATTINY861 -8K in a 20 pin DIP. Oh, but look: there is no UART in the ATTINY861, so in order to send the display information to the LCD display controller, I would have to bit-bang a UART in C, but if I was going to go to that much work, why not bite the bullet and merge the LCD controller function into the ATTINY861. I had written a controller for the 2X16 LCD in assembler, and it was kind of messy, so I wasn’t looking forward to doing it in C -at least not while I am still so new to C. That’s was when I remembered Peter Fleury’s C libraries.
A couple of clicks took me to Peter’s web site, http://homepage.hispeed.ch/peterfleury/, and another click took me to the page with his AVR software http://homepage.hispeed.ch/peterfleury/avr-software.html. Looking though the offerings – AVR-GCC Source Examples, AVR-GCC Libraries,  an AVR Studio compatible Boot Loader, and a test program for his AVR Starter Kit. A couple of these look interesting to me, but it was the LCD library that I was after, so I downloaded the zip file containing the LCD library and had a look. The HTML documentation was very clear and direct -it seemed that I could make use of the libraries by merely placing the library and header files in the folder with the main program and then just calling the functions per the examples in the documentation.  I tried it out, and you know what? It’s just as simple as the documentation said it would be. The LCD Library and header files are included in the zip file, Even-Better_LCM.zip, which contains the complete built project. To get the complete LCD Library, including the documentation, please visit Mr. Fleury’s site, http://homepage.hispeed.ch/peterfleury/.
The LCD library’s default setup generates the code to drive displays using the Hitachi HD44780U controller based displays, but if you have a display that uses the Samsung KS0073 controller, there is a switch that causes code for that controller to be generated.
I had picked up an extra 2 line x 16 character controller from a small surplus shop in Bahnmo Plaza in Bangkok just a few days before starting this project, so I quickly built up a small circuit board with an ATTINY861 and the surplus 2×16 display, and since the power and ISP connections on the ATTINY861 are different from those on the ATTINY2313/AT90S2313 and the AT90S1200, I wired up a jumper socket with an ISP programming plug (Lazy ISP Socket Adapter). Pretty quickly, I had my name on the surplus LCD (250 Thai Baht or US$7.50 well spent). . I ran some wires from the original “Pretty Good LC Meter” to the breadboard so I could use the osciallator already on the original meter, and I was ready to begin re-writing the ATTINY2313 C code for the ATTINY861.
The task of rewriting the code cosisted mainly of getting the timer and counter working on the ATTINY861, and after that, writing the new calibration and zeroing routines.
A couple of months after finishing the Pretty Good LC Meterr, I bough several 1% film capacitors from Digikey for the purpose of verifying the accuracy. Up until then, the only precision capacitors I had was a bag full of 1000 pf 1% polycarbonate capacitors. After all, how many capacitors can you put in series and parallel combinations before the parasitics generate an uncertainty approaching 1%? Running though the precision capacitors from 1000 pf through 0.47 uf, I saw that above about 0.1 uf, the errors became pretty large. This was a puzzle until I remember reading a paper that Chris Krah had sent to me, in which he analyzed this oscillator and showed the relationship between accuracy of oscillator and the Q of the circuit. I ran his formula and it showed that the low Q of the 1 millihenry inductor I was using for the capacitance measurement accounted for nearly all of the error.
Lc meter
Improved accuracy at higher capacitances.
The 1 millihenry inductor that I had been using to measure capacitance was selected to be precisely 1.00 millihenries as measured on my old B&K Precision 875A. The only problem is that its series resistance was 14.8 Ohms (Coincidentally, I had bought a bag of these inductors at Bahnmo Plaza in Bangkok at the same little surplus shop at which I had bought the LCD). 14.8 Ohms is ok for a power supply choke, bu it was  pretty poor for an inductor to be used in a resonant circuit.  The immediate problem was solved by selecting a high permeability toroid core from my available stock, and it worked out that I could get very close to 1.0 millihenries with a little bit of fiddling around. Over the following weeks, I noticed that a capacitor that I measured at night read very differently the next morning. Obviously the high permeability ferrite material is (typical of high permeability materials) variable with temperature.
Reduced drift of capacitance accuracy
The solution to this problem that revealed itself after fretting over the problem for some weeks, was to put a stable 1000 pf reference capacitor (remember, I have a whole bag full of 1000 pf poly carbonate caps) across the inductor. When zeroing and auto calibrating he meter in the capacitance mode, there is only the 1000 pf polycarbonate capacitor and stray capacitance across the inductor.  While one could use a 1000 pf precision capacitor,  knowing the stray capacitance, especially when test leads might or might not be used, was a problem. I came up with a way to program the total reference capacitance from the front panel, and have that stored in the ATTINY861’s on-chip EEPROM as a calibration parameter.
During the zero/autocalibrate cycle in the capacitance measurement mode, the resonant frequency is measured, and based on the capacitance stored in EEPROM, the inductance of the approximately 1 millihenry inductor is calculated. This calculated inductance is then used to calculate the capacitance of the capacitor under test when the zero/calibrate cycle is over. In this way, a drifting inductor is automatically compensated for, providing that the capacitor is stable.
Capable of accurate operation without precision components
Recall that the value of the reference capacitor that is used to measure the inductance used to measure capacitance in the capacitance measurement mode is programmed from the front panel. The value programmed into the EEPROM  represents the total reference capacitance, 1012 pf as an example when using a 1000 pf reference capacitor with 12 pf of stray capacitance. If, instead of programming the actual capacitance into the EEPROM, a value that causes the minimum error when measuring capacitance can be used. This is the way I used it. I adjusted the reference capacitor value to obtain a acceptably low error when measuring a known capacitor.
Similar to the case of the reference capacitor for capacitance measurement, the value of the nominal 10,000 pf reference capacitor used for inductance measurement, is also entered in EEPROM as a calibration parameter from the front panel. As with capacitance measurement,  it is not necessary to  use a precision  reference capacitor if you have an accurate inductor with which to calibrate the inductance reference capacitance value. In my case, I used a 1% film capacitor so I would be confident of my measurements of high Q coils, but modified the value slightly to obtain minimum error over a range of inductances from 1 microhenry to 1 millihenry.
In the case of inductance measurement, a stray capacitance of 10 or 20 pf would be insignificant compared to the 10,000 reference capacitances, so using a precision reference capacitor would be enough to assure accuracy, and since the inductance measurement would not have to be measured, there is no need for access to a precision inductor with which to calibrate the meter.
With the ability ot change the value that the firmware uses as the value of the reference capacitors for capacitance and inductance measurement, it is possible to build an accurate meter that does not incorporate accurate components into the design, provided that one has access to precision components to calibrate the meter to.
 
For more detail: An Even Better LC Meter Based on the AVR ATTINY861


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top