Sie sind auf Seite 1von 12

Lab 4 Discrete-time structures: Finite

Impulse Response (FIR) filters

Achievements in this experiment

You will be able to relate the response of a discrete-time (DT) FIR filter to its transfer
function. You will use the zeros of the transfer function to visualize frequency responses
graphically at a glance, without math. You will be able to use this knowledge to intuitively
design low order discrete-time responses. You will be ready to extend this concept to
recursive DT filters and to higher order applications.

Preliminary discussion

In Lab 11 we used poles and zeros as an intuitive aid in working with continuous-time filters. In
this Lab we apply the same idea for discrete-time applications. DT filters can be implemented
with or without the use of feedback. The latter filters are generally known as nonrecursive
or Finite Impulse Response (FIR).

The transfer function of a nonrecursive filter can be expressed as a polynomial. Since there is
no denominator, there are no poles, only zeros, which makes it simpler for getting started. As
with the continuous-time case, you can intuitively predict and track system responses from the
zeros.

The absence of feedback is an important advantage in many applications as there is no risk of


unstable behaviour. This is very useful when working with adaptive filters.

Serious practical realizations of FIR filters generally require a large number of delay elements.
The most demanding are the bandpass. However, the notch filter works well as a two-delay
FIR example. We will use this example here to examine the relationship between the
frequency response and the coefficient values through the interpretation of zero positions in
the z plane.
Preparation

This preparation provides essential theory needed for the lab work to make sense.

Question 1
Consider the system in Figure 1, where nT are the discrete-time points, with T sec denoting the
unit time delay, i.e. the time between samples. Show that the difference equation relating the
output y(nT) and the input u(nT) is

Y(nT) = b0.u[nT] + b1.u[(n - 1)T] + b2.u[(n - 2)T] (Eqn 1).

Show by substitution that ejnT is a solution, i.e. show that when the input is ejnT , y(nT) is
ejnT multiplied by a constant (complex-valued); is the frequency of the input in
radians/sec.

+
OUTPUT

b0 b1 b2

INPUT
UNIT UNIT
DELAY DELAY

Figure 1: schematic of FIR filter with two unit delays

In Lab 11 we used a complex exponential input to represent the behaviour of a system that is
supposed to operate with real-valued signals. You could consider using u[nT] = cos(nT ) or
sin(nT ) instead. However, the use of the exponential function simplifies the math
considerably. We have already seen that cos( t) is Re{exp(j t)}, so, you can carry out the
analysis with ejnT , then simply take the real part of the result. After a while, working with
complex exponential functions to represent sinusoids becomes second nature and we don't even
bother thinking about taking the real part. Many practical systems implemented digitally
actually operate with complex-valued signals, for example modulators and demodulators
working with quadrature signals.

From the above, with input u(nT) = ejnT , show that

H = y/u = b0 + b1. e-jT + b2. e-j2T (Eqn 2).

Note that H is not a function of n.

Question 2
Use this result to obtain a general expression for the magnitude of y/u as a function of . You
will need to first write down the real and imaginary parts.
Set T = 1 sec for the time being, and plot the result for the case b0 = 1, b1 = -1.3 ,
b2 = 0.9025
over the range = 0 to 2. rad/sec. Label the frequency axis in Hz as well as
rad/sec. You should find there is a significant dip in the response near 0.13Hz.

Question 3
As in Lab 7, we consider an alternative way of getting frequency responses. We will create a
graphical medium to provide an intuitive environment for visualizing and generating both
magnitude and phase responses.

First, return to the expression for y/u obtained in (a) and replace "exp(jT )" by the symbol
"z". Look upon z merely as a convenient macro for exp(jT ) . At this point there is no need to
ascribe any deeper significance to this substitution. The result is the (complex-valued)
polynomial

y/u = H(z) = b0 + b1.z-1 + b2.z-2 = z-2 . [b0. z2 + b1.z + b2 ] (Eqn 3).

For the case b0 = 1, b1 = - 1.3 , b2 = 0.9025 (from (Q2)), express the quadratic in the brackets
in the factored form (z - z1)(z - z2), where z1 and z2 are the roots. Show that these are given
by

z1 = 0.95e j0.260
z2 = 0.95e -j0.260 (Eqn 4).

Satisfy yourself that the magnitude response of H can be expressed as

|H( )| = |(ejT - z1)|.|(ejT - z2)| (Eqn 5).

Write down the corresponding expression for the phase of H.

Question 4: Graphical plotting of poles & zeros

We are now ready to proceed with a graphical approach for evaluating the factors (z - z1) and
(z - z2) in Eqn 3. Place an "o" on a complex plane (we will refer to this as the z plane) at the
locations corresponding to z1 and z2, as obtained in Eqn 4. With T = 1, we will get an estimate
of |H| at = /5.

Place a dot at the point ej /6. Join this point and the point z1 with a straight line. The length of
this line is |(ej /5- z1)|.
Do the same with z2 to obtain |(ej /5 - z2)|. From Eqn 5, the desired estimate of |H( /5)| is
simply the product of the lengths of these two lines.

Question 5
By repeating this for other values of we are able to get a quick estimate of the graph of |H|
versus . It's important to note that the locus of ejT is a circle of unity radius centered at
the origin (known as the unit circle). Hence, the general shape of the frequency response is
easily estimated by simply running a point counter-clockwise along the circumference of the
unit circle, starting at (1, 0). Note that the idea is just a variant on the procedure introduced
in Lab 11, where we moved the frequency point along the j axis. Compare the outcome with the
result computed in (Q2).

Notice that the presence of the trough in the response can be seen at a glance from the
behaviour of the vector from the "zero" z1 as the dot on the unit circle is moved near z1. By
comparison, the rate of change of the other vector is small over that range.

Question 6

Modify Fig 1 by replacing the unit delays with a gain of 1/z and show that Eqn 3 follows by
inspection using simple algebra, without the need to work through the difference equation
step. While this is only a minor simplification in this example, it is very useful in more
complicated cases, especially where feedback loops are involved.

Although z was originally introduced in (Q3) as just a substitution for ejT , our interpretation
appears to have been extended in (Q4) to include any complex number. Consider whether this
is the case, and why.

Question 7
In the above example, we had the sample interval T = 1. Suppose T = 125 microsec. Adjust the
frequency axis for this value of T. Extend this result for any value of T. How are the zeros of
H(z) affected by the value of T? Why is it appropriate to use T = 1 normally?

Show that |H( )| is periodic, and determine the period in Hz.



Equipment

PC with LabVIEW Runtime Engine software appropriate for the version being used.

NI ELVIS 2 or 2+ and USB cable to suit

EMONA SIGEx Signal & Systems add-on board

Assorted patch leads

Two BNC 2mm leads

Procedure
Part A Setting up the NI ELVIS/SIGEx bundle

1. Turn off the NI ELVIS unit and its Prototyping Board switch.

2. Plug the SIGEx board into the NI ELVIS unit.

Note: This may already have been done for you.

3. Connect the NI ELVIS to the PC using the USB cable.

4. Turn on the PC (if not on already) and wait for it to fully boot up (so that its ready to
connect to external USB devices).

5. Turn on the NI ELVIS unit but not the Prototyping Board switch yet. You should
observe the USB light turn on (top right corner of ELVIS unit).The PC may make a sound to
indicate that the ELVIS unit has been detected if the speakers are activated.

6. Turn on the NI ELVIS Prototyping Board switch to power the SIGEx board. Check that
all three power LEDs are on. If not call the instructor for assistance.

7. Launch the SIGEx Main VI.

8. When youre asked to select a device number, enter the number that corresponds with
the NI ELVIS that youre using.

9. Youre now ready to work with the NI ELVIS/SIGEx bundle.

10. Select the Lab 14 tab on the SIGEx SFP.

Note: To stop the SIGEx VI when youve finished the experiment, its preferable to use the
STOP button on the SIGEx SFP itself rather than the LabVIEW window STOP button at the
top of the window. This will allow the program to conduct an orderly shutdown and close the
various DAQmx channels it has opened.

Ask the instructor to check


your work before continuing.


Experiment

Part 1 Notch filter using two-delay FIR:

We will be implementing the filter in Fig. 1. Figure 2 shows the SIGEx wiring diagram. The
gains b0, b1, b2 in the triple ADDER module realize the coefficients b0, b1, b2, respectively.

11. Patch up the SIGEx model in Fig. 2.


Settings are as follows:
ADDER gains: b0 =1.0; b1 = -1.3; b2 = 0.902
PULSE/CLK GENERATOR: 10 kHz, Duty cycle = 0.5 (50%)
FUNCTION GENERATOR: 1000 Hz; 4Vpp, Sinewave output selected
SCOPE: Timebase 4ms; Rising edge trigger on CH0; Trigger level=0V

View the input signal on CH0, and output with CH1. Check that the time interval between
samples is consistent with the clock frequency.


Figure 2: SIGEx wiring model of FIR filter with two unit delays

12. Measure and plot the magnitude response over the range 300 Hz to 3kHz using the
FUNCTION GENERATOR. Note that the amplitude measurement could be a little challenging
at the upper frequencies due to the increasing interval between samples relative to the signal
period. It is suggested you vary the timebase appropriately, and use the RUN/STOP and Y-
AUTOSCALE buttons when necessary to achieve a stable display.

Confirm that the response has a deep notch.


Graph 1:response plot

Question 8
Measure the notch frequency and the depth relative to the response at DC. Also measure the
time delay as a function of frequency at several points of interest.

13. Using the values of b0, b1, b2 entered, apply the method developed in the preparation
section to plot the zeros of this filter in the z-plane. Check that you have the correct sign of
the coefficients (the zeros should be in the right half-plane). Compare the measured
frequency response with the plot of the zeros. Verify that the measured notch frequency
agrees with the position of the zeros (remember, the frequency at the 180 degree point on the
unit circle corresponds to f_sample/2 = 1/2T Hz).

14. Decrease the b1 gain slightly and observe the effect on the magnitude response.
Measure the new notch frequency. Use this to determine the new positions of the zeros and
the corresponding value of b1. Verify the agreement between measurement and theory.

Question 9
Determine and note the new notch frequency, for the b1 gain entered. Document the
relationship between b1 and notch frequency
15. This time, reduce b2 gain very slightly (order of 2-3%, say) and again, observe the
effect on the magnitude response. The outcome should be a reduced notch depth. Try to
determine the approximate position of the zeros from the notch depth (notch depth relative
to DC gain, say).

Part 2 Using notch filter to eliminate interference

In the next exercise we use the notch filter to remove an interference tone. Consider this
practical situation: we are trying to receive a message at frequency f1 from a distant
transmitter, but in our neighbourhood there is another transmitter sending an unwanted signal
at frequency f2 affecting our reception of f1.

16. Keep the PULSE/CLK GENERATOR frequency at 10,000Hz and maintain the
coefficients values as for Part 1 of this experiment.

17. Use the ANALOG OUTPUT as a source of signals f1 ,and f2. Add these using the f +
g ADDER block to create f1 + f2 .
Confirm that DAC-0(f1 ) = 500Hz sinusoid, and DAC-1 ( f2 ) = 1300 Hz sinusoid.

18. View each output individually as well as the sum of the outputs. View them both in the
time domain as well as in the frequency domain.Show that the f2 signal can be suppressed with
the notch filter. Remember that the notch is set to 1.3kHz.

Question 10
What is the level of attenuation of the f2 signal for the original zero positions.

19. Vary the value of b1 slightly in each direction and notice the affect on the output.
Remember that b1 controls the frequency of the notch. This is a finding from a previous part
of this experiment.

NOTE: To vary the value of a control slightly, set the cursor next to the digit you wish to
vary and then use the UP and DOWN arrow buttons on the control.
As well, the GAIN ADJUST knob on the SIGEx board itself can be used to vary by hand
the coefficient value of the ADDER.

Question 11
From your previous findings in this experiment, what change is required to gain b1 to reduce
the notch frequency ?
20. View both the input two-tone signal on CH1 and the output signal from the notch filter
on CH0. In particular, view them on the FFT display of Lab14 SFP.

21. As well, switch between the Lab 14 TAB and the PZ PLOT TAB on the SFP while making
these adjustments. Notice how the zeroes move when b1 is adjusted. In particular, interpret
the notch frequency from the position of the zeroes. By entering the sample clock frequency
into the clock freq control on the PZ PLOT TAB, you can automate the calculation of the
notch frequency somewhat. Ensure you understand what is being calculated.

Figure: example of PZ PLOT TAB displaying a FIR structure. Zeroes only.

Remember that the POLE-ZERO PLOT is an essential diagram for interpreting frequency
response of a structure.

Question 12
What is the equation relating theta of the zero to the frequency of the zero, as implemented
in the PZ PLOT TAB ?

22. Vary the value of b1 until you eliminate the lower frequency component of the two-tone
message signal. You are exploring using the selectivity of a filter through variation of its
transfer function. Use both the FFT display on TAB14 and the PZ PLOT TAB during this
process so you develop an appreciation for the relatedness of these two different display
representations.
Figure : Notch filter set to attenuate the lower component of the message

Question 13
For what value of b1 did you achieve the maximum attenuation of the lower message component
RELATIVE to the higher component ? What levels did you measure ?

23. Pass the notch filter output, which is sampled and discrete, through a reconstruction
filter such as the BASEBAND LPF to clean up the signal. Experiment again with the b1
coefficient whilst viewing the now, continuous, output signal as you select between each
message component. See how clean a sinusoid you can recover. Experiment with attenuating
both components.

HINT: if using the GAIN ADJUST knob to control b1, you can set the available output range of
the knob so as to be able to fine tune your coefficient value by hand.

Question 14
What components is the TUNEABLE LPF attenuationg in order to give a clean signal ?
Tutorial Questions

Q 1. In Eqn 4 the zeros are complex conjugates. Examine other cases in this Lab
and consider whether this is a coincidence or an outcome of a general
property of FIR filters.

Q 2. Lowpass FIR filters are sometimes called moving average (MA) filters.
Using an example, explain the reason behind this.

Q 3. For the system in Prep (c) show that when b0 = b2 the zeros are on the unit
circle. Plot a graph of the frequency of the zeros versus b1/b0. Tip: to fast
track the math, factor out z.
Interpret the result in the context of step 9.

Q 4. Consider a zero at the origin of the z plane. Show that its magnitude
response is constant and its phase response linear. Show that the factor z-2
in Equation (3) generates a pair of poles at the origin. What is the effect of
these poles on the overall response H_y?

Q5. The z plane method generates frequency responses that are periodic. Is this
an artificial mathematical side effect resulting from the use of complex
variables, or does this reflect reality (refer to the Lab on sampling)?

Q. 6. Find the zeros for the following 4-delay FIR filters (hint: exploit the
symmetry)
(i) [1, 2sqrt2, 4, 2sqrt2, 1]
(ii) [1, -2sqrt2, 4, -2sqrt2, 1]
(iii) [1, 0, 0, 0, 1]
(iv) [1, 0, 1, 0, 1]
(v) [1, 0, 2, 0, 1]
(vi) [1, 1, 1, 1, 1] (hint: this is a geometric progression)
(vii) [1, sqrt3, 2, sqrt3, 1]

State the type of filter realized in each case (lowpass/ highpass/ other).
Compare cases (i) and (ii), and derive a rule of thumb for converting a
lowpass FIR filter to highpass (make reference to the coefficients and to
the zeros).
Which of these is relevant to the implementations in step 12 and 15?
Confirm that in each case the zeros are on the unit circle. Is it a
coincidence, or is there a systematic property that these examples share?
Q. 7. Show that the phase responses of the filters in Q.6 are linear.
Q. 8 In Prep (h) consider an alternative case: move the zeros at +/- 150deg to
180deg (the other zeros remaining fixed). What is the effect on bandwidth
and attenuation in the stop band? What is the result if all the zeros are
placed at 180deg?
Suppose the FIR has 48 zeros. Discuss alternatives for the design of a
lowpass filter: is it preferable to spread the zeros across the stopband or to
place all the zeros at 180deg?

Q 9. Find and plot the zeros for the coefficients in step 13. Note that the
transfer function is a truncated GP. Apply this to simplify the factorization.

Q 10. Write down the transfer function of a first-order continuous-time LPF. The
impulse response of this filter is a decaying exponential that can be matched
approximately to the unit pulse response of the FIR in step 13. Obtain the
time constant and pole of the CT LPF that matches the FIR. Estimate the
bandwidth of the CT filter. Compare this with the bandwidth of the FIR.

Q11. Show how an analog FIR can be implemented with short equal lengths of
coaxial cable as delay elements. Satisfy yourself that such a filter can be
used with continuous-time inputs, i.e., without sampling. On this basis we
should expect a transfer function in terms of the Laplace variable s. Obtain
such a transfer function for the case in prep (b) and show that it is a
quadratic in exp(-sT), where T is the delay of a cable element. Show that in
order to apply the graphical method for estimating responses, a z plane
representation is needed, with z = exp(sT). Filters of this kind were used
with early TV systems in the 1940's. The inventor was Kalmann (not to be
confused with Kalman filters in optimization theory).

Q12. Consider the periodicity issue in Q5 again, in the context of Q11. Satisfy
yourself that frequency responses of this continuous time system are also
periodic.

Das könnte Ihnen auch gefallen