You are on page 1of 38

EE3001 - Advanced Measurements

Digital Filters

Dr. H. M. Wijekoon
Chief Engineer (Transmission Planning)-R3

DGM (Planning and Development) Branch-Region 3


644, Sri Jayawardanapura Mawatha
Ethulkotte

1
Filters
 Filters may be classified as either digital or analog.
 Digital filters are implemented using a digital computer or
special purpose digital hardware.
 Analog filters may be classified as either passive or active and
are usually implemented with R, L, and C components and
operational amplifiers.
 An active filter is one that, along with R, L, and C components,
also contains an energy source, such as that derived from an
operational amplifier.
 A passive filter is one that contains only R, L, and C components.
It is not necessary that all three be present. L is often omitted
(on purpose) from passive filter design because of the size and
cost of inductors – and they also carry along an R that must
be included in the design.
 Generally speaking, digital filters have become the focus
of attention in the last 40 years. The interest in digital
filters started with the advent of the digital computer,
especially the affordable PC and special purpose signal
processing boards. People who led the way in the work
(the analysis part) were Kaiser, Gold and Radar.

 A digital filter is simply the implementation of an


equation(s) in computer software. There are no R, L, C
components as such. However, digital filters can also be
built directly into special purpose computers in hardware
form. But the execution is still in software.
Signals
 Real signals are comprised of a number of frequencies. Some
signals may contain both high frequency and low frequency
components.
 Depending on the application, some frequencies may be
undesirable, such as a low frequency AC power supply hum or
interference from some other source.
 Filters can be used to remove these undesirable frequency
components.
 As an example, the signal shown on the above diagram has five
components, marked in increasing frequency order, f1 to f5.
A filter could be used to remove f1 and f2.
 The circuit shown at the top right acts as a filter that will remove
most of the frequencies f1 and f2 so that only the higher
frequencies f3, f4 and f5 remain..
The main filter types are as follows:
Low-pass Filters (LPF) - These filters pass low frequencies and
stop high frequencies.
lowpass

Ideal Practical

High-pass Filters (HPF) - These filters pass high frequencies and


stop low frequencies.
highpass highpass
Band pass Filters (BPF) - These filters pass a range of frequencies
and stop frequencies below and above the set range.
bandpass bandpass

Band-Stop Filters (BSF) - These filters pass all frequencies except the
ones within a defined range.
bandstop bandstop

All-Pass Filters (APF) - These filters pass all frequencies, but they
modify the phase of the frequency components.
High Pass

Gain and Phase Response


 H(w) is a frequency-dependent complex function. This means
that the gain and phase will vary with frequency.

 Since both gain and phase equations contain frequency-


dependent components, it is natural to expect both to be
frequency- dependent.

 This frequency dependence is used to our advantage in filtering.


Cut-Off Frequency
Cut-off frequency is defined as the frequency where the gain of
the filter falls to 1/ 2 = 1/ 1.414 = 0.707 of its value in the pass
band. It is also referred to as the -3dB point since (20log10 (0.707)
= -3).
Digital Filters
Mapping from s-plane to z-plane (from last lecture)
𝑆𝑖𝑛𝑐𝑒 𝑧 = 𝑒 𝑠𝑇 = 𝑒 (𝜎+𝑗𝜔)𝑇 = 𝑒 𝜎𝑇 𝑒 𝑗𝜔𝑇 𝑤ℎ𝑒𝑟𝑒 𝑇 = 2𝜋/𝜔𝑠
we can map the s-plane to the z-plane as below:
Frequency Response from pole-zero locations
The transfer function H[z] can be expressed in factorized polynomial

o We have established that the frequency response is given by


o Therefore we can compute the frequency be evaluating H[z] at
z=ejΩ, which is the unity circle.
o Each term (z-zi) can be evaluated as shown:
 Therefore, for all the poles and zeros, we can use the graphical
method (similar to the s-plane case):

 The amplitude response is:


𝑧 − 𝑧1 𝑧 − 𝑧2 𝑧 − 𝑧3 … … … (𝑧 − 𝑧𝑛 )
𝐻 𝑍 = 𝑏0
𝑧 − 𝛾1 𝑧 − 𝛾2 𝑧 − 𝛾3 … . . (𝑧 − 𝛾𝑛 )

𝑟1 𝑟2 𝑟3 …………………..𝑟𝑛
H[𝑒 𝑗𝜔 ] = 𝑏0
𝑑1 𝑑2 𝑑3 …………….𝑑𝑛

 The phase response is:


Pole-Zero locations & Filtering
Therefore, for all the poles and zeros, we can use the graphical
method (similar to the s-plane case):
Digital Filters
We will now examine digital filters, starting with a simple example -
a moving average filter (see flow diagram below). Let us first
identify the major components of a digital filter

The Input x(n)


The input of a digital filter is a series of discrete samples obtained by sampling
the input waveform. The sampling rate must meet the Nyquist criteria that we
covered in our sampling lecture (highest frequency of input signal < = 1/2 x
sampling frequency). The term x(n) means the input at a time (n).
Z -1 Unit Delay
Z-1 represents a time delay that is equal to the sampling period. This is also
called a unit delay. Therefore, each z box delays the samples for one sampling
period. In the diagram, this is shown by the input going into the delay box as
x(n) and coming out as x(n-1). We see this because x(n) means the input at a
time (n), and x(n-1) means the input at time (n-1). What actually happens is
that x(n-1) is the previous input that has been
saved in the memory of the DSP

Filter Taps and Weights


The output of each delay box is called a tap. Taps are usually fed into scalers
which scale the value of the delayed sample to the required value by multiplying
the input (or delayed input) by a coefficient. In the diagram, these are marked as
b0, b1 and b2. The scaling factor is called the weight. In mathematical terms, the
weight is multiplied by the delayed input, so the output of the first tap is
b0*x(n). The next tap output will be b1*x(n-1), and the output of the last tap is
b2*x(n-2).
Summing Junctions
The output of the weights are fed into summing junctions, which
add the weighted, delayed, forward-fed forward outputs from
taps. So in this example, the output of the first summing junction
is b0*x(n) + b1*x(n-1). At the next summing junction, this is
added to the output of the final tap, giving b0*x(n) + b1*x(n-1) +
b2*x(n-2), which is the output.
The Output y(n)

The output of a digital filter is a combination of a number of


delayed and weighted samples, and is usually called y(n).

y(n) = b0*x(n) + b1*x(n-1) + b2*x(n-2)


Linear Time-Invariant Digital Filters
 Linear time-invariant (LTI) filters are a class of filters whose
output is a linear combination of the input signal samples and
whose coefficients do not vary with time.
 The linear property entails that the filter response to a weighted
sum of a number of signals, is the weighted sum of the filter
responses to the individual signals.
 This is the principle of superposition. The term time invariant
implies that the filter coefficients and hence its frequency
response is fixed and does not vary with time.
 In the time domain the input-output relationship of a discrete-
time linear filter is given by the following linear difference
equation:
Recursive and non-Recursive Filters
There are two categories of digital filter: the recursive filter and
the non-recursive filter.

These are often referred to as infinite impulse response (IIR)


filters and finite impulse response (FIR) filters, respectively

a recursive filter is a type of filter which re-uses one or more of


its outputs as an input.

This feedback typically results in an unending impulse response


(commonly referred to as infinite impulse response (IIR).

a recursive filter does not always have an infinite impulse


response. Some implementations of moving average filter are
recursive filters but with a finite impulse response
Recursive and non-Recursive Filters
 The transfer function of the filter is the ratio of two
polynomials in the variable z and may be written in a cascade
form as

 where H1(z) is the transfer function of a feed-forward, all-


zero, filter given by

 and H2(z) is the transfer function of a feedback, all-pole,


recursive filter given by
Non-Recursive or Finite Impulse Response (FIR) Filters
 A non-recursive filter has no feedback and its input-output
relation is given by

 The output y(m) of a non-recursive filter is a function only


of the input signal x(m).
 The response of such a filter to an impulse consists of a finite
sequence of M+1 samples, where M is the filter order.
 Hence, the filter is known as a Finite-Duration Impulse Response
(FIR) filter.
 Other names for a non-recursive filter include all-zero filter,
feed-forward filter or moving average (MA) filter a term usually
used in statistical signal processing literature.
Recursive or Infinite Impulse Response (IIR) Filters

o A recursive filter has feedback from output to input, and in general


its output is a function of the previous output samples and the
present and past input samples as described by the following
equation

o In theory, when a recursive filter is excited by an impulse, the


output persists forever.

o Thus a recursive filter is also known as an Infinite Duration


Impulse Response (IIR) filter.
 Figure shows a particular case of an IIR filter when the output is a
function of N previous output samples and the present input
sample given by
Filtering, Convolution
 it follows that the operation of filtering of a signal x(m) can be
mathematically expressed as the convolution of the input
signal and the impulse response of the filter h(m) as

 The filtering, or convolution operation, is composed of the


following four sub-operations:

(1) Fold the signal x(k) to yield x(-k), this is done because the samples with
the earliest-time index (i.e. most distance past) go into filter first.
(2) Shift the folded input signal x(-k) to obtain x(m-k).
(3) Multiply x(m-k) by the impulse response of the filter h(k).
(4) Sum the results of the vector product h(k)x(m-k) to obtain the filter
output y(m).
𝑧
Ex: Using only the fact that 𝛾𝑘𝑢 𝑘 ↔ and properties of the
𝑧−𝛾
z−transform, find the z−transform of:

Ex02: By applying the time-shift property of z-transform, find the z-


transform of the signal x[n] as shown in Fig. Q2.
Hint: x[n] = n{u[n] – u[n-6]}.
Ex03: Show a canonical realization of the following transfer functions:

EX04: Draw a diagram showing the realization of a digital system


whose transfer function is given by:

Ex05:Derive the amplitude and phase response of the digital filters


shown in Fig.Q5(a) and (b).
Ex06: a) Realize a digital filter whose transfer function is give by

b) Choose a value of K such that H[1] = 1. The amplitude response


has a maximum value of Ω = 0, and it decreases monotonically with
frequency until Ω = π. The 3-dB bandwidth is the frequency where
the amplitude response drops to 0.707. Determine the 3-dB
bandwidth of this filter when a = 0.2.
Ex07:Pole-zero configurations of two filters are shown in Fig.
Q7(a) and (b). Sketch roughly the amplitude and the phase
responses of these filters

Ex08: Design a digital notch filter to reject frequency 5000 Hz


completely, and to have a sharp recovery on either sides of 5000 Hz
to a gain of unity. Assume that the sampling frequency is 40 kHz.
Ex09: a) Show that the amplitude response of a system with a pole
at z = r and a zero at z = 1/r (r is less than or equal to 1) is constant
with frequency (this is called an “allpass” filter).

b) Generalize the result from a) to show that a digital LTI system


1 ±𝑗𝜃
with two poles at 𝑧 = 𝑟𝑒 ±𝑗𝜃 and two zeros at 𝑧 = 𝑒 (r  1) is
𝑟
also an allpass filter.
Example
Derive the amplitude response of a discrete-time system having a
sampling frequency of 1000 Hz, and with zeros at (z=1) and (z=-1),
and poles at

Hence Ω=π/4 corresponds to ω=250π or f =125Hz.