In signal processing, the function of a filter is to remove
unwanted parts of the signal, such as random noise, or to
extract useful parts of the signal, such as the components
lying within a certain frequency range.
Figure 1: Â A block diagram of a basic filter
There are two main kinds of filter, analog and digital. They are quite different in their physical makeup
and in how they work.
An analog filter uses analog electronic circuits made up
from components such as resistors, capacitors and op amps to
produce the required filtering effect. Such filter circuits are
widely used in such applications as noise reduction, video
signal enhancement, graphic equalisers in hifi systems, and
many other areas.
There are wellestablished standard techniques for designing
an analog filter circuit for a given requirement. At all
stages, the signal being filtered is an electrical voltage or
current which is the direct analog of the physical quantity
(for example, a sound or video signal or transducer output)
involved.
A digital filter uses a digital processor to perform
numerical calculations on sampled values of the signal. The
processor may be a generalpurpose computer such as a PC, or a
specialized DSP (Digital Signal Processor) chip.
The analog input signal must first be sampled and digitized
using an ADC (analogtodigital converter). The resulting
binary numbers, representing successive sampled values of the
input signal, are transferred to the processor, which carries
out numerical calculations on them. These calculations
typically involve multiplying the input values by constants and
adding the products together. If necessary, the results of
these calculations, which now represent sampled values of the
filtered signal, are output through a DAC (digitaltoanalog
converter) to convert the signal back to analog form.
Note that in a digital filter, the signal is represented by
a sequence of numbers, rather than a voltage or current.
Figure 2: Â A block diagram of a basic digital filter
The following list gives some of the main advantages of
digital over analog filters:
 A digital filter is programmable, in other words, its
operation is determined by a program stored in the
processor's memory. This means the digital filter can easily
be changed without affecting the circuitry (hardware). An
analog filter can only be changed by redesigning the filter
circuit.  Digital filters are easily designed, tested and
implemented on a generalpurpose computer or
workstation.  The characteristics of analog filter circuits
(particularly those containing active components) are subject
to drift and are dependent on temperature. Digital filters do
not suffer from these problems, and so are extremely stable
with respect both to time and temperature.  Unlike their analog counterparts, digital filters can
handle low frequency signals accurately. As the speed of DSP
technology continues to increase, digital filters are being
applied to high frequency signals in the RF (radio frequency)
domain which, in the past, was the exclusive preserve of
analog technology.  Digital filters are very much more versatile in their
ability to process signals in a variety of ways. This
versatility includes the ability of some types of digital filter to adapt
to changes in the characteristics of the signal.
Fast DSP processors can handle complex combinations of
filters in parallel or cascade (series), making the hardware
requirements relatively simple and compact in comparison with
the equivalent analog circuitry.
In the next few sections, we will develop the basic theory of
the operation of digital filters. This is essential to an
understanding of how digital filters are designed and used.
First of all, we need to introduce a basic notation.
Suppose the “raw” signal that is to be digitally filtered is
in the form of a voltage waveform described by the function
V = x (t)
where t is time.
This signal is sampled at time intervals h (the
sampling interval). The sampled value at time t = ih
is
x_{i} = x (ih)
Thus the digital values transferred from the ADC to the
processor can be represented by the sequence
x_{0} , x_{1} , x_{2} ,
x_{3} , …
corresponding to the values of the signal waveform at times
t = 0, h, 2h, 3h, … (where t = 0 is the instant
at which sampling begins).
At time t = nh (where n is some positive
integer), the values available to the processor, stored in
memory, are
x_{0} , x_{1} , x_{2} ,
x_{3} , … , x_{n}
Note that the sampled values x_{n+1} ,
x_{n+2} , and so on are not available as they haven't
happened yet!
The digital output from the processor to the DAC consists of
the sequence of values
y_{0} , y_{1} , y_{2} ,
y_{3} , … , y_{n}
In general, the value of y_{n} is calculated
from the values x_{0} , x_{1} , x_{2} ,
x_{3} , … , x_{n} . The way in which the y values are calculated from the x values determines the filtering action of the digital filter.
The following examples illustrate the essential features of
digital filters.

UNITY GAIN FILTER: y_{n} = x_{n}
 Each output value y_{n} is exactly the same
as the corresponding input value x_{n} :  y_{0} = x_{0 } y_{1} = x_{1 } y_{2} = x_{2 } … etc
This is a trivial case in which the filter has no
effect on the signal.  Each output value y_{n} is exactly the same

SIMPLE GAIN FILTER: y_{n} = Kx_{n}
(K = constant) This simply applies a gain factor K to each
input value:  y_{0} = Kx_{0 } y_{1} = Kx_{1 } y_{2} = Kx_{2 } … etc
K > 1 makes the filter an amplifier,
while 0 < K < 1 makes it an attenuator. K < 0 corresponds to an inverting amplifier. Example 1 above is the special case where K = 1.  This simply applies a gain factor K to each

PURE DELAY FILTER: y_{n} = x_{n1}
 The output value at time t = nh is simply the
input at time t = (n1)h, in other words, the signal is
delayed by time h:  y_{0} = x_{1 } y_{1} = x_{0 } y_{2} = x_{1 } y_{3} = x_{2 } … etc
Note that as sampling is assumed to commence at t =
0, the input value x_{1} at t =
h is undefined. It is usual to take this (and any
other values of x prior to t = 0) as
zero.  The output value at time t = nh is simply the

TWOTERM DIFFERENCE FILTER: y_{n} =
x_{n} – x_{n1} The output value at t = nh is equal to the
difference between the current input x_{n}
and the previous input x_{n1} :  y_{0} = x_{0} – x_{1 } y_{1} = x_{1} – x_{0 } y_{2} = x_{2} – x_{1 } y_{3} = x_{3} – x_{2 } … etc
in other words, the output is the change in the input
over the most recent sampling interval h. The effect
of this filter is similar to that of an analog
differentiator circuit.  The output value at t = nh is equal to the

TWOTERM AVERAGE FILTER: y_{n} =
(x_{n} + x_{n1} ) / 2 The output is the average (arithmetic mean) of the
current and previous input: 
y_{0} = (x_{0} + x_{1} ) /
2
y_{1} = (x_{1} + x_{0} ) /
2
y_{2} = (x_{2} + x_{1} ) /
2
y_{3} = (x_{3} + x_{2} ) /
2
… etc
This is a simple type of lowpass filter as it tends to smooth out highfrequency variations in a signal. (We will look at more effective lowpass filter designs later).
 The output is the average (arithmetic mean) of the

THREETERM AVERAGE FILTER: y_{n} =
(x_{n} + x_{n1} + x_{n2} ) / 3 This is similar to the previous example, with the
average being taken of the current and two previous
inputs: 
y_{0} = (x_{0} + x_{1} +
x_{2} ) / 3
y_{1} = (x_{1} + x_{0} +
x_{1} ) / 3
y_{2} = (x_{2} + x_{1} +
x_{0} ) / 3
y_{3} = (x_{3} + x_{2} +
x_{1} ) / 3
… etc
As before, x_{1} and
x_{2} are taken to be zero.  This is similar to the previous example, with the

CENTRAL DIFFERENCE FILTER: y_{n} =
(x_{n} – x_{n2} ) / 2 This is similar in its effect to Example 4 . The output is equal to half the change in the input signal over the current value and value two time intervals prior:

y_{0} = (x_{0} – x_{2} ) /
2
y_{1} = (x_{1} – x_{1} ) /
2
y_{2} = (x_{2} – x_{0} ) /
2
y_{3} = (x_{3} – x_{1} ) /
2
… etc
The order of a digital filter can be defined as the number
of previous inputs (stored in the processor's memory) used
to calculate the current output.
This is illustrated by the filters given as examples in the
previous section.
 Example 1:Â y_{n} = x_{n}
 This is a zeroorder filter, since the current
output y_{n} depends only on the current input
x_{n} and not on any previous inputs.
 Example 2:Â y_{n} = Kx_{n}
 The order of this filter is again zero, since no
previous outputs are required to give the current output
value.
 Example 3:Â y_{n} = x_{n1}
 This is a firstorder filter, as one previous
input (x_{n1} ) is required to calculate
y_{n} . (Note that this filter is classed as
firstorder because it uses one previous input, even
though the current input is not used).
 Example 4:Â y_{n} = x_{n} –
x_{n1}  This is again a firstorder filter, since one
previous input value is required to give the current
output.
 Example 5:Â y_{n} = (x_{n} +
x_{n1} ) / 2  The order of this filter is again equal to 1 since it
uses just one previous input value.
 Example 6:Â y_{n} = (x_{n} +
x_{n1} + x_{n2} ) / 3  To compute the current output y_{n} , two
previous inputs (x_{n1} and
x_{n2} ) are needed; this is therefore a
secondorder filter.
 Example 7:Â y_{n} = (x_{n} –
x_{n2} ) / 2  The filter order is again 2, since the processor must
store two previous inputs in order to compute the current
output. This is unaffected by the absence of an explicit
x_{n1} term in the filter expression.
The order of a digital filter may be any positive integer. A
zeroorder filter (such as those in Examples 1 and
2 above) is possible, but somewhat trivial, since it does
not really filter the input signal in the accepted sense.
All of the digital filter examples given in the previous
section can be written in the following general forms:
Zero order:  y_{n} = a_{0} x_{n} 
First order:  y_{n} = a_{0} x_{n} + a_{1} x_{n1} 
Second order:  y_{n} = a_{0} x_{n} + a_{1} x_{n1} + a_{2} x_{n2} 
Similar expressions can be developed for filters of any
order.
The constants a_{0} , a_{1} ,
a_{2} , … appearing in these expressions are
called the filter coefficients. The values of these
coefficients determine the characteristics of a particular
filter.
The table below gives the values of the coefficients of
each of the filters given as examples in the previous
section.
Example  Order  a_{0} 
a_{1} 
a_{2} 

1  0  1  –  – 
2  0  K  –  – 
3  1  0  1  – 
4  1  1  1  – 
5  1  ^{1} /_{2}  ^{1} /_{2}  – 
6  2  ^{1} /_{3}  ^{1} /_{3}  ^{1} /_{3} 
7  2  ^{1} /_{2}  0  –^{1} /_{2} 
For all the examples of digital filters discussed so far, the
current output (y_{n} ) is calculated solely from
the current and previous input values (x_{n} ,
x_{n1} , x_{n2} , …). This type of filter
is said to be nonrecursive.
A recursive filter is one which in addition to input
values also uses previous output values. These, like the
previous input values, are stored in the processor's
memory.
Note: FIR and IIR filters Some people prefer an alternative terminology in which a nonrecursive filter is known as an FIR (or Finite Impulse Response) filter, and a recursive filter as an IIR (or Infinite Impulse Response) filter. These terms refer to the differing “impulse responses” of the two types of filter The impulse response of a digital filter is the output 

The word recursive literally means “running back”, and
refers to the fact that previouslycalculated output values go
back into the calculation of the latest output. The expression
for a recursive filter therefore contains not only terms
involving the input values (x_{n} , x_{n1} ,
x_{n2} , …) but also terms in y_{n1} ,
y_{n2} , …
From this explanation, it might seem as though recursive
filters require more calculations to be performed, since there
are previous output terms in the filter expression as well as
input terms. In fact, the reverse is usually the case. To
achieve a given frequency response characteristic using a
recursive filter generally requires a much lower order filter,
and therefore fewer terms to be evaluated by the processor,
than the equivalent nonrecursive filter. This will be
demonstrated later.
A simple example of a recursive digital filter is given
by
y_{n} = x_{n} + y_{n1}
In other words, this filter determines the current output
(y_{n} ) by adding the current input
(x_{n} ) to the previous output
(y_{n1} ).
 Thus:
 y_{0} = x_{0} + y_{1 } y_{1} = x_{1} + y_{0 } y_{2} = x_{2} + y_{1 } y_{3} = x_{3} + y_{2 } … etc
Note that y_{1} (like x_{1} )
is undefined, and is usually taken to be zero.
 Let us consider the effect of this filter in more detail.
If in each of the above expressions we substitute for
y_{n1} the value given by the previous
expression, we get the following: 
y_{0} = x_{0} + y_{1} =
x_{0 } y_{1} = x_{1} + y_{0} =
x_{1} + x_{0 } y_{2} = x_{2} + y_{1} =
x_{2} + x_{1} + x_{0 } y_{3} = x_{3} + y_{2} =
x_{3} + x_{2} + x_{1} + x_{0 } … etc
Thus we can see that y_{n} , the output at
t = nh, is equal to the sum of the current input
x_{n} and all the previous inputs. This filter
therefore sums or integrates the input values, and so has a
similar effect to an analog integrator circuit.
This example demonstrates an important and useful feature of
recursive filters: the economy with which the output values are
calculated, as compared with the equivalent nonrecursive
filter. In this example, each output is determined simply by
adding two numbers together.
 For instance, to calculate the output at time t =
10h, the recursive filter uses the expression  y_{10} = x_{10} + y_{9}
 To achieve the same effect with a nonrecursive filter
(in other words, without using previous output values stored in memory)
would entail using the expression 
y_{10} = x_{10} + x_{9} +
x_{8} + x_{7} + x_{6} + x_{5}
+ x_{4} + x_{3} + x_{2} +
x_{1} + x_{0}
This would necessitate many more addition operations, as
well as the storage of many more values in memory.
The order of a digital filter was defined earlier as the
number of previous inputs which have to be stored in order to
generate a given output. This definition is appropriate for
nonrecursive (FIR) filters, which use only the current and
previous inputs to compute the current output. In the case of
recursive filters, the definition can be extended as
follows:
 The order of a recursive filter is the largest
number of previous input or output values required to
compute the current output.
This definition can be regarded as being quite general: it
applies both to FIR and IIR filters.
 For example, the recursive filter discussed above, given
by the expression  y_{n} = x_{n} + y_{n1}
is classed as being of first order, because it uses one
previous output value (y_{n1} ), even though no
previous inputs are required.
In practice, recursive filters usually require the same
number of previous inputs and outputs. Thus, a firstorder
recursive filter generally requires one previous input
(x_{n1} ) and one previous output
(y_{n1} ), while a secondorder recursive filter
makes use of two previous inputs (x_{n1} and
x_{n2} ) and two previous outputs
(y_{n1} and y_{n2} ); and so on,
for higher orders.
Note that a recursive (IIR) filter must, by definition, be
of at least first order; a zeroorder recursive filter is an
impossibility.
From the above discussion, we can see that a recursive filter
is basically like a nonrecursive filter, with the addition of
extra terms involving previous outputs (y_{n1} ,
y_{n2} , and so on).
A firstorder recursive filter can be written in the general
form
y_{n} = (a_{0} x_{n} +
a_{1} x_{n1} – b_{1} y_{n1} )
/ b_{0}
Note the minus sign in front of the “recursive” term
b_{1} y_{n1} , and the factor (1/b_{0} )
applied to all the coefficients. The reason for expressing the
filter in this way is that it allows us to rewrite the
expression in the following symmetrical form:
b_{0} y_{n} + b_{1} y_{n1}
= a_{0} x_{n} +
a_{1} x_{n1}
In the case of a secondorder filter, the general form
is
y_{n} = (a_{0} x_{n} +
a_{1} x_{n1} + a_{2} x_{n2} –
b_{1} y_{n1} – b_{2} y_{n2} )
/ b_{0}
An alternative “symmetrical” form of this expression is
b_{0} y_{n} + b_{1} y_{n1}
+ b_{2} y_{n2} = a_{0} x_{n} +
a_{1} x_{n1} +
a_{2} x_{n2}
Note the convention that the coefficients of the inputs (the
x's) are denoted by a's, while the coefficients
of the outputs (the y's) are denoted by b's.
In the last section, we used two different ways of expressing
the action of a digital filter: a form giving the output
y_{n} directly, and a “symmetrical” form with all
the output terms (y's) on one side and all the input
terms (x's) on the other.
In this section, we introduce what is called the transfer
function of a digital filter. This is obtained from the
symmetrical form of the filter expression, and it allows us to
describe a filter by means of a convenient, compact expression.
The transfer function of a filter can be used to determine
many of the characteristics of the filter, such as its
frequency response.
The Unit Delay Operator
First of all, we must introduce the unit delay operator,
denoted by the symbol
z^{1}
When applied to a sequence of digital values, this operator
gives the previous value in the sequence. Therefore, it introduces a delay of one sampling interval.
Applying the operator z^{1} to an input
value (say x_{n} ) gives the previous input
(x_{n1} ):
z^{1} x_{n} = x_{n1}
 Suppose we have an input sequence

x_{0} = 5
x_{1} = 2
x_{2} = 0
x_{3} = 7
x_{4} = 10
 Then

z^{1} x_{1} = x_{0} = 5
z^{1} x_{2} = x_{1} = 2
z^{1} x_{3} = x_{2} = 0
and so on. Note that z^{1} x_{0}
would be x_{1} which is unknown (and usually
taken to be zero, as we have already seen).
Similarly, applying the z^{1} operator to an
output gives the previous output:
z^{1} y_{n} = y_{n1}
Applying the delay operator z^{1} twice
produces a delay of two sampling intervals:
z^{1} (z^{1} x_{n} ) =
z^{1} x_{n1} = x_{n2}
We adopt the (fairly logical) convention
z^{1} z^{1} = z^{2}
in other words, the operator z^{2}
represents a delay of two sampling intervals:
z^{2} x_{n} = x_{n2}
This notation can be extended to delays of three or more
sampling intervals, the appropriate power of
z^{1} being used.
Let us now use this notation in the description of a
recursive digital filter. Consider, for example, a general
secondorder filter, given in its symmetrical form by the
expression
b_{0} y_{n} + b_{1} y_{n1}
+ b_{2} y_{n2} = a_{0} x_{n} +
a_{1} x_{n1} +
a_{2} x_{n2}
We will make use of the following identities:
y_{n1} = z^{1} y_{n}
y_{n2} = z^{2} y_{n}
x_{n1} = z^{1} x_{n}
x_{n2} = z^{2} x_{n}
Substituting these expressions into the digital filter
gives
(b_{0} + b_{1} z^{1} +
b_{2} z^{2} ) y_{n} = (a_{0} +
a_{1} z^{1} + a_{2} z^{2} )
x_{n}
Rearranging this to give a direct relationship between the
output and input for the filter, we get
y_{n} / x_{n} = (a_{0} +
a_{1} z^{1} + a_{2} z^{2} ) /
(b_{0} + b_{1} z^{1} +
b_{2} z^{2} )
This is the general form of the transfer function for a
secondorder recursive (IIR) filter.
For a firstorder filter, the terms in z^{2}
are omitted. For filters of order higher than 2, further terms
involving higher powers of z^{1} are added to
both the numerator and denominator of the transfer
function.
A nonrecursive (FIR) filter has a simpler transfer function
which does not contain any denominator terms. The coefficient
b_{0} is regarded as being equal to 1, and all
the other b coefficients are zero. The transfer function
of a secondorder FIR filter can therefore be expressed in the
general form
y_{n} / x_{n} = a_{0} +
a_{1} z^{1} + a_{2} z^{2}
Transfer Function Examples

The threeterm average filter, defined by the
expressiony_{n} = ^{1} /_{3}
(x_{n} + x_{n1} + x_{n2} )can be written using the z^{1} operator
notation asy_{n} = ^{1} /_{3}
(x_{n} + z^{1} x_{n} +
z^{2} x_{n} )= ^{1} /_{3} (1 + z^{1} +
z^{2} ) x_{n}The transfer function for the filter is therefore
y_{n} / x_{n} = ^{ 1} /_{3} (1 + z^{1} +
z^{2} ) 
The general form of the transfer function for a
firstorder recursive filter can be writteny_{n} / x_{n} = (a_{0} +
a_{1} z^{1} ) / (b_{0} +
b_{1} z^{1} )Consider, for example, the simple firstorder recursive
filtery_{n} = x_{n} + y_{n1}
which we discussed earlier. To derive the transfer
function for this filter, we rewrite the filter expression
using the z^{1} operator:(1 – z^{1} ) y_{n} = x_{n}
Rearranging gives the filter transfer function as
y_{n} / x_{n} = 1 / (1 –
z^{1} ) 
As a further example, consider the secondorder IIR
filtery_{n} = x_{n} + 2x_{n1} +
x_{n2} – 2y_{n1} + y_{n2}Collecting output terms on the left and input terms on
the right to give the “symmetrical” form of the filter
expression, we gety_{n} + 2y_{n1} – y_{n2} =
x_{n} + 2x_{n1} + x_{n2}Expressing this in terms of the z^{1}
operator gives(1 + 2z^{1} – z^{2} ) y_{n} =
(1 + 2z^{1} + z^{2} ) x_{n}and so the transfer function is
y_{n} / x_{n} = (1 + 2z^{1} +
z^{2} ) / (1 + 2z^{1} –
z^{2} )
Acknowledgments
This article originally appeared on Dr. Iain A. Robin's DSP site (www.dsptutor.freeuk.com).

0 comments on “Digital Filters: An Introduction”