0% found this document useful (0 votes)
2 views4 pages

The Digital Solution

This document discusses digital filters, focusing on their operation, structure, and comparison to analogue filters. It explains how digital filters perform mathematical operations on digital samples to remove unwanted frequencies, detailing the low-pass filter's functionality and providing examples of filter design and programming. The text highlights the advantages of digital filters, such as linear phase response and good roll-off, while also addressing potential stability issues with infinite impulse response (IIR) filters.

Uploaded by

HecOs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

The Digital Solution

This document discusses digital filters, focusing on their operation, structure, and comparison to analogue filters. It explains how digital filters perform mathematical operations on digital samples to remove unwanted frequencies, detailing the low-pass filter's functionality and providing examples of filter design and programming. The text highlights the advantages of digital filters, such as linear phase response and good roll-off, while also addressing potential stability issues with infinite impulse response (IIR) filters.

Uploaded by

HecOs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

THE DIGITAL SOLUTION

Part 7 - Digital filters


By Owen Bishop
I n almost all electronic cir-
cuits there is a need for fil-
has just arrived, perhaps from
an analogue-to-digital con-
te ring to remove unwanted verter (ADe). At this instant,
frequencies from the signals. the previous samples are
In this series we look closely at digital electrouics,
In analogue circuits, filtering moved one step along tbe
is achieved by using combi- what it is, what it does, how it works, aud its delay chain. The sample in
nations of resistors, capacitors promise for the future. register 5 (the sample taken
and (eometimes) inductors. langest ago) is overwritten by
The filters may include oper- the sample from register 4, so
ational amplifiers (op ampa), is lost from the fi lter. The
too. Filtering is a kind of sample in regiater 4 is now
mathematical operation. A overwritten by the sampie
low-paes filter has the proper- from register 3. In this way
ties of an integrator. It aver- the sampies are shifted along
ages out signals levels over a the chain and the present
period of time, thus removing, sam pIe xn is transferred to
or at least attenuating, the register 1.
rapid changes of voltages due The present sam ple and
to high frequencies. By COD- the output from each register
trast, a high-pass filter has 940120-7-50 (the five previous sam ples)
the properties of a differentia- are each fed to multiplier
tor, responding strongly to units, which multiply them by
rapid changes in signal level Fig.51 one series of coefficients, aO to
and thus attenuating the as. These coefficients weight
slowly changing voltages of the sampies in a way that
R
the lower frequencies. As weIl gives the fiJter its characteris-
as using integration and dif- c tics. The array of multipliers
ferentiation, analogue fil- is referred to as taps, since
tering uses addition and sub- they tap the signal as it pro-
traction of signals, especial1y ceeds along the chain. The fil-
in band-pass filters.
Similarly, a digital filter
performs mathematical oper-
ations on the digital sampIes
that constitute a digital sig-
• ter in Fig. 51 is a 6-tap filter.
The weighted outputs are
summed by an array of sum-
ming circuits, and their total
is the output Yn of the filter, If
nal. The operations are per- the six coeffcients were all
formed in real time at very made equal to 1/6, then Yn
high speed and the filtered would be a moving aue rage
signals reach the output of the Fig.52 based on the present sampIe
filter with an imperceptible and the five previous sam pies.
delay. But, in digital filters, A moving average, by its na-
the operations are directly a computer program. The digital sampies are stored as ture, averages out any partic-
mathematical, being per- computer program could be they arrive. The registers are ularly large or small values.
formed by microprocessors ur written in machine code or in arranged in a chain and , as Given a high-frequency sig-
speci al- purpose les with a high-level language such as each new sam ple xn arrives, nal, in which the signal level
buil t-in mathematical fune- C or BASIC. This underlines the other samples are passed is rapidly changing, making
Liens, known as digital signal the fact that digital filters are along the chain at the sam- five consecutive sampIes
processor. As an example, we essentially software, whereas pling frequency. For this rea- range widely in value, the ex-
describe how a digital low- analogue filters are essen- son, the chain is known as a tremes are averaged out. In
pass filter works. tially hardware. Of course, delay chain. Each register is other words, rapid changes, or
hardware is required in the an array of bistables (fl ip- high-frequency changes, are
Low-pass digital filter implementation of a digital flops), one for each bit of the attenuated. This is a low-pass
filter (including paper and sampIe, which is typically 16 filter, and its averaging effect
The structure of a lew-pass peneil as hardware for the bits long. The diagram shows is greater if we include more
filter is shown in Fig. 51. The brain-powered form of filter), five registers, but there may registers in the chain.
drawing ie a bleck diagram of but the result of filtering de- be fewer or more than this Note that the output of the
a digital Je with registers, pends much more on the se- number. Typically, a digital filter 1S obtained by summa-
multiplying sub-circuits and quence of actions and tbe coef- signal processor may have a tion. The action is similar to
summing sub-circuits. lt could ficients in troduced in to the hundred or more registers, that of a low-pass active filter
also be taken as a flow chart calculation than it does on the though tbe processor may be as shown in Fig. 52, in which
of a mathematical operation. structure of the hardware. programmed to use only a few the charge accumulating on
As such, it could be executed A digital filter consists of a of them, perhaps only the first the capacitor is the sum of
by band on paper or by using number of registers in whicb one. In the figure, sam ple Xn currents recently arriving. In

ELEKTOR ELECTRONICS JUNE 1995


THE DIGITAL SOLUTION - PART 7

general, the most recently ar- tant in aJl kinds of digital cir-
rived current has the biggest 10 REM *** FIR DIGITAL FILTER *** cuit. The precision of a digital
20 DIM X(100). A(100)
effect. To produce an eq uiva- 30 CLS:INPUT"Number Qf taps";T value is usually ±1 bit, so the
lent effect, we must weight 40 INPUT"Number Qf ~amples";N precision with which a value
the coefficients so that aO is 50 PRINT"Select waveform" is represented digitally de-
60 PRINT TAB(10) "1 Sque r-e
the largest and a5 is the 70 PRINT TAB (10) "2 Sawtooth
pends on its magnitude. Val-
smal1est. This modi fies the 80 PRINT TAB (10) "3 Tr-Lang Le " uee in the region of 60 000
moving average calculation, 90 PRINT TAB (10) "4 Sine" have aprecision of 0.0015%,
but the effect is still that of a 100 PRINT TAB(10)"5 Pulse" but values in the region of 100
110 INPUT"Key 1 to 5";W
lew-pass filter. It is the nature 120 INPUT"Period"; P
(with 7 bits) have a precision
of the weighting that largely 130 FOR J=O Ta T-l of only 0.01%. For optimum
determines the exact shape of 140 PRINT"Coeffici!'mt "jJ::INPUT"= ";A(J) precision, registers should be
150 NEXT used near their full capacity,
the filter's response curve and
160 FOR SAMPLE=O TO N STEP 1
the type of phase changes it 170 XS=SAMPLE Mon p provided that they do not be-
exhibits. Later we shall look 180 ON W GOTO 190, 220, 230. 250. 260 come over-full. Usually, the
at other patterns ofweighting. 190 XS=SGNCXS-P/2) most significant digit of a reg-
200 X=O: IF XS=)O THEN X=255
210 GOTO 270
ister that is filled beyond its
Filter action 220 X=INT(XS*255/P):GOTO 270 full capacity changes from 1 to
230 X=INT(XS*255/P):IF X)127 THEN X=255-X 0, with a dramatic fall in the
Ta see how the filer operates, 240 GOTO 270 value stored. This would seri-
250 X=INT«SIN(XS*6.283/P»*127+127l:GOTO 270
here is a numerical example. 260 X=O:IF SAMPLE<=P THEN X=255 ously upset the action of the
The filter in Fig. 51 has six 270 FOR J=T-l TO 1 STEP -1 filter. Many DSPs have regis-
taps and its output at any in- 280 X(J)=X(J-1) ters that minimize the error
290 NEXT
stant is represented by th is by making the register fill
300 X(O)=INT(X)
equation 310 Y=O with ls when there is over-
Yn = aQXO + alxn_l + a2oXn-2 320 FOR J=O TO T-1 flow. The error passes along
330 Y=INT (Y+X (J) oJ!'A (J» the chain and is eventual1y
+agXn_3 + a4xn-4 + aSXn-5'
340 NEXT
Suppose that seven consecu- 350 PRINT X; Yj" "-, lost (not so in another filter
tive sarnples, in order of ar- 360 NEXT type yet to be described). Sim-
rival at the input, are 11, 13, 940120--1-52
ilarly, if a register underflows,
15, 17, 14, 12, and 10. Sup- it is made to hold all Os. This
pose also that the coefficients Fig.53 feature could be added to the
are 0.3, 0.25, 0.2, 0.15, 0.1, BASIC program.
and 0.05. When the first six The results of filtering a
sampIes have arrived, the out- sine wave are shown in
put is Fig. 54. The program was set
0.3x12 + 0.25x14 + 0.2x17 to provide three taps with co-
+0.15x15 + 0.lx13 +0.05x11 efficients aO = 0.25, al = 0.5,
= 14.6. and a2 = 0.25. The period of
Note that the [irst sampIe to the sine wave is 40 samples.
arrive is now in register 5; the The magnitude of the coeffi-
sarnples are in the reverse of eients affects the 'gain' of the
50
their order of arrivaL An in- sampies
filter; for a 'gain' of 1, the coef-
940120-7-53
stant later, the seventh sam- ficients should total about 1.
ple (10) arrives, and the The graph shows a transient
others are shifted along the Fig.54. response for the first three
chain. The first sam pie (11) is sam ples as they are shifted
lost. Now the output is through to occupy both taps.
0.3x10 +0.25x12 + 0.2x14 From then on, the filtered
XlV
+0.15x17 +0.lx15 waveform is a sine wave of the
+ 0.05x13 = 13.5. 200 same frequency and almost
Between the 6th and 7th sam- the same amplitude as the
pIes, the input signal falls by 100 input signal. There is a very
2. The output falls by 1.1. The slight phase delay of one sam-
I
filter is smoothing out the sig- o pling period. In a real digital
nal, as required in a lew-pass filter in which the sampling
20
r' filter.
940120-7-54
sampies rate is higher in comparison
We could continue to ana- with the signal frequency, this
lyse tbe filter in this way but, delay is negligible. Note that
obviously, operating a pencil - Fig.55. in this filter we have allocated
aud-paper digital filter is a the middle tap the largest co-
lengthy business. A simple efficient, and that aO and a2
BASIC pro gram gives results of BASIC. The program allows 127, so they are equivalent to are equa l. This symmetrical
more quickJy. the user to decide on the num- having 8-bit registers in the pattern of coefficients has the
ber of taps, the number of fil ter. Actual filters usua11y effect of giving the filter a lin-
BASICsimulation samples, the waveform, the have 16-bit registers, giving a ear phase response, a charac-
period (the number of samples precision of 1 in 65536 or teristic of Bessel filters in the
Figure 53 lists a GWBASIC per cycle of the waveform or 0.0015%, provided that the analogue world. Unfortu-
program that simulates digi- the length of the single pulse), amplitude of the waveform is nately, this advantageous fea-
tal filters of the type ilIus- and the coefficients for each sufficiently great to almost ture of analogue Bessel filters
trated in Fig. 51. It is easily tap. The waveforms a11have saturate the registers. Inci- is counter-bal anced by their
converted into other dialects an amplitude and offset of dentally, this factor is impor- poor roll-off. With digital fil-

ELEKTOR ELECTRONICS JUNE 1995


GENERAL INTEREST

ters we ean have linear phase plied by the coefficients, thus


response and good roll-off, too. circulates indefinitely in the
XIY
Figure 55 shows the result filter. The filter is described
of filtering a sine wave of four
times the frequency (per-iod =
10 samples), but leaving the
number of taps and the coeffi-
eients unchanged. The output
200

100 I x __

y--
"
rt
as an infinite impulse re-
eponse or UR filter. For a
given number of taps, an IrR
filter has a faster roll-off at
the extremes of the passband,
50
is a sine wave of the same fre- sampies
which is an advantage. Hcw-
queney, lagging ODe sampIe 94ü120-7-55 ever, in contrast with an IFR
period behind the input, as filter, which is always stable,
before. But the amplitude of Fig.56. an UR filter may become un-
the output is less than that in stable in certain circum-
the previous example, indicat- stances. This is because the
ing that the filter is behaving IIR filter has an element of
as a low-pass filter. With more feedback in its action and,
taps, the effeet would be 200 where there is feedback, there
greater. is always the possibility of the
The low-pass action is more system going into permanent
apparent in Fig. 56 in which oscil1ation. For this reason,
a single pulse is filtered. In IIR filters need much more
50
this example, the filter has 11 sarnptes
careful design.
taps with coefficients 0.19, The FIR and UR filters are
0.17. 0.15, 0.13, 0.11, 0.09, the two basic configurations of
-200
0.07, 0.05, 0.03, 0.01 and 950120-7-56
digital filters, but it is posible
0.005. The 'exponential' rise to combine both types. The
and fall at the beginning and simplest of these is a filter in
end of the pulse are indicative which the output from each
of a lew-pass filter. By COD- Fig.57. register 1S summed and se nt
trast, Fig. 57 shows behav- to the filter output, as in an
iour associated with a high- FIR filter and, at the same
pass filter. Analogue high- time, the output of each regis-
pass filters are differentiators, ter is also fed back to the
so we might expect to use dir- input side as in an JIR filter. It
ferences between successive is possible to cascade these fil-
samples to represent rate of ters or connect them in paral-
change and thus produce a lel to give filters of higher
high-pass filter. Figure 57 was order. There are very many
produced with a 5-tap filter ways in which filters can be
with coefficients 0.1, 0.25. 0.4, built, leading to a wide range
-0.25, and 0.1. Typical up- of responses that can be engi-
ward and downward spikes neered. The digital filter is a
occur at the beginning and 940120-7-57 flexible device and is capable
end of each pulse of this of realizing filter functions
square wave. that are not possible with
The mathematics of digital Fig.58 analogue filters.
filters 1Shighly involved and We have shown that digital
any discussion of this is not filters may be implemented in
appropriate to this series. The several diferent ways. The

'D[ j[ j[
coefficients for the foregoing BASIC program is one such
examples were arrived at by way which, though quick
intuition rather than by calcu- enough as a demonstration, is
lation. But enough has been not fast enough to filter, say,
said to illustrate the pr-inci- an audio signal. Increased
ples behind digital filtering. o j I j j
speed is obtained by program-
The reader is left to investi- '.
21
5 ming the computer in ma-
gate further, using the BASIC chine code, but this falls short

'Ir j[ j[ J
program. of the speed that can be
achieved with a dedicated
Another digital filter digital signal processor. Multi-
plication is an essential stage
The filter described above is in filter ing and, on a micro-
know as a finite impulse re- o ' , processor acts as a bettle-
'-.'2 -, 21.
sponse or FIR filter. Each sam- IM0120-7-5&o.b neck. It takes a microproces-
ple is considered to be an im- sor several machine cycles to
pulse. Eacb sam pie passes perform a multiphcation. In
along the row of taps and is Fig.59. contrast, DSPs have multi pli-
eventually lost. Thus, each cation circuits built in, and
impulse exerts its effect for a can multiply in a single cycle.
finite nurnber of sample peri- value in each tap, multip1ied side, to be summed with the A DSP, such as one of the
ods. Figure 58 shows a differ- by the corresponding coeffi- products from subsequent Texas TMS320C5x series, op-
ent type of digital filter. The cient, is fed back to the input sampIes. Each sample, multi- erating as a 50-tap filter, can

ELEKTOR ELECTRONICS JUNE 1995


Please mention ELEKTOR ELECTRONICS when contacting advertisers

e new SC ematic capture program


Geswin (GESECA for Windows'")
adds more than a pretty face to 3
r'H-"i
i ~.,

Spieenge. Upgrade forflOO+ VAT*


• Geswin ODE links with SpiceAge to pravide instant
circuit editing. Because this link enables SpiceAge
to retain all its simulation settings, the schematic
(produced by Geswin) is uncluttered so that you
can create clean drawings that may be clipboarded
into your other Windows applications.
• You can clipboard sections of your netlist fram
SpiceAge back into Geswin' s attribute Inspector if
you wish to use patches of existing circuits.
• Geswin has inherited GESECA' s speed and ease of
use. You will find it's best-Ioved "bücket of bits" components' store waiting for your instant use from a
special self-replenishing window.
• The SpiceAge component library has been expanded and re-drawn into "stubbies". The new symbols allow
more components to fit within a given screen area without compromisirig clarity.
• Multiple windows allow you to scratch pad your designs (simulating as you work) and clipboard them into
a fair copy window.
• File compatible with GESECA: schematics and components from GESECA may be read.
• Comprehensive HELP pro vi des reference material; tutorial style manual reassures you of your own intuition.
• Geswin automatically invokes (or switches to) SpiceAge; you can also invoke Geswin from SpiceAge.

Please contact Those Engineers Ltd, 31 Birkbeck Road,


LONDON NW7 4BP.
Tel 0181-906 0155, FAX 0181-906 0969.
·upgrade price from GESECA; [295 + VAT new

accept and filter signals at result is that the lew-pass fil- spaee. No matter how precise logue filters need eomplete
frequencies up to 250 kHz. In ter passes all the lower fre- the eomponents in an ana- rewiring to effect such a
contrast, a typical micropro- quencies that can be heard (ta logue filter, they introduce change. The ability to pro-
cessor, working at 33 MHz the left of the dashed line) parasitic capacitance and in- gram the filter by changing
and programmed as a 50-tap and also higher frequencies ductance into the circuit with the eoeffieients opens up the
filter, can filter signals with atha t can not be heard. In consequent distortion. Trim- possibility of altering the re-
maximum frequeney of only Fig. 58b, the pass-bands are mers to adjust the eapaei- sponse of the filter while it is
25 kHz. shifted up the frequeney spec- tances and inductanees are running. This means that the
trum. The band within the often required in preeision filter ean be altered to suit the
range of interest provides a analogue filters, adding more signal that it is eurrently re-
Frequency response eeiving. Filters of this type
high-pass function. Suitably to cost and board space.
It is a consequence of the located combs of bands can Even when an analogue fil- are known as adaptive filters.
mathematics that the fre- provide band-pass and band- ter has been built from high- The incoming signal is moni-
queney response of digital fil- stop filters. precision eomponents and tored and the eoeffieients al-
ters is repeated at multiples earefully trimmed, its behav- tered accordingly. Taking all
of the sampl ing frequency. The digital solution iour is subject to changes in these points intc considera-
Whether a filter is considered eomponent values resulting tion, it is not surprising that
to be low-pass, high-pass, Digital filters operate by cal- from age or temperature. Di- the digital solution has been
band-pass or band-stop de- culating and produee an out- gital filters work precisely ac- so widely adopted.
pends on the relationship be- put to any reasonably re- cording to the response de-
tween the location of the mul- quired level of precision. In signed into them and are en- Reference: Craig, Marvin and
tiple pass-bands in the fre- addition, filters of widely dif- tirely stable. This is a re- Ewers, Gillian: A simple ap-
queney spectrum. In Fig. 59a, fering characteristics can all minder that it is possible to proach to digital signal pro-
the first pass-band extends be realized with a general- program a digital filter with cessing; Texas Instruments,
from zero frequeney (0) to a purpose DSP device. There is frequency and phase re- 1993.
value less than fs/2, where fs no need of high-precision (and sponses that are just not pos-
is the sampling frequency. The expensive) resistors, capaei- sible with analogue tech-
band is repeated at {" 2 {" tors (possibly ganged), induc- niques. Test yourself
The sampling frequency is tors or op amps as there is for Finally, there is the advan- The I1Rfilter in Fig. 58 has co-
chosen so that it 1S at least an analogue filter. There is no tage that the response of a efficients ao == 0.2, a1 == 0.4,
double the frequency of any need for special layouts on the digital filter can be altered, and a2 = 0.2. A single ramp
signal that is of interest. This peB. Discrete components, possibly quite drastically, pulse is fed into it, having
is why, in digital audio, for particularly inductors, are rel- simply by changing the values values 2, 4, 6, 8, 10. Find the
whicb 20 kHz is the highest atively bulky and take circuit- of the eoefficients. A few small output of the filter for 10 con-
frequency that the human ear board space. A digital filter is changes in the coefficients can secutive sample times, round-
can detect, the sampling fre- built from minute deviees on a even change a low-pass filter ing to four decimal places.
quency is at least 40 kHz. The silicon chip and takes up little into a high-pass filter. Ana- [940120-VIl]

ELEKTOR ELECTRONICS ]UNE 1995

You might also like