Circuit Surgery
Regular clinic by Ian Bell
Topics in digital signal processing –
windowed sinc filters
W
e are looking at various
topics related to digital signal
processing (DSP).
DSP covers a wide range of electronics
applications where signals are manipulated, analysed, generated, stored or
displayed as digital data but originate
from and/or are converted to real-world
signals for interaction with humans or
other parts of the physical world.
Fig.1 shows the key elements of a generic DSP system with a signal path from
an analog input via digital processing to
an analog output. This does not necessarily represent every DSP system (not all
have all the parts shown), but it serves
as a reference for the various subsystems
we will consider.
Last month, we started looking at the
windowed sinc filter, which is a widely
used type of digital filter. We discussed
the “sinc” aspect of the filter’s name,
which refers to the fact that its impulse
response takes the form of the mathematical sinc function.
The impulse response is the output obtained from a system when the input is
an impulse. For a sampled data system,
this is a single input sample of value 1
at time zero, with an input of zero at all
other times.
For a Finite Impulse Response (FIR)
filter (Fig.2), the coefficients (the ai values
in Fig.2) are equal to the impulse response of the filter. So, if we know the
impulse response of the desired filter,
we have the coefficient values required
to implement it.
As discussed last month, we can obtain
the impulse response of a filter by performing an inverse Fourier Transform on
the required filter frequency response.
The result for an ideal low-pass filter
(a ‘brick wall’ filter) is that the impulse
response is a sinc function, hence the
Analog
In
Antialiasing
filter
Sample and
hold
importance of the sinc function in filter
implementation.
We showed how to use a spreadsheet
to calculate an example set of low-pass
filter coefficients, normalising the DC
gain to one.
Filter & simulation improvements
The sinc function has non-zero values
over an infinite range, so a perfect filter
would require an infinite number of coefficients. That is obviously not practical,
so last month we simply used the relevant sinc function values up to a specific
number of coefficients.
Truncating the coefficients like this
does not necessarily produce the best results, which is where the “windowing”
part of the filter name comes in. Before
getting into that, though, we will continue our discussion on using LTspice
to simulate these filters.
In previous articles, we used LTspice to
implement digital filter maths for obtaining frequency response plots or transient
simulations of just the filter, or the filter
together with other subsystems such as
sampling and reconstruction filters (see
Fig.1). Our approach uses LTspice behavioural voltage sources to implement
the delay, multiply and add operations
shown in the filter structure of Fig.2.
Last month, we showed an FIR filter
example with 25 coefficients, which required drawing 24 behavioural sources on
the schematic to implement the delays.
As a reminder, part of the schematic
from last month is shown in Fig.3. This
includes just five of the 24 delay sources, and the input signal source is also
not shown.
We may need to investigate filters with
many more coefficients, or circuits with
multiple filters, but in doing so, it becomes increasing cumbersome to draw
Digital
ADC
Digital
processing
Analog
DAC
Fig.1: a generic digital signal processing (DSP) system structure.
46
Reconstruction
filter
the schematic. We need a better way to
create large filters.
SPICE netlists
Although we usually draw schematics when using LTspice, the simulator
actually uses a text description of the
circuit, called a netlist, which is generated from the schematic drawing. SPICE
simulators go back to the 1970s, before
the days of high-resolution graphical
user interfaces, so text has always been
the format for circuit input.
The libraries of component models
provided with LTspice or via downloads
are also primarily text-based netlists or
model statements.
You can view the netlist of a schematic
from the main menu using View → SPICE
Netlist. For the circuit from last month,
the netlist will be similar to that shown
in Fig.4, although the lines may be in a
different order.
Fig.4 only shows the first and last three
behavioural sources used to implement
the delays. Still, it should be clear that
the regular structure of the circuit leads
to a repetitive form for the code relating
to these sources in the netlist.
This means it is reasonably easy to
create the netlist of a larger filter without
a0
x(n)
×
Σ
y(n)
a1
Δt
x(n–1)
×
a1x(n–1)
Σ
a2
Δt
x(n–2)
×
a2x(n–2)
Σ
aN–1
Δt
Out
a0x(n)
Memory
x(n–N–1)
×
aNx(n–N–1)
Processing
Fig.2: the structure of a finite impulse
response (FIR) filter.
Practical Electronics | March | 2025