Pre Lab
Pre Lab
png
23
1
7/
2
Contents
Abstract 4
Introduction 4
Theory 4
Objectives 5
Procedure 6
Discussion Questions 7
Specification Requirements 8
Conclusion 11
3
Abstract
In this lab we looked into designing Filter Design and analysis tool. With the given specifics we
designed butterworth filter and chebyshew type I filter. On part B of the lab we simulated one of
the filters in part A for a finite duration in non-real time using Simulink. Also generated and tested
sine waves with different frequencies to see several periods of the sine wave. Finally we measured
the effectiveness of of the noise filtering approach using basic simulink blocks.
Introduction
In this lab we will design digital-selective filters to be used to remove or filter out noise from a
signal. We do the filter design and testing techniques using MATLAB/simulink.(1)
There are several techniques for designing filters. Lowpass filter design is another technique whereby
frequency domain is visualised as a rectangular function, although having its own inadequacies it is
not ideal for use in real life filters, another technique is using Windowing technique though it also
has some shortcomings since design parameters cannot be controlled independently. One can also
use z-transformation techniques to design filters such as impulse response, bilinear transformation
and unmatched z-transformation techniques.(2)
We use MATLAB GUI driven filter design program which only requires us to click a few buttons.
This simpler tools are the FDA TOOL AND THE SIMULINK. The Filter Design and Analysis Tool
(FDATool) is a powerful user interface for designing andanalyzing filters quickly. FDATool enables
you to design digital FIR or IIR filters by setting filterspecifications, by importing filters from your
MATLAB workspace, or by adding, moving or deletingpoles and zeros. FDATool also provides
tools for analyzing filters, such as magnitude and phaseresponse and pole-zero plots. FDATool
seamlessly integrates additional functionality from otherMathWorks products as described in the
following table. Use FDATOOL in matlab. fdatool incommand window, FDAtool will be opened.
There you can select FIR or IIR filter, order of filterand cutoff frequency of a filter (either HPF,
LPF or BPF).(3) That code will automatically generate.m file for you. the following user interface
will pop up;
Theory
Recall the concept of the ideal lowpass filter, which is simply visualized in the frequency domain
as the rectangle function (of a specified width and centered at the origin). Also recall that this
filter, although handy in theory, is not implemented in practice. There are several reasons why
ideal (lowpass, bandpass, highpass, and band-stop) filters are not used in real-life: 1. The impulse
response, h(n) is non-causal as a consequence of the Paley-Wiener theorem, which implies these
filters cannot be implemented in practice on a DSP. Another way to think about this is that
h(n) has infinite support for any of the ideal filters. Thus, it cannot be zero for n ¡ 0 making it
necessarily non-causal. 2. When implemented in software or hardware, due to the finite number
of elements employed for processing, an ideal filter exhibits the undesirable Gibbs phenomenon.
In signal and image processing, this shows up as the infamous ringing effect, i.e. it introduces
extra unwanted artifacts. To bypass the above inadequacies, the design of digital filters using
the windowing technique is an alternative to ideal filters. These filters can be implemented as
FIR filters, and make use of the wellknown Bartlett, Blackman, Hamming, Hanning, and Kaiser
windows. The shortcoming of digital filter design via windowing techniques is that one cannot
individually control the design parameters of the filter. For example, in Figure 1, p (pass-band
frequency) and s (stop-band frequency) cannot be independently controlled using the windowing
technique.
By making the transition band (frequencies between p and s) narrower, you must make a sacrifice in
the form of larger undesirable ripples in the pass-band (frequencies between 0 and p) and Passband
ripple Stopband ripple Passband edge frequency Stopband edge frequency Passband edge frequency
Stopband edge frequency Passband ripple Passband Stopband Transition band
4
stop-band (frequencies exceeding s); that is smaller s - p necessitates 1 and 2 larger These tradeoffs
are all due to bypassing the two inadequacies of ideal filters. The above specifications are general
and do not delineate the form of the digital filter. In practice we would prefer either a rational
system function corresponding to FIR or IIR filters discussed in the lectures. Thus we consider
using the difference equation, or ARMA (autoregressive moving average) model given in (1) and
(2) representing the descriptions in the time- and frequency-domain, respectively.
N
X M
X
y(n) = − ak y(n − k) + bk x(n − k)
K=1 K=0
PM
K=0 bk x(k)
H(z) = PN
K=1 ak
Figure 1: FDAToolExample
Objectives
• introduces you to filter design and testing techniques using MATLAB/simulink
• To give us an understanding of the filter design techniques automated in MATLAB via the
filter design and analysis tool (FDAT)
• To gain a deeper understanding of the filter design techniques automated in PYTHON via
PyFDA
5
Specification Requirements
• Sampling rate =8kHz
• passband frequency=1kHz
• Stopband frequency = 1.4kHz
• Attenuation at passband =1dB
• Attenuation at stopband =80dB
tasks, assuming Sampling rate is 8kHz
Procedure
In FDAtool perform the following
1. Design a minimum order, stable, lowpass butterworth filter with passband 1kHz and a stop-
band of 1.4kHz. Make the attenuation 1dB at the passband frequency frequency and 80dB
at the stopband frequency.
2. Design a minimum order, stable, lowpass Chebyshew type I filter with the same specifications
as the butterworth filter
6
Figure 3: Chebyshew type I filter
3. Design a low pass FIR filter using the Blackman window with a cutoff frequency of 1kHz.
specify the order of the filter such that the first minimum in the stopband (preceeding the
first lobe) is as close to 1.4 as possible without exceeding it.
Discussion Questions
• what is the order of the lowpass butterworth filter you designed?
Ans: 0rder 26
• what is the order of the chebyshew type I filter you designed?
Ans: Order 12
7
• Compare the memory usage of each of the 3 filters assuming a direct form II realization is
employed. Do you see how inefficient the windowing technique is ? How much more expensive
in terms of memory is the windowing technique from the best IIR filter?
Ans: the windowing technique is inefficient because it produces more ripples on the filter
when compared to the butterworth and chebyshew type I filters.
Specification Requirements
input for the filter is a noisy sinusoid with following specifications
• Sampling rate =8000
• passband frequency=3800
• Stopband frequency =3600
• Attenuation at passband =1dB
• Attenuation at stopband =60dB
In this section, simulate each one of the filters you designed for a finite duration in nonreal-time.
Open a new Simulink model and construct a block diagram similar to that shown in Figure 3
below. Before your begin, please note the following about the block diagram:
8
and the filter parameters used for generating the noise. Write down any observation that you may
have about the signals and interpret the obtained results.
1. Generate and test sine waves with frequencies in the following regions. For each frequency,
set the stop time of the simulation so that you can see several periods of the sine wave.
For these tests, you can disconnect the noise from the input signal and terminate it with a
Terminator block.
9
Figure 8: FIR NOISE SIGNAL DISCONNECTED
2. Reconnect the noise to the input signal. Change the frequency of the sine wave to be in the
passband and set the stop time of the simulation appropriately. Add noise to the sine wave
whose frequency is in the following three regions (Note: in order to contain the noise to the
correct region, you’ll have to change the filter after the noise generator to the appropriate
highpass, lowpass, or bandpass filter):
10
Figure 10: NOISE SIGNAL
Conclusion
this lab was a success since we managed to design different filters using the fdatool, where we also
got to grasp the basics of how to use the matlab tool. We designed a filter with a noise signal
altered at different frequencies and managed to get an observation of the different output waves
displayed when a signal is combined with that of a noise signal.
References
[1] V. K. J. G.Proakis, Digital Signal Processing using Matlab, 2010.
[2] D. N. Art, Digital Signal Digital Signal, 2012.
[3] Xilinx In, “Vivado Design Suite Tutorial Model-Based DSP Design Using System Generator,”
Ug 835, vol. 835, pp. 1–1557, 2016.
11