You are on page 1of 5

projects instrumentation

2-Pound RLC Meter


impedance measurement using a sound card

Martin Klaper and Heinz Mathis

Is it possible to make an RLC meter for less than two pounds? In this article the authors answer this
question with a resounding ‘yes’ in the form of a simple and compact circuit that will enable you to
make RLC measurements rapidly, accurately, and, above all, cheaply.

For many years the two authors have Elektor [1]. There we described how to (complex) impedance. The alternating
used a Marconi RLC bridge. To use this make an ECG (electrocardiogram) re- test voltage can be provided by an out-
device two controls are adjusted until corder using a sound card, and it is a put of the sound card. Could we im-
a meter reads ‘null’, and then the value relatively small step from that to the plement all of this on a PC? After a lit-
of the connected resistor, capacitor or idea of measuring impedance using a tle contemplation, soldering and pro-
inductor can be read from the settings sound card. gramming, the answer turned out to
of the controls. It is also possible to use In outline, this is how it works: us- be yes.
the instrument to measure the loss fac- ing the two input channels of a stereo Almost any PC can be used for this
tor tan δ and the Q (quality) factor. sound card we can measure two volt- project, even a dusty old 500 MHz ma-
Not every household is lucky enough to ages simultaneously. A resistor in se- chine. There is even no need to open it
own such an instrument or an expen- ries with the device under test (R, L or up, as we only need access to the ex-
sive RLC meter; PCs and sound cards, C) is used to convert the current flow- ternal connections of the sound card.
however, are ubiquitous. And it turns ing through it into a voltage. If an al- Of course, we cannot guarantee that
out that these can be used to make ex- ternating voltage is applied to the de- every PC will work, but we have tried
cellent measuring instruments, as one vice under test and the resulting cur- a range of machines, desktop and lap-
of the authors has already described in rent is measured, we can calculate its top, running Windows XP and Vista,

64 elektor - 6/2008
and all have worked perfectly. would be possible to assume that the
Besides the PC very little is required: Ur voltage applied to Rref is simply propor-
Line Out
build the tiny circuit described below, (R) R1 R ref
tional to the voltage that has been out-
connect it to the PC, and run the soft- put by the program to the sound card.
U rm
ware provided. In practice, however, sound cards have
The hardware consists of just two re- Soundcard a certain latency which means that
sistors and a dual operational ampli- there is a delay between the program
fier: total cost well under two pounds. Line In A1 sending a signal to the sound card out-
(R)
The circuit can conveniently be built put and its actually appearing there
on perforated board or on a bread- (see our test of sound cards elsewhere
board, and then, low-cost impedance in this issue). Using two inputs on the
Ux
meter in hand, you can test inductors, sound card gets around this problem
Line In
capacitors and resistors to your heart’s (L)
A2
Zx in an elegant way.
content. The circuit gives astonish- R1 references the output of the sound
ingly good accuracy: its results have card to ground. The two operational
been checked against a much more 080055 - 11 amplifiers, each with a gain of one,
expensive RLC meter on the authors’ act as buffers with a high input imped-
bench. ance and a low output impedance. The
Figure 1. Block diagram for method A.
sinusoidal voltage Ur (from ‘line out’),
which is applied to the test circuit, is
Impedance measured on the right input channel.
Impedance (from the Latin ‘impedire’, ing phase lag and loss factor. Method The voltage across the device under
to hinder, hence ‘impediment’ etc.) is B goes by the delightful name of ‘ap- test, Zx, is measured using the left in-
essentially the degree of opposition to proximation of the characteristic curve put channel. The operational amplifier
current flow. It is a complex quantity, using a variable test frequency and the used is a type LM358, although any
that is, it has real and imaginary parts. method of least squares’. similar device would do equally well.
The impedance of a pure resistor has And now to the gory details. The supply voltage for the opamp is
zero imaginary part, although the im- relatively low at ±3 V, in order to pro-
pedance of a practical resistor (and in tect the sound card input from dam-
particular a wirewound resistor) will
Method A age in the event of something going
have a small imaginary part. Ideal in- One of the two output channels of the wrong.
ductors and capacitors have a purely sound card drives a voltage divider, The accuracy of the measurements
imaginary impedance, but again real consisting of a reference resistor Rref made depends on the accuracy of ref-
inductors and capacitors have a small and the device under test Zx, with a erence resistor Rref. It is therefore very
real part to their impedance along with sine wave (Figure 1). The second important to know the value of this re-
a (hopefully dominant) imaginary part. output of the sound card is unused. sistor as accurately as possible. Rref
This deviation from the ideal gives rise It could be used in an enhanced ver- can be changed to change the meas-
to power dissipation or losses in the sion of the meter to allow for switching urement range: for best results the
component. For this project we imag- ranges automatically (in the current value of Rref should be comparable to
ine a real component to comprise an version the range has to be changed the impedance of the device under
ideal component in series with a pure manually). The two input channels test. For added convenience it would
resistance, the latter representing the measure the two voltages on the volt- be possible to provide for automatic
losses. At a specified frequency an im- age divider, which allows the ratio range switching using the spare out-
pedance can be expressed in polar co- between these two quantities to be put channel of the sound card.
ordinates or in Cartesian coordinates: measured at any instant. In principle it
The concept
Z = |Z|∠θ = R + jX The ratio between the amplitudes of
where |Z| = √(R2 + X2) and θ = arctan R the voltages dropped across the ref-
(X/R) Line Out R1
R2 +3V
erence resistor and the device under
test, and the phase angle between
1k
10k

IC1 = LM358

Here Z is the (complex) impedance, 8 these voltages, are the keys to comput-
IC1
measured in ohms, |Z| is the magni- Ur (t)
1
3
4
ing the impedance of the device. The
R IC1.A
tude of Z, and θ is the argument of Z. Z Line In
2 series combination of the reference
has real part R and imaginary part jX resistor and the device under test is
–3V
(see also the formulae in the accompa- driven by the signal Ur, which is one
nying box). Ux (t)
5 output of the sound card; a voltage is
Below we will describe two ways L
7
IC1.B
6 R
dropped across the device under test
of measuring impedance, which (al- Line In Zx
whose amplitude and voltage depend
though both inspired by the previous Ux
jX
on its impedance. Our first approach
article in Elektor mentioned above) works as follows: we measure using
have been developed independently of a constant-frequency stimulus volt-
080055 - 12
one another. Method A is an adaptive age (1250 Hz for example) and take the
linear combiner using a least-squares measured signal at Ur into an adaptive
method which makes a measure- Figure 2. The hardware for method A consists of just a dual linear combiner implemented in soft-
ment at constant frequency, calculat- opamp and two resistors. ware. The combiner employs two vari-

6/2008 - elektor 65
projects instrumentation

where Urm = Ur – Ux.

A Ux[n] - N/ x[n] "desired signal" Now let Urm = A × sin(ωt) and Ux = A


Z 2
Ux (t) D × sin(ωt + ϕ), and we can write Ux =
w0A × sin(ωt) +w1A × cos(ωt).
A Ur[n] Hn[Z] LMS
D - N/ algorithm Figure 3 shows the adaptive linear
Ur (t) Z 2
combiner. Ur (from ‘line out’) is modi-
w0[n] w1[n] fied using the weights w0 and w1 so
R ref that it is as close as possible to the de-
sired signal Ux; e(n) is the computed
y[n] error.
Zx
The impedance of the device under
e[n] = x[n] - y[n] test is then given by
Adaptive Linear
Combiner Z = Rrefw0 + jRrefw1.

080055 - 13 Software
The program that generates the sine-
wave signals, reads back the signals
Figure 3. Functional diagram for method A.
on the line-in input, and calculates the
impedance of the device under test is
written in Java.
able weights, w0 and w1, which can be values of the weights w0 and w1. At The user interface shows the measured
thought of as equivalent to the poten- each time step it adjusts the weights values as well as a display of the volt-
tiometers in an analogue RLC bridge. and then recomputes the real and im- ages across the reference resistor Rref
The program adjusts the weights until aginary parts of the resulting signal and the device under test Zx. The LMS
the voltage at the output of the com- and thence the resulting error. The ad- algorithm can be replaced by a differ-
biner matches that across the device justment is a small step in the direc- ent algorithm (see under the ‘Settings’
under test as accurately as possible in tion which reduces the error as quick- tab). The algorithm must be derived
amplitude and in phase. By ‘as accu- ly as possible (the ‘method of gradient from the class Alg and implement the
rately as possible’ we mean that we descent’), seeking the minimum of the determine() method (see Figure 4).
try to minimise the mean squared dif- error function like a skier who always This allows a variety of different ap-
ference between the two signals. The chooses the steepest downhill route proaches to be compared: for example,
complex impedance of the device un- with the aim of reaching the lowest a second approach, which uses a vari-
der test can then be determined from point of a valley. able frequency, is described below. It
the weight values w0 and w1. When the error e(n) falls below a pre- would also be possible to implement
The system thus works in a very simi- set threshold the execution of the algo- the classic three-voltmeter method.
lar fashion to the authors’ trusty Mar- rithm terminates, and the weight val- The software architecture is illustrated
coni bridge, with the adjustment of the ues are taken as correct. Now we can in Figure 5.
(virtual) potentiometers under soft- use them to compute the impedance
ware control. we are trying to measure. The sound card
From the block diagram in Figure 1 we The sound card samples the incoming
The algorithm have: signals 44100 times per second, and
We use the so-called LMS (least mean we allow a choice of test frequency
squares) algorithm, which is an itera- Ux = IRref × Zx = Urm / Rref × Zx from 1000 Hz, 1250 Hz and 2200 Hz.
tive approach to finding the optimal The sound card must have a stereo

Alg
{abstract} Line Output Digital Signal User interface
Processing (GUI)
determine() Sine wave (DSP)
generator

Line Input

NewAlg
determine() Software System
080055 - 14
080055 - 15

Figure 4. Deriving a new algorithm. Figure 5. Block diagram of the software.

66 elektor - 6/2008
About the authors
Martin Klaper studied Electronic Engineering at the Swiss Federal Institute of Technology in Zurich, graduating in 1977. He then worked in devel-
opment for 20 years at Crypto AG. From 2000 to 2005 he lectured in computing and telecommunications at the Solothurn University of Applied
Sciences, and currently he lectures at the School of Engineering and Architecture in Horw, near Lucerne. He is also a keen radio amateur (call
sign HB9ARK) and is particularly interested in
the ideas behind software-defined radio.

Heinz Mathis studied Electronic Engineering


at the Swiss Federal Institute of Technology
in Zurich, graduating in 1993. After several
years working as a development engineer
in industry at various companies in Switzer-
land and in Britain, in 1997 he returned to
the Swiss Federal Institute of Technology to
become a research assistant. He received
his doctorate in the field of signal process-
ing in 2001 and went on to work for u-blox
AG developing GPS receivers. Since 2002
he has lectured on mobile communications
at Rapperswil University of Applied Sci-
ences. His main interests are in the fields
of high-frequency engineering and digital
signal processing for mobile radio and GPS
applications.

input (watch out: some laptops only dll) which must be kept in the same switches between a simple meter
have a single input channel). directory. The program is run by dou- mode and an expert mode. In simple
There are two important points to ble-clicking on rlc.jar. mode the program just displays the
note: if Ur has a very high amplitude, Figure 6 shows the graphical user in- measurement result in large charac-
it may distort. Although the actual am- terface. Clicking on the relevant tabs ters so that it can easily be read from
plitude of Ur does not enter into the
final calculation, it must nevertheless
be a pure sinewave. It is also possi-
ble to overdrive the input amplifiers on
the sound card, which will also lead to
distortion.
The program is able to display the in-
put waveforms to allow the user to
check for distortion. The relevant lev-
els can be adjusted using the PC’s au-
dio mixer settings. For a more precise
measurement of the degree of distor-
tion, connect an oscilloscope (or, even
better, an audio spectrum analyser). It
is also essential to ensure that the bal-
ance between left and right channels
is set exactly in the centre.
The software oscilloscope display
gives a good demonstration of the
time relationship between the voltage
across a capacitor or inductor and the
current flowing through it.

Installation and operation


The RLC meter software can be down-
loaded from the Elektor website [3].
It is also necessary to have the Java
runtime environment [2] installed.
Then it is a simple matter of unpack-
ing the software and running it. The
Java program consists of three parts,
Figure 6. How the software displays its results on the screen.
(rlc.jar, swt.jar and swt-win32-3236.

6/2008 - elektor 67
projects instrumentation

voltage divider part from the above cir-


cuit using a series resistor R. If we con-
R R
struct a symmetrical T-network it has
10k 10k
the advantage that the circuit is sym-
R R metric with respect to the inputs and
10k 10k
outputs of the sound card. This method
also has the advantage that it can be
used with single-channel sound cards,
Z Rin Rin
Uout ,L Uout ,R although using two channels helps to
Uin,R
reduce the noise in the measurement a
little. We thus end up with the simple
resistor network shown in Figure 7.
Rin is the input impedance of the sound
Soundcard
card, which can be determined from
the datasheets of the devices used.
0800555 - 17
The details of the derivation of the for-
mulae for calculating the unknown im-
pedance are available in a supplemen-
Figure 7. The hardware for method B consists of just four resistors.
tary document that can be downloaded
from the Elektor website.
The task for the software in the me-
a distance. The series equivalent cir- ter is now to measure the amplitude
cuit is also shown graphically. In the of the signal levels at the inputs to the
Phase shift ϕ:
case of a resistor the ohmic value is sound card. The measurement is car-
ω  also displayed as the corresponding ried out at a range of different audio
ϕ = arctan 1  colour code. frequencies. If the unknown imped-
ω  It is possible to make single measure- ance is purely resistive the amplitude
 0 
ments or continuous measurements: will exhibit no frequency dependence,
Component characterisation: the latter is particularly useful when whereas for an inductive or capacitive
tuning components such as coils. load the amplitude will increase or de-
ϕ = 0: pure resistance
In expert mode the display shows the crease (respectively) with increasing
ϕ < 0: capacitor input signals oscilloscope-fashion on frequency.
ϕ > 0: inductor the display, along with some inter- For each of the three quantities R, L
esting intermediate values computed and C the software calculates a nomi-
by the LMS algorithm. Three different nal value which minimises the squared
Impedance Z: measurement frequencies are availa- error over the set of test frequencies
ble. The ‘Settings’ menu allows the se- used. The corresponding residuals (i.e.,
Z = ( ω0 ⋅ Rref )2 + ( ω1 ⋅ Rref )2 lection of a different sound card if more the normalised distances between the
than one is present, and it is also pos- measured amplitudes and the theoreti-
sible to switch to a different measure- cal amplitudes for the calculated com-
Real (R) and imaginary (XL or XC) parts: ment algorithm (if one has been imple- ponent value) are also computed. The
L mented) for comparison purposes. value which leads to the smallest re-
As mentioned above it is important to sidual is taken as the correct one and
know the value of the reference resis- is displayed as the result, along with
tor Rref accurately, as the accuracy of its corresponding unit.
the whole measurement depends on it. (080055-I)
X L  Z –sin( K ) Z Ideally we should aim for an accura-
cy of 1 % or better, and if possible it is
J
worth measuring the value of the resis-
References and
R
tor before use with a precision bridge. Internet links
R  Z –cos( K )
It is also important to use a film resis- [1] Martin Klaper, ‘ECG using a Sound Card’,
tor for Rref rather than a wirewound Elektor October 2006.
Resistor: R=Z
type, as the latter will have significant
http://www.elektor.com/magazines/2006/oc-
inductance. Accurate measurements of
tober/ecg-using-a-sound-card.58566.lynkx
Inductor: reactance from 0.01 Rref to 100 Rref are
possible. It is a good idea to arrange [2] Java compiler and development environ-
X the circuit so that different resistors ment (JRE and JDK): the Java Runtime Envi-
L= L ronment (JRE), version 5.0, is required to run
2π f can easily be substituted for Rref to ex-
the program, and the J2SE development kit
tend the range of the instrument. (JDK), version 5.0, is required to modify and
Capacitor: compile the program.

1 Method B http://java.sun.com/javase/downloads/in-
C= An even simpler approach, suitable for
dex.jsp
2π f ⋅ Z
measuring an unknown impedance Z [3] Software download: www.elektor.com;
using a sound card, is to use only the month of publication

68 elektor - 6/2008

You might also like