This is only a preview of the April 2023 issue of Practical Electronics. You can view 0 of the 72 pages in the full issue. Articles in this series:
|
Circuit Surgery
Regular clinic by Ian Bell
Electronically controlled resistance – Part 8
T
his month, we conclude our
series on electronically controlled
resistance with a look at using digipots to control active filter circuits. Like
previous articles, we will discuss general circuit design issues and approaches
to simulation using LTspice. Filters are
a large and complex area of electronics,
so we will start with some general background before discussing digipot circuits.
Gain
Gain
Low pass
High pass
Frequency
Gain
Frequency
Gain
Bandpass
Bandstop
Filter basics
A filter is a circuit which passes certain
frequencies and rejects others. That is, the
gain is designed to be relatively high over a
range of wanted frequencies (the passband)
and low for frequencies outside this range
(the stopband). There are four basic classes
of filter, referred to as ‘bandforms’, which
are shown in idealised form in Fig.1. These
are graphs of the filter’s frequency response
– that is, plots of gain versus frequency.
Low-pass filters let low frequencies through
and block high frequencies. High-pass filters
let high frequencies through and block low
frequencies. Bandpass filters let a specific
range of frequencies through. Bandstop
filters reject a specific range of frequencies.
There are few other bandforms forms
beyond these basic classes. A notch
filter is a bandstop filter with a very
narrow stopband, which can be useful for
rejecting a specific unwanted frequency.
A comb filter has multiple, regularly
spaced stopbands and passbands. There
are also ‘all pass’ filters which have
constant gain, but a specific phase shift
response with frequency.
The idealised (so-called ‘brick wall’)
filters in Fig.1 cannot be implemented –
it is not possible to have an infinitely fast
transition from passband to stopband in a
real circuit, so the transition occurs over
a range of frequencies. Furthermore, the
gain in the passband may not be constant
(as it is implied by Fig.1) and the stopband
gain will not be either zero (complete
rejection) or constant at some low level.
Fig.2 shows a low-pass response with
various features that occur in real circuits.
On filter response plots the gain or
attenuation is usually expressed in decibels,
which is a logarithmic scale. For voltage
46
Frequency
Frequency
Fig.1. Basic filter bandforms.
gain A the value (in decibels,dB) is given
by: 20 × log10(A). The (horizontal) frequency
axis of the graph is also usually logarithmic,
with the scale marked in multiple-of-ten
steps, referred to as ‘decades’.
Response types
There are various filter response types
available named after their related
mathematics, such as Butterworth, Bessel
and Chebyshev filters. The features shown
in Fig.2 vary with different response
types and there is a trade-off in terms
of desirable features. For example,
Butterworth filters have maximally flat
passbands with a relatively slow change
of gain near the cut-off, while Chebyshev
filters have significant passband ripple,
but their gain decreases more rapidly
near the cut-off.
For an ideal filter, the transition from
passband to stopband occurs at a single
frequency. For real filters the transition from
passband to stopband occurs over a range
of frequencies so we need to specify exactly
what we mean by ‘cut-off frequency’. For
a flat passband the cut-off is often defined
as the frequency where the filter’s gain is
–3dB with respect to the passband gain.
This is the point where the output signal has
half the power it has in the passband. For
filters with ripple, the cut-off frequency is
usually defined as the frequency where the
response has dropped by an amount equal
to the ripple size relative to the maximum
passband gain (as seen in Fig.2).
Gain/dB
Pass band
Pass band ripple
Passband
gain
Transition region
Roll-off gradient
in dB/decade
Stop band
Stopband
gain
Stopband ripple
Cut-off frequency fc
Stopband frequency fS
Frequency f
(log scale)
Fig.2. Features of filter frequency response curves.
Practical Electronics | April | 2023
Fig.3. Low-pass response for various Q values.
The slope of the frequency response in
the transition region/stopband (see Fig.2)
indicates how quickly the filter’s gain
drops as the frequency moves away from
cut-off. For many filters, at frequencies
well into the transition region/stopband,
the response tends to decrease as a
straight line when plotted on a graph
of decibels against log frequency. The
slope is measured in dB per decade and
is called the ‘roll-off’. The roll-off may be
different (and changing) near the cut-off,
but the term usually refers to ultimate
roll-off, at a frequency sufficiently far
from the cut-off.
The ultimate roll-off is determined
by the order of the filter, the higher the
order the faster the falloff. A single RC
filter is first order and rolls off at 20dB/
decade, while an N-th order filter rolls
off at 20 × N dB/decade. The order of
the filter determines the ultimate rolloff, but the response type (Butterworth,
Chebyshev and so on.) determines the
shape of the response near the cut-off.
Q – quality factor
and bandstop filters are often required
in radio circuits.
For low-pass filters we typically
require relatively low Q values because
higher Q values result in a sharp peak
around the cut-off frequency (see
Fig.3). Usually, we would not want
this peak to be very high. The situation
is the same for high-pass filters. For
these filters the damping factor (ζ =1/
(2Q)) is often used instead of Q as it is
perhaps more intuitive However, the
reciprocal relationship means they are
fundamentally the same thing. Higher
damping results in a slower, smoother
transition from passband to stopband.
The properties of filters are related to
resonance – the tendency of some systems
to respond at greater amplitude when
applied oscillations match the system’s
natural frequency of vibration. The
peaks seen in Fig.3 occur at the resonant
frequency. The resonant frequency is a
‘natural’ property of the filter, or to put
it another way, fundamentally related to
the mathematics of the filter’s function.
The cut-off frequency is effectively
arbitrarily defined, so they are not the
same thing.
The Q, or ‘quality factor’, of a filter
determines the response type (shape).
Fig.3 shows the response of several
second-order low-pass filters with
Frequency scaling factor
different Q values. The responses are
For a particular response type, order
the same at frequencies a long way from
and definition of cut-off frequency (fc)
cut-off (both high and low) but are very
there will be a fixed relationship
different around the cut-off point.
between the resonant frequency (f0) and
For bandpass filters, Q is the ratio of
cut-off frequency, which can be
bandwidth relative to centre frequency. If
expressed as a frequency scaling factor
Electronically
Resistance –(FPart
8
a band-pass
filter has aControlled
centre frequency
s), such that:
of f0 and a bandwidth of fb the Q factor
𝑓𝑓! = 𝐹𝐹" 𝑓𝑓#
is given by Q = f /f . High-Q bandpass
0
b
Practical Electronics | April | 2023
𝐴𝐴 = 1 +
𝑅𝑅$
𝑅𝑅%
The scaling factors are typically, but
not always, in the range 0.2 to 2. For
Butterworth filters with the cut-off defined
as –3dB, the frequency scaling factor is 1.
We have discussed frequency response
in detail, but filters are also characterised
in terms of their phase response (how
phase shift varies with frequency). Phase
shift is a measure of delay relative to the
cycle time at the frequency of interest and
ideally increases linearly with frequency
– this implies that the absolute delay time
is equal at all frequencies. Different filter
types have different phase responses. As
well as the variation of gain and phase
with frequency, the time-domain response
of filters is important. Typically, this is
characterised by looking at the response
to a step change in the input voltage.
Again, this depends on the order and
response type and there are trade-offs
in desirable properties.
Filter circuit design
There are many different circuits
which can be configured to implement
a desired filter response (for example
Sallen-Key, multiple feedback and
state variable). These have different
non-ideal characteristics which might
need to be taken into consideration and
balanced against factors such as cost
and complexity. When designing a filter,
the bandform and cut off frequency are
usually straightforward to determine from
the application. The order, response type
(Butterworth, Chebyshev) and circuit
implementation choices will be based
on the performance requirements – for
example, how close are unwanted signals
47
Fig.4. (left)
Sallen-Key
second-order
low-pass filter.
C2
Vin
R1
R2
–
C2
R4
Vout
Digipot
Digipot
W
W
Electronically
Controlled
– Part
8 8
Vin Resistance
Electronically
Controlled
Resistance
– Part
Fig.5. (right)
B
B
Electronically Controlled ResistanceUnity-gain
– Part 8
𝑓𝑓! =𝑓𝑓!𝐹𝐹"=𝑓𝑓# 𝐹𝐹R" 𝑓𝑓#
C1
R3
R1
2
C1
Sallen-Key low𝑓𝑓! =
𝐹𝐹" 𝑓𝑓with
#
pass
filter
Electronically Controlled Resistance – Part 8
digipot cut𝑅𝑅$
𝐴𝐴 =𝐴𝐴1=
+ 1 + 𝑅𝑅$
𝑓𝑓! =off𝐹𝐹"frequency
𝑓𝑓#
𝑅𝑅% 𝑅𝑅
𝑅𝑅$
%
control.
𝐴𝐴 = 1 +
𝑅𝑅%
+
–
Vout
+
𝑅𝑅$ be obtained with the RC
to wanted ones and how much do they
values than can
should dominate the digipot parasitics,
= 1 + has a maximum Q of 0.5,
need to be attenuated.
filter,𝐴𝐴which
so something
1 1 around 10nF may be the
𝑅𝑅%
𝑓𝑓! =smallest
For the various circuit implementations
and is often lower.
capacitor value that should be
𝑓𝑓! =
2𝜋𝜋*𝑅𝑅& 𝑅𝑅' 𝐶𝐶
& 𝐶𝐶
1
& 𝑅𝑅
'a&𝐶𝐶real
& 𝐶𝐶& design the details of
there are equations relating the component
The other
used,2𝜋𝜋*𝑅𝑅
but for
𝑓𝑓! = design equations for this
values to the resonant frequency and Q.
circuit are: 2𝜋𝜋*𝑅𝑅& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶&
individual digipot devices can be checked
The required response type determines the
on datasheets.
1
𝑓𝑓! =
Q and frequency-scaling factor. These can
2𝜋𝜋*𝑅𝑅& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶&
𝑅𝑅' 𝐶𝐶
*𝑅𝑅&*𝑅𝑅
& 𝐶𝐶
be found in filter design tables published
& 𝑅𝑅
'&𝐶𝐶simplifications
& 𝐶𝐶&
𝑄𝑄 =𝑄𝑄 = Sallen-Key
𝑅𝑅
𝐶𝐶
+
𝑅𝑅
𝐶𝐶
+
𝑅𝑅
𝐴𝐴)
in various places. A well-known example
One
approach
to−
simplifying
the Sallen& 𝑅𝑅
& & 𝐶𝐶& +
' 𝑅𝑅
& ' 𝐶𝐶& +
& 𝐶𝐶𝑅𝑅
' (1
*𝑅𝑅& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶&
& 𝐶𝐶' (1 − 𝐴𝐴)
𝑄𝑄 =
of this is the Active Filter Cookbook by
Key equations is to use equal component
𝑅𝑅& 𝐶𝐶& + 𝑅𝑅' 𝐶𝐶& + 𝑅𝑅& 𝐶𝐶' (1 − 𝐴𝐴)
Don Lancaster, which was first published
values R = R1 = R2, and C = C1 = C2,
𝑅𝑅' 𝐶𝐶
*𝑅𝑅
&is
& 𝐶𝐶& resonant frequency.
in 1975 and is described as the best-selling
Where
f
which
gives:
the
0
𝑄𝑄 =
(1
1
𝐶𝐶
+
𝑅𝑅
𝐶𝐶
+
𝑅𝑅
𝐶𝐶
−
𝐴𝐴)
book on active filter design. Another 𝑅𝑅These
equations
are
quite
cumbersome,
& &
' &
& '
𝐹𝐹 𝑓𝑓 = 𝑓𝑓 = = 1
source is Active Low-Pass Filter Design, an
so simplifications are often made, which " # 𝐹𝐹" 𝑓𝑓# != 𝑓𝑓!2𝜋𝜋𝜋𝜋𝜋𝜋
2𝜋𝜋𝜋𝜋𝜋𝜋
1
application note by Jim Karki from Texas
we will 𝐹𝐹discuss
=
" 𝑓𝑓# = 𝑓𝑓! below.
2𝜋𝜋𝜋𝜋𝜋𝜋
1
Instruments (SLOA049 – see: https://bit.
𝑄𝑄 =𝑄𝑄 = 1
ly/pe-apr23-ti). An alternative to tableDigipots with1 Sallen-Key
filters
3
−
3𝐴𝐴− 𝐴𝐴
1
𝐹𝐹 𝑓𝑓# = 𝑓𝑓! =
assisted manual calculations is to use a
𝑄𝑄 2𝜋𝜋𝜋𝜋𝜋𝜋
=
To "use
the Sallen-Key
with digipot control
3 − 𝐴𝐴
filter design app or online tool. These make
we need to be able to control the cut-off
This provides very simple design
Electronically
Controlled
Resistance –equations
Part 8 but does not allow the overall
1 by varying
things easy but may restrict the options
frequency
just
the resistors.
𝑄𝑄 =
Electronically Controlled Resistance – Part1 8
for exactly how the filter is implemented.
The capacitors
gain of the filter1to be set independently of
3 − 𝐴𝐴 should be chosen based
𝐹𝐹 𝑓𝑓 =
=
𝑓𝑓#𝑓𝑓
==𝑓𝑓
𝐹𝐹!2𝜋𝜋𝜋𝜋𝐶𝐶
( 𝑓𝑓
!!=
" 𝑓𝑓
#
Filters represent a huge ‘design space’
on the midpoint of the1required frequency ( #𝐹𝐹the
Q
value.
𝑛𝑛 circuit can be designed
&The
2𝜋𝜋𝜋𝜋𝐶𝐶
𝑓𝑓! =
𝐹𝐹√𝑓𝑓#& √𝑛𝑛
𝑓𝑓# = 𝑓𝑓The
of possibilities – bandform, response
control𝐹𝐹(range.
by choosing a"required
response, which
! = resonant and hence cut2𝜋𝜋𝜋𝜋𝐶𝐶
type, order, circuit implementation and
off frequency is set
by &R√1𝑛𝑛and R2, which
sets the
Q, and choosing R3 and R4 to
√𝑛𝑛𝑅𝑅
𝑛𝑛
1
𝑄𝑄 = = $√gain
so on. To keep things manageable for
need to be independently
controlled,
obtain
(A) for that Q.
𝐴𝐴 = 1𝑄𝑄+the
2 2 𝑅𝑅required
𝐹𝐹( 𝑓𝑓# = 𝑓𝑓! =
$
𝑛𝑛
𝑅𝑅
√
%1 +
the remainder of this article on using
which implies
use
of
two
digipots
in
The
Q
could
be
set
independently
of the
2𝜋𝜋𝜋𝜋𝐶𝐶
𝑛𝑛
𝐴𝐴
=
√
𝑄𝑄 = &
2 we have discussed
digipots with filters we will just look at
rheostat mode. As
frequency with𝑅𝑅a% digipot, as mentioned
second-order low-pass Sallen-Key Filters.
previously,√digipot
resistance values are
above, but the gain variation may need to
𝑛𝑛
𝑄𝑄 =particularly accurate,1which
Sallen-Key filters are widely used, and
often not
be compensated
1 1 for by another variable
2
1 =
1
=𝑅𝑅 =
= 5181
tools are available to help design them
will affect the accuracy 𝑅𝑅with
which the
gain
stage.
The frequency
is set by
=
= 5181
2𝜋𝜋𝑓𝑓2𝜋𝜋𝑓𝑓
𝑛𝑛 √𝑛𝑛𝑓𝑓2𝜋𝜋
852
× 15𝑛𝑛𝑛𝑛
× √5.099
! =×
! 𝐶𝐶& √
1
𝐶𝐶
1
1
2𝜋𝜋
×
852
×
15𝑛𝑛𝑛𝑛
×
√5.099
!
&
(select the required component values).
cut-off
frequency
can
be
controlled.
Use
choosing
C
and
controlling
R
with two
2𝜋𝜋*𝑅𝑅
𝑅𝑅
𝐶𝐶
𝐶𝐶
𝑓𝑓
=
&
'
&
&
𝑅𝑅 =
=
= 5181
!
2𝜋𝜋𝑓𝑓! 𝐶𝐶of
Low-pass filters are commonly required in
would
usually
digipots2𝜋𝜋*𝑅𝑅
in rheostat
set to the same
2𝜋𝜋digipot
× 852 ×device
15𝑛𝑛𝑛𝑛 ×
√5.099
& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶mode
&
& √a𝑛𝑛 dual
microcontroller circuits for anti-aliasing
be a good option.
resistance to set the resonant frequency.
1
1
𝑅𝑅 =
= We are probably less likely=to5181
and reconstruction filters before/after
want to
The resonant
𝑅𝑅 𝑅𝑅 frequency is calculated
2𝜋𝜋𝑓𝑓! 𝐶𝐶& √𝑛𝑛 2𝜋𝜋 × 852 × 15𝑛𝑛𝑛𝑛 × √5.099
ADCs and DACs, where cut-off frequency
control the Q with a digipot – in most
from
required
cut-off frequency using
𝐷𝐷 =𝐷𝐷the
𝑆𝑆𝑅𝑅
=
𝑆𝑆& 𝐶𝐶&
𝐶𝐶
*𝑅𝑅& 𝑅𝑅')*
𝑅𝑅)*
𝑅𝑅
programmability may be desirable.
cases the requirement
would be𝑄𝑄for
the frequency-scaling
factor.
= a
𝑅𝑅
𝐶𝐶
*𝑅𝑅
' −
& 𝐶𝐶𝐴𝐴)
&
𝐷𝐷 = 𝑆𝑆
𝑅𝑅 𝐶𝐶 + 𝑅𝑅' 𝐶𝐶& + 𝑅𝑅& 𝐶𝐶&' (1
fixed response shape
gain variations
discussed above
𝑅𝑅)* with a variable&𝑄𝑄&= 𝑅𝑅The
& 𝐶𝐶& + 𝑅𝑅' 𝐶𝐶& + 𝑅𝑅& 𝐶𝐶' (1 − 𝐴𝐴)
cut-off frequency.
However,
it
would
can
be
avoided
by
using
a fixed gain.
Sallen-Key low-pass filter
𝑅𝑅
be possible
This requires at least the two resistors
Fig.4 shows a Sallen-Key low-pass filter.
𝐷𝐷 = 𝑆𝑆 to use a digipot to set the
𝑅𝑅)*
amplifier gain
(via R3 and R4) and hence
or the two capacitors to have different
It comprises a frequency-dependent
1
Resistance circuit
– Part 8formed by R , R , C and C , and
used variant of the
make
Q
programmable.
We
discussed
use
𝐹𝐹" 𝑓𝑓#values.
= 𝑓𝑓! =A commonly
1
2
1
2
1
2𝜋𝜋𝜋𝜋𝜋𝜋
Sallen-Key
of digipots to control op amp amplifier
a non-inverting op amp amplifier. The
𝐹𝐹" 𝑓𝑓# = 𝑓𝑓!filter
= is the unity-gain version
2𝜋𝜋𝜋𝜋𝜋𝜋
𝑓𝑓! = 𝐹𝐹" 𝑓𝑓#gain (A) is set by R and R ,
shown in Fig.5, which also shows how
gain in Part 5.
amplifier
3
4
1
the
digipots
are
Use of digipots may introduce
and is given by:
𝑄𝑄 =
1 used.
3−
𝑄𝑄 𝐴𝐴
=design simplification approach
Another
limitations on the filter design. For
3 − 𝐴𝐴
𝑅𝑅$
is to set equal resistors and capacitors
example, their parasitic capacitance is
𝐴𝐴 = 1 +
𝑅𝑅%
with ratio n, that is R = R1 = R2, and C2 =
likely to be higher than the same filter
using fixed resistors. Parasitic capacitance
nC1 which gives:
1
is the unwanted capacitance inherent in𝐹𝐹( 𝑓𝑓# = 𝑓𝑓! =
The frequency-dependent circuit is
1
2𝜋𝜋𝜋𝜋𝐶𝐶
𝐹𝐹( 𝑓𝑓# = 𝑓𝑓! =& √𝑛𝑛
structure of the pins and circuitry of the
similar to a two-stage RC filter, but with
2𝜋𝜋𝜋𝜋𝐶𝐶& √𝑛𝑛
1
digipot device. This will limit the upper
C connected
to positive feedback from
𝑓𝑓! =2
𝑛𝑛
√
frequencies
than
can
be
used
or
accurately
the2𝜋𝜋*𝑅𝑅
amplifier,
rather
than
to
ground.
This
& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶&
𝑄𝑄 =
controlled. Frequency-setting capacitors
allows the circuit to have much higher Q
2𝑄𝑄 = √𝑛𝑛
2
48
Practical Electronics | April | 2023
𝑄𝑄 =
*𝑅𝑅& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶&
1
1
ronically Controlled Resistance – Part 8
𝑓𝑓! = 𝐹𝐹" 𝑓𝑓#
trolled Resistance – Part 8
𝑓𝑓! = 𝐹𝐹" 𝑓𝑓#
𝐴𝐴 = 1 +
𝑓𝑓! =
𝑅𝑅$
𝑅𝑅%
1
𝑅𝑅$
𝐴𝐴 = 1 +
𝑅𝑅%
𝑓𝑓! =
1
2𝜋𝜋*𝑅𝑅& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶&
2𝜋𝜋*𝑅𝑅& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶&
𝑄𝑄 =
𝐴𝐴 = 1 +
*𝑅𝑅& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶&
𝑅𝑅& 𝐶𝐶& + 𝑅𝑅' 𝐶𝐶& + 𝑅𝑅& 𝐶𝐶' (1 − 𝐴𝐴)
𝑓𝑓! =
𝑄𝑄 =
𝑅𝑅$
𝑅𝑅%
1
2𝜋𝜋*𝑅𝑅& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶&
Fig.6. LTspice
schematic for 1kHz
unity-gain Sallen-Key
low-pass filter.
*𝑅𝑅& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶&
𝑅𝑅& 𝐶𝐶& + 𝑅𝑅' 𝐶𝐶& + 𝑅𝑅& 𝐶𝐶' (1 − 𝐴𝐴)
𝐹𝐹" 𝑓𝑓# = 𝑓𝑓! =
1
2𝜋𝜋𝜋𝜋𝜋𝜋
1
3 − 𝐴𝐴
ripple size below the peak gain, which
next represents a larger frequency change.
in this case is the point where it crosses
This in turn means that it is less likely
0dB as it transitions into the stopband.
that exactly the right resistance value will
1 at the higher frequency end
This occurs at 1kHz, as designed.
𝐹𝐹( 𝑓𝑓# be
= 𝑓𝑓available
! =
2𝜋𝜋𝜋𝜋𝐶𝐶& √𝑛𝑛
of the programmable
range.
As discussed previously (see Part 5 in
Setting the digipot code
PE, January
Example design
In a typical programmable filter application,
1
√𝑛𝑛 2023) digipots can be modelled
𝑄𝑄two
= resistors R and R such that the
as
there
are
likely
to
be
a
set
of
required
cut-of
Consider𝑄𝑄a =
filter
of
Chebyshev
type
with
A
B
3 − 𝐴𝐴
2
frequencies. For these cut-off frequencies
2dB passband ripple and 1kHz cut-off.
If
total resistance RA + RB = RAB where RAB
1
= 𝑓𝑓! =
to be implemented in a circuit like that
we look it up, Q𝐹𝐹(=𝑓𝑓#1.129
and
Fs =√0.907
is the resistance between the terminals A
2𝜋𝜋𝜋𝜋𝐶𝐶
& 𝑛𝑛
in Fig.5 the required resistor values must
and B and the specified resistance of the
and using the equal-resistor unity-gain
fall within the range of resistance1values
digipot. In1rheostat mode we use just one
Sallen-Key circuit1we need n = 4Q2 =
√𝑛𝑛
𝑅𝑅 = combined
=
= 5181
𝐹𝐹( 𝑓𝑓# Choosing
= 𝑓𝑓! =
available
from
the
digipot,
these
say from
terminal B
5.099.
C
=
15nF
gives
C
=
𝑄𝑄
=
1
2
2𝜋𝜋𝑓𝑓! 𝐶𝐶& √𝑛𝑛 2𝜋𝜋 of
2𝜋𝜋𝜋𝜋𝐶𝐶& √𝑛𝑛
× 852
× resistances,
15𝑛𝑛𝑛𝑛 × √5.099
2 need f =
with
fixed
capacitor
values.
This
means
to
the
wiper
(as
drawn
in Fig.5). For a
76.48nF. For 1kHz cut-off we
0
that very wide frequency ranges will not
digipot with S steps we need a digital code
Fsfc = 0.852 × 1000 = 852. We can then
√𝑛𝑛
be possible, but something from 10:1 to
D to set a resistance value R as follows:
calculate R𝑄𝑄 as:
=
2
100:1 should be possible.
𝑅𝑅
1
1
𝐷𝐷 = 𝑆𝑆
basic filter calculations discussed
𝑅𝑅 =
=
=The
5181
𝑅𝑅)*
2𝜋𝜋𝑓𝑓! 𝐶𝐶& √𝑛𝑛 2𝜋𝜋 × 852 × 15𝑛𝑛𝑛𝑛 × √5.099above determine the required resistance
values, but these need to be mapped to the
The actual resistance obtained is:
1
1
digipot codes giving the nearest resistance
=
=
= 5181
𝐷𝐷
2𝜋𝜋𝑓𝑓! 𝐶𝐶& √𝑛𝑛 2𝜋𝜋 × 852 × 15𝑛𝑛𝑛𝑛 × √5.099
values. The exact resistance required may
𝑅𝑅 = 𝑅𝑅)*
𝑆𝑆
𝑅𝑅
not be available from the digipot, leading
𝐷𝐷 = 𝑆𝑆
𝑅𝑅
)*
to errors in the frequency setting. The
In some cases, there may be a significant
Fig.6 shows an LTspice schematic
of the
more positions the digipot has the more
difference between the required and
filter implementation. The simulation
𝑅𝑅
likely the frequency can be set close to
obtained resistance, in other cases they
results (AC
to plot frequency
𝐷𝐷 =analysis
𝑆𝑆
𝑅𝑅)*
the desired value.
will be close. For example, to set a 10kΩ,
response) for this
circuit in Fig.7 show the
The reciprocal nature of the frequency
256-step digipot to 5181Ω (from the above
gain is 0dB at low frequencies (unity gain).
to resistance relationship means that at
example) requires a digital code of 256 ×
The gain peaks at +2dB (this is the 2dB
higher frequencies (lower resistance) each
(10000 / 5181) = 133. The actual resistance
passband ripple). The cut-off frequency
step in resistance from one code to the
is 5195Ω , an error of just 0.3%. For a
for this type of filter is defined as the
100kΩ, 256-step digipot the code required
is 13 and the resistance is 5078Ω, a 2%
error. Smaller resistances may produce
larger errors with a given digipot. For
example, 518.1Ω for a 10kHz cut-off with
the above circuit requires codes 13 and
1 with resistance errors of 2% and 25%
respectively for the 10kΩ and 100kΩ
digipots. This assumes a perfectly accurate
digipot, but the RAB value itself may be
subject to quite a large tolerance, for
example 20% in some cases.
*𝑅𝑅& 𝑅𝑅' 𝐶𝐶& 𝐶𝐶&
𝑅𝑅& 𝐶𝐶& + 𝑅𝑅' 𝐶𝐶& + 𝑅𝑅& 𝐶𝐶' (1 − 𝐴𝐴)
To design with this approach the1required
𝐹𝐹" 𝑓𝑓#Q,=which
𝑓𝑓! = in turn sets
response type sets the
2𝜋𝜋𝜋𝜋𝜋𝜋
the capacitor ratio (n). The base capacitance
value, n and the 1calculated
1 resonant
𝑄𝑄 the
= resistor value.
𝐹𝐹" 𝑓𝑓# =
𝑓𝑓!used
= to set
frequency
are
3
−
𝐴𝐴
2𝜋𝜋𝜋𝜋𝜋𝜋
𝑄𝑄 =
𝑄𝑄 =
Design tools
Fig.7. Simulation results for the circuit in Fig.6.
Practical Electronics | April | 2023
The filter design calculations above, and the
associated need to obtain the correct Q and
frequency-scaling factor can be avoided by
using a filter design app or online utility.
These tools may reduce the options for
component selection compared with manual
49
Fig.8. (left)
FilterLab
bandform and
response type
setting.
Fig.9. (right)
FilterLab filter
parameter
settings.
Fig.10. (above) FilterLab circuit settings.
Fig.11. (right) Example FilterLab result.
design, which could be a problem in the
context of digipot-controlled circuits. We
need to be able to find a set of resistor values
to set different cut-off frequencies using a
circuit with the fixed capacitor values and
op amp circuit gain. This means we have
to be able to set the capacitor values and
let the tool calculate the resistor values for
a fixed-gain circuit such as the unity-gain
Sallen-Key discussed above.
Unlike the simplified approach above,
it is not necessary to have equal resistors.
In fact, by using different resistor values
(as calculated by the tool) the response
shape can be changed as well as the cutoff frequency, allowing the shape as well
as cut-off to be programmed. The way the
numbers work means that if a range of
response types is required the range of
cut-off frequencies possible with a given
digipot will be smaller than with a fixed
response type.
As was seen in the equal-resistor
example design above, the capacitor ratio
can influence the Q. The resistors do not
have to be equal but similar values will
make it easier to make use of a dual digipot.
In general, the feedback capacitor (C2 in
Fig.5) will be larger than the capacitor at
the op amp input (C1). Unlike the above
example, standard capacitor values should
be used for a real design.
FilterLab
One filter design tool that allows you
to set capacitor values is FilterLab from
Microchip – see: https://bit.ly/pe-apr23-mc
To design a filter using this app, select
Filter > Design from the menu and step
through the three tabs in the dialog (see
Fig.8 to Fig.10). The first tab is used to
select the bandform and response type.
Simulation files
Fig.12. LTspice schematic for Sallen-Key filter with digipot control.
50
Most, but not every month, LTSpice
is used to support descriptions and
analysis in Circuit Surgery.
The examples and files are available
for download from the PE website.
Practical Electronics | April | 2023
Here we have selected Chebyshev lowpass
as in the example above. The second tab sets
the filter parameters, here we selected ‘Force
filter order’ – this is to help make sure the
tool uses the required circuit to implement
the design. We select 1000Hz cut-off and
–2dB for the passband to match the 2dB
ripple Chebyshev design discussed above.
The third tab allows the circuit type to be
selected (Sallen-Key in this case) and the
capacitor values to be set, so they are fixed
in the circuit implementation. To do this,
click on both capacitors and select the value
from the dropdown list. The result is shown
in Fig.12 – the schematic of the filter created
by the app. For full details of using FilterLab
consult the manual on the download page.
Example design
Fig.13. Simulation results from the circuit in Fig.12.
FilterLab was used to create three more
circuits with different cut-offs. These can be simulated using
all the code combinations in one sweep simulation we can use
the circuit in Fig.12. Using the procedure described above,
the LTspice table function which uses an index to look up the
digipot codes were calculated for a 256-step 10kΩ digipot for
corresponding value. For four configurations we need index
the following frequencies:
values 1 to 4 which can be achieved by defining a parameter
R1 codes: 140
called FSET (frequency set), sweeping it in steps of 1 from 1 to
98
49
33
4 and using this in the look up. For example, for R1:
R2 codes: 239
167
84
56
700Hz 1kHz 2kHz 3kHz
.param Fset=1 RAB=100k N=256
In LTspice we can use a behavioural resistance (as used in
R = table({Fset},1,140,2,98,3,49,4,33)*{RAB}/{S}
previous parts) to calculate the actual digipot resistance using
the formula above with the RAB resistance and number of digipot
The results of the simulation are shown in Fig.13 and confirm
that the filter responses are as designed.
steps as parameters (RAB and S respectively). To run through
GET T
LATES HE
T CO
OF OU PY
R
TEACH
-IN SE
RIES
AVAILA
BL
NOW! E
Order direct from
Electron Publishing
PRICE £8.99
(includes P&P to UK if ordered direct from us)
EE
FR -ROM
CD
ELECTRONICS
TEACH-IN 9
£8.99
FROM THE PUBLISHERS OF
GET TESTING!
Electronic test equipment and measuring
techniques, plus eight projects to build
FREE
CD-ROM
TWO TEACH
-INs
FOR THE PRICE
OF ONE
• Multimeters and a multimeter checker
• Oscilloscopes plus a scope calibrator
• AC Millivoltmeters with a range extender
• Digital measurements plus a logic probe
• Frequency measurements and a signal generator
• Component measurements plus a semiconductor
junction tester
PIC n’ Mix
Including Practical Digital Signal Processing
PLUS...
YOUR GUIDE TO THE BBC MICROBIT
Teach-In 9 – Get Testing!
Teach-In 9
A LOW-COST ARM-BASED SINGLE-BOARD
COMPUTER
Get Testing
Three Microchip
PICkit 4 Debugger
Guides
Files for:
PIC n’ Mix
PLUS
Teach-In 2 -Using
PIC Microcontrollers.
In PDF format
This series of articles provides a broad-based introduction to choosing and using a wide range
of test gear, how to get the best out of each item and the pitfalls to avoid. It provides hints
and tips on using, and – just as importantly – interpreting the results that you get. The series
deals with familiar test gear as well as equipment designed for more specialised applications.
The articles have been designed to have the broadest possible appeal and are applicable to all branches of electronics.
The series crosses the boundaries of analogue and digital electronics with applications that span the full range of
electronics – from a single-stage transistor amplifier to the most sophisticated microcontroller system. There really is
something for everyone!
Each part includes a simple but useful practical test gear project that will build into a handy gadget that will either
extend the features, ranges and usability of an existing item of test equipment or that will serve as a stand-alone
instrument. We’ve kept the cost of these projects as low as possible, and most of them can be built for less than £10
(including components, enclosure and circuit board).
© 2018 Wimborne Publishing Ltd.
www.epemag.com
Teach In 9 Cover.indd 1
01/08/2018 19:56
PLUS! You will receive the software for the PIC n’ Mix series of articles and the full Teach-In 2 book – Using PIC
Microcontrollers – A practical introduction – in PDF format. Also included are Microchip’s MPLAB ICD 4 In-Circuit Debugger User’s Guide; MPLAB PICkit 4 In-Circuit Debugger Quick Start Guide; and MPLAB PICkit4 Debugger User’s Guide.
ORDER YOUR COPY TODAY: www.electronpublishing.com
Practical Electronics | April | 2023
51
|