Você está na página 1de 3

NEWCASTLE UNIVERSITY

SCHOOL OF MECHANICAL & SYSTEMS ENGINEERING


MEC3015
Mod.Ref.

Instrumentation and Drives


Mod.Title

FILTERS tutorial #2

Sheet No.

As soon as you get MATLAB/Simulink running


youll find it more convenient to adjust (reduce) the
1/(R*C)
sizes of each window so that they all fit onto the
Sine Wave
s+1/(R*C)
Scope
widescreen and are not hidden/obscured this will
Add
Transfer Fcn
make it much easier to see what is happening.
output
SIMULINK
To Workspace
time
Signal
1. Build the first-order low pass filter model shown
Clock
Generator
To Workspace1
opposite. Well use the Sig Gen to superpose
noise on the Sine signal. Set the cut-off frequency = 1/(R*C) in the transfer function, using the values
R=10k and C=1F (as set via Command window). Open the Sig Gen function and set the waveform
to random, amplitude = 0.1, and frequency = 1000 (units rads/s) then close it. Open the Sine function
and set the frequency = 10 (rads/s). Run the model you should observe the phase lag and attenuation
albeit on a rather jagged scope plot (again down to the max step size being set to auto).
2. Pull down the Simulation tab and select the Configuration parameters tab (you can also use Ctrl E).
Now choose the Fixed-step solver option, and select the ode4 (Runge-Kutta) solver, and set the fixed
step to 0.001. [Note: the solver is the integration algorithm that Simulink uses when it runs the model.]
3. You can adjust the scope plot by modifying the Parameters tab (top 2nd left)

4. select Data History and uncheck limit data points. Before running the model again Autoscale the
plot

and then the save current axes tab.

5. Replace the low-pass Transfer Function with this high-pass one;

and run the model. How does the output compare with the input? Change the Sine input frequency
to 1 rad/s, and run the model again. Confirm that the noise component is still present, and that the
low-frequency 1 rad/s is removed.

MEC3015
Departmental Ref.

Nov 2012
Revise Date

Peter Cumpson
Lecturer

Page 1 of 3

Frequency Response using Bode function


6. In the MATLAB Command window set w=100, then create the first order low-pass transfer function
w
firstLP=
using the procedure from last week.
sw
quick reminder of how to do this: From the MATLAB Command window:
>num = [0 w]
>den = [1 w]
Then define the transfer function:
>firstLP = tf(num,den) which should then display
100
------s + 100

7. Run the Bode function


>bode(firstLP)

to obtain the corresponding frequency response plot. The cut-off frequency should be at 100rad/s
(corresponding to -3dB at -45 phase shift). Copy this plot (e.g. into a new Word document) so that
you can compare with it later.
s
8. Hold the plot (>>hold on), and create the first order high-pass transfer function firstHP=
. Now
sw
obtain the Bode plot for firstHP. Your plot should show symmetrical magnitude plots for the LP and
HP filters, about the w frequency, both with 90 phase shifts.
9. Now cascade the two functions as follows >>bode(firstLP*firstHP). Your Bode plot should show a
bandpass filter, with w centre-frequency note how it attenuates signals either side of this centrefrequency, and is -6dB down at w.
10.
Release the plot (>>hold off), and run the bode function once again using firstLP. Hold the plot.
11.
Now well cascade this function as follows >>bode(firstLP*firstLP). Notice how the attenuation
at the cut-off frequency is now -6dB, with the high-frequency roll-off increasing to 40dB/decade, and
that the phase shift has increased to -180.

MEC3015
Departmental Ref.

Nov 2012
Revise Date

Peter Cumpson
Lecturer

Page 2 of 3

Second Order (active) filter


2
1. The TF shown opposite is of a 2nd order unity gain LP active filter. Set the filter
cut-off frequency w=100, and zeta=1. Now create the TF in MATLAB calling it s 2 2 s 2
secondLP and obtain the frequency response. Note that at frequency w there is
a -6dB attenuation. What value of zeta gives a -3dB drop at this frequency?
Compare this plot with that obtained in step 7 on page 2.
s2
nd
2. Now create a 2 order HP filter, called secondHP using the TF opposite, and
s 2 2 s 2
plot the Bode diagram with the same value of zeta for w=100.
3. Now cascade the 1st through to 4th order LP filters (see
opposite) using Bode (put hold on). What is the
relationship between the asymptotic roll-off rate (as a
function of frequency) and phase shift, as the filter order
increases? Note the asymptote should pass through the
corner frequency.
4. On Blackboard you will find an m-file called
secondLP.m. This file models 7 of the most recognised
shape options of filter design (see below) - copy this file to
your MATLAB working directory, then open it in
MATLAB. You will notice that Ive set the cut-off
frequency f=1000. Before you run this file release the
previous figure (hold off) then run it using the
icon on the editor toolbar.
5. Replace the comment symbol (%) at the beginning of the 3rd line the % symbol in MATLAB is used
to ignore all text to its right on a line. Now progressively activate each line in turn by removing the %
character, and then run the m-file. Reinstate the % character and repeat this procedure for each
successive line of the remaining filters. Your Bode plot should now show all 7 different filter types.
Expand the figure and check to see if the cut-off frequency is the same for each filter (at -3dB). Log
onto Blackboard and open the file FilterParameters.pdf (in the TeachingMaterials>Tree Cluster Filter
Tutorials folder). A copy of this is stapled to the end of the hardcopy of this tutorial document.
6. Check out the frequency and Damping parameters in the Table 1 they should correspond with the
values in the m-file. [Note the value of the Damping term is 2xZeta].
7. Having established the 2nd order LP filter response, now modify the m-file so that it models the
equivalent 3rd order LP filters (see the corresponding 3rd order filter parameters in Table 2 of the
FilterParameters file). You will need to create an additional 1st order section which has to be cascaded
with the 2nd order section First change the frequency and damping terms (f1 and d1) on each of the
7 lines (corresponding to the second-order section in Table 2), AND then add the f2 term on each
line for the corresponding first-order section. Now insert a new line (just below line 11) and enter
first=tf(f2, [1 f2]) and then cascade this into the bode function by replacing bode(second) with
bode(first*second). Save this as thirdLP.m. Now run third, by once again releasing the previous plot
and then proceeding to work through each filter type in turn. Check that the magnitude plots all pass
through the -3dB point at the frequency f. Get some practice copying the figure to a Word document,
adding a line of text to describe each plot.
8. If you have the time (and the inclination) try the extending the m-file to a 4th order filter. You can also
go on to develop the high pass equivalents, and for that matter bandpass variants.
Filter Shape Options these are the most common filter designs and can be extended up to nth order.
[***recommend that you check these out on Wikipedia, along with filter terminology***]
Best-time delay Filter Sometimes called a Bessel filter
Compromise Filter Paynter or transitional Thompson-Butterworth filter
Flattest-Amplitude Filter Butterworth filter. Has the flattest passband, and is often best overall choice.
Note that all cascaded sections have the same frequency
Slight-dips Filter Chebyshev filter with a small peaking and ripple
One-dB-dips Filter Chebyshev filter with 1dB passband ripple
Three-dB-dips Filter - Chebyshev filter with 3dB passband ripple
MEC3015
Page 3 of 3
Nov 2012
P J Cumpson
Departmental Ref.

Revise Date

Lecturer

Você também pode gostar