A Compact ESR Meter with LED Display

If
you build or repair electronics equipment, an ESR meter is an essential
item in your toolbox. Of course you can buy one ready-made, but this
ESR meter is very easy to make and features a simple low cost LED
display for quick and easy testing of capacitors.
Introduction
Faulty
electrolytic capacitors are one of the most common problems encountered
with consumer electronics. Simply measuring the capacitance of the
suspect component often fails to identify a faulty part because it can
very much depend on the method used to make the measurement. However,
measuring the Equivalent Series Resistance (ESR) of a capacitor can
quickly and easily indicate if the part is faulty.
An ideal capacitor has zero equivalent series resistance. Typically, the higher the capacitance, the lower the ESR.
There are many ESR meter designs available. Some provide highly
accurate ESR measurements, but when a capacitor goes bad, its ESR value
usually changes dramatically. A meter that indicates the general range
of the value of ESR can therefore be used with confidence to
discriminate between good and faulty parts.
This design was inspired by a 2003 article in a Czech magazine (See
reference details at the end of this page). It used an 8-pin ATtiny15
microcontroller, a CMOS CD4094 shift register and a handful of
transistors to display capacitor ESR values on a series of LEDs. The
simplicity of the approach appealed to me, but the article was not
accompanied by any downloadable software. In addition, the ATtiny15 is
listed as an obsolete device by Atmel now, although at the time the
orignal article was written, a programmed device could be ordered from
the author. Still, I did not like my chances of getting one
after this length of time.
It also seemed to me that the circuit could be simplified without the
loss of any features. The original design used a number of extra parts
in an external “sample and hold” analog-to-digital converter yet the
ATtiny15’s own analog to digital converter (ADC) has its own sample and
hold function. The Czech design also used an unusual voltage regulator
chip which also appeared to be unobtainable. And if I opted for a
larger but similarly priced Atmel processor, I could do away with that
extra CD4094 shift register too. Hmmm...
Since it appeared I would need to reverse-engineer my own version of
the software for this design, I decided to combine this project with an
evaluation of high level language compilers. It is often claimed that
designing software with a high level language is faster than writing
assembler code, and many reference texts claim that such high level
language code is also easier to modify and maintain than my traditional
assembler software design approach. I decided to test those theories.
ESR Measurements
The
Equivalent Series Resistance (ESR) of a capacitor is an AC measurement
of a capacitor’s internal resistance measured in ohms. (Attempting to
measure ESR with a DC ohm meter is doomed to failure – The meter simply
charges the capacitor!) The ESR value depends on the design of
capacitor, the type and quality of its dielectric, the frequency at
which the measurement is made, and the temperature. The total impedance
of the capacitor includes Xc, the capacitive reactance of the capacitor
measured at that frequency (most measurements are made at 100kHz), and
Rs, the ESR value of that capacitor at that frequency.
Rs is the Equivalent Series Resistance (ESR) and
Xc is the impedance of capacitor C where Xc= 1⁄2πfC
Figure 1 : Equivalent series components of the measured capacitor
As capacitors age, their properties change. With electrolytic
capacitors in particular, the electrolyte dries out. The first
indication of this can be seen as changes in the value of the
capacitor’s ESR. Operation at high temperatures accelerates this effect
as does operation with high AC currents, the characteristics often
encountered in PC power supplies, for example.
Measuring a capacitor’s ESR accurately requires a high frequency AC
measurement, typically around 100 kHz, although many amateur meter
designs do not use this approach. Some designs feed a sine or square
wave oscillator with a low impedance output into a series combination
of the capacitor being tested and a small load resistor, typically 3 to
10 ohms. Such meters measure the resulting output voltage appearing
across the series resistor. This provides an approximate value for the
capacitor’s ESR although with very limited range and accuracy.
Figure 2 : Impedance of a typical capacitor – Capacitive reactance reduces
impedance until resonance and then ESR causes impedance to increase
An alternate approach is to use very short current pulses at a low
repetition rate. Typically, a 10uS pulse is used at a 1kHz pulse
repetition rate. The resulting voltage pulses measured across the
capacitor under test are divided by the charging current to give the
capacitor’s ESR. The low pulse repetition rate prevents the capacitor
charging up and preventing accurate measurements.
Also, if the voltage pulse is kept less than the 0.6V forward
conducting voltage of diodes and transistors, and since ESR values are
typically much lower than most surrounding resistors in a circuit, many
ESR measurements can be actually be made in-circuit, avoiding the need
to remove the capacitor first. The voltage pulse across the capacitor
under test is typically less than 150mV. With very large value
capacitors, the voltage pulse may rise to 400mV.
The main problem with this technique is that it is not very accurate
for capacitors smaller than 1µF. Such small capacitors charge more
rapidly with these pulses, making it difficult to measure the value of
the voltage pulse before the effect of charging takes over. For most
electrolytic capacitors, the parts which we are most interested in
testing this way, this approach is very effective.
The Design
Figure
1 shows the circuit diagram of the ESR meter. I managed to reduce the
parts count down to the ATtiny26 microprocessor, three transistors, and
a commonly available LP2951 regulator. In total, there are fewer than
30 components. This compares with around 40 in the original Czech
design, and over 70 parts in a well-known full-featured ESR meter
published in several Australian electronics magazines over the past
decade.
Figure 3 : Schematic of ESR meter
Power is supplied from a standard 9V battery. Alkaline batteries are
not necessary unless you are using the meter many times each day. IC2
(LP2951) regulates this to 5V required by the meter. As soon as power
is detected by the ATtiny26, the microprocessor then turns Q2 on to
keep Q3 and the regulator turned on. Each of the LEDs is briefly turned
on and off in sequence to show that the meter is operational and all
LEDs are working. Then the measurement cycle begins. The software keeps
the meter operating for about a minute, then Q2 is turned off, and the
meter is automatically powered down.
I originally planned to use the power-down feature on the LP2951 but
attempts to use it resulted in a small residual load current on the
battery after the regulator was powered down. This would have
considerably reduced battery life. As a result, the decision was made
to add a further switching transistor (Q3) to avoid the problem
completely.
In the measurement cycle, Q1, VR1 and R1 act as a current source. Q1 is
briefly turned on and off to send a short 10uS pulse of current
to the test capacitor. This is sufficient to allow the capacitor’s ESR
to be measured without charging the capacitor itself. The10-bit
ADC in the ATtiny26 is then used to measure the voltage produced by the
capacitor being tested in parallel with the 10 ohm resistor across the
input. The back-to-back diodes, the 10 ohm resistor and the 1k series
resistor to the ADC input provide some degree of protection for the
meter.
Because the measured ESR voltage is small, over-sampling was used to
extend the range of the 10-bit ADC measurement to 12 bits. The internal
2.56V voltage reference inside the ATtiny26 also increased the dynamic
range of the measurement. Finally, for very low ESR values which are on
the limit of even 12-bit ADC measurements, a further test is carried
out by the meter. This uses a longer duration pulse to detect the
charging of a large capacitor. It is only used to discriminate between
a short circuit and such large capacitors.
The meter continues to cycle through the measure-display process for 45
– 60 seconds, the exact time depending on the ESR value of the
capacitor being tested. Then Q2 is turned off, and the meter powers
down.
The Software
As I
mentioned, this design was also to be something of a test of a high
level language compiler. In this case, I used the widely available
BASCOM-AVR compiler to write the software very quickly in Basic. While
some might regard this approach as somewhat primitive in light of the
wide availability of C-language compilers, I prefer the readability and
ease of Basic over C. In any case, if I want a convoluted textual mire
of code, which is how I view C, I can always revert to assembler.
For all that, BASCOM presented a few limitations, the foremost being
its speed. It is not possible to generate a sufficiently brief current
pulse from the processor using Basic. Fortunately, BASCOM allows a mix
of assembler and Basic for just this reason. The problem that this
presented for me was that this mix of code was not described
particularly clearly (at least for me) either in the help files, the
BASCOM website, or in the various books available on BASCOM. That
includes those published in German, Polish and English. Fortunately,
with a little effort, I managed to muddle through to get everything
working.
The other limiting factor of high level languages is that their use is
usually accompanied by a heavy code overhead. Depending on the language
used, the particular commands required in the software, and the
subsequent libraries which must be loaded, this tends to make the size
of the final software significantly larger than the comparable software
written directly in assembler. With BASCOM, the final code runs out at
less than 1k bytes. The same code written in assembler would probably
take less than half of this. It’s hardly an issue in any case because
the ATtiny26 has 2kB of code memory, and the limit of the freeware
version of BASCOM used to write the software was 4kB, both providing
significant margins for this task.
The software, both source code and HEX files (used to directly program
the ATtiny26), are available for download at the end of this page.
Having benefited from the work of others who have made their software
available, I take some pleasure in doing the same. Of course, it does
allow others to point out all the mistakes in my software, but that’s
beneficial too. We’re all here to learn. So, feel free to add, correct,
amend, trim and otherwise revise the software to suit your own
requirements.
Which ATtiny26 Should I Use?
Some
suppliers list several types of ATtiny26. The two most commonly shown
are the ATtiny26-16PU and ATtiny26L-8PU. Of the many types available,
which is the best one to use for the ESR meter?
This
design uses the internal RC oscillator operating at its standard 8MHz
clock speed. The ATtiny26-16PU or the ATtiny26-8PU both operate at this
clock speed. The '16-PU' is the most common tiny26 part sold, and
probably the cheapest. It's made in a standard DIP plastic package, and
that was the one I used. However, the 8L-PU type should work fine too,
as far as I can see, although I've not been able to try it myself .
The ATtiny26L
has an extended low voltage supply range and should work just fine too,
although it should be operated from 5V as shown in the above schematic
if you chose to use it.
SMD versions are also available, and
should work fine. However, they are more difficult for me to use (I
don't have all of the necessary SMD tools) so I've avoid using them so
far. Maybe in my next design...
(Thanks to Pavel for asking this question)
Construction
The
prototype was built on a scrap of prototyping board. A small plastic
box was used to mount the board, the pushbutton power switch, and the
battery. I think it used to hold a pack of cards. The board was
hot-glued in place.. The front panel label was made using a laser
printer.
Figure 4 : Front panel for the ESR meter (Download is available below)
I used a socket for the ATtiny26 although the chip was programmed in-circuit via the usual Atmel six-pin connector.
Programming the ATtiny26
I used
PonyProg to program the chip. It avoids that “chicken and egg” scenario
with other 'build this programmer' articles and approaches which
require you to program a chip first for the programmer that you need to
program the same devices. Um…? PonyProg just requires an interface made
from a few passive components, and it’s very cheap to make. The one
downside is it requires you to use an elderly computer with a (really
old) parallel or RS-232 port.
After using this simple programmer for a year or so, I then built my
present USB-based programmer (The well-known USBasp BASCOM-compatible
design) so I could use it with the USB ports on my current PC. It also
works with Windows 7.
Along with programming the program memory of the ATtiny26, the fuse
bits of the device also need to be programmed. These configure such
things as reset and clock options. These should be set, as follows:
Testing
BEFORE
turning the meter on, adjust VR1 so that maximum resistance is in
circuit. Push the power button briefly to turn on the meter. Each of
the LEDs should now turn on and off in turn, the red LED staying on
until the end of this brief test.
Connect a 330 ohm resistor temporarily to the test socket and adjust
VR1 until the top LED (300 ohms) just begins to blink. Then disconnect
the test resistor. Short out the test clips and check that the red LED
blinks slowly.
Operation
Turn
the meter on, then connect any capacitor to measure its ESR. To be
safe, and to avoid possible damage to the meter, make sure capacitors
are discharged first. The meter can measure capacitors from about 330nF to 10,000uF.
After a very brief moment, one of the LEDs on the panel will light. The
table on the front panel of the meter indicates the expected result.
Disconnect the capacitor, and leave the meter to turn itself off in a minute or so.
Final Remarks
An obvious question remains: Did writing the software in Bascom save me any time and effort?
In the short term, probably not, because I had to take a bit of time to
learn to use the software. I also needed to figure out how to embed
some assembler code into the high level Bascom software because one of
the subroutines still had to be written in assembler because of the
processing speed required for that code. That all took quite a bit of
time to sort out.
The limited performance of the simulator provided in Bascom also proved
to be a problem. Unlike similar systems, it lacked some expected
functionality, and when it was used, it was surprisingly slow. I
quickly avoided testing software with it and used the target hardware
directly, which was probably preferable anyway. Despite these issues,
many of the initial tests with the software went much more quickly and
with fewer errors than is usually the case with assembler.
Despite those hurdles, I enjoyed writing code with Bascom. It felt
easier to use than my usual assembler approach, so I plan to write some
more of my software using Bascom. Whether it will actually save me any
time is hard to predict. I suspect that being able to write code faster
simply means I’ll have more opportunities to make new and exciting
mistakes which will then take me longer to find and fix!
References
1. Milos Zajic, “Tester kondenzatoru – meric ESR”, Prakticka elektronika – A Radio, 02/2003 (p 20 – 22)
Downloads:
Software (includes Bascom source code and compiled HEX files): Click here to download software
Front panel artwork: FrontPanel
Want to go back to the main page? Click
here to
return directly.