ELEC 310 term project Design of digital filters Everything about a 2-pole 2-zero bandpass (bandstop) filter. Phase 1 You are asked to design a bandpass OR digital notch (bandstop) filter, test the filter characteristics, and document your results in a succinct but complete report. The specifications for the bandpass (bandstop) filter are - center frequency f_1 = 2,000 Hz. - sampling rate f_s = 8,000 Hz - 3dB bandwidth B = 500 Hz - using 2 poles and 2 zeros. You can use any general purpose software that you like, such as C, Fortran, Matlab, Maple, and spreadsheets or anything else you have. 1. Design the filter and specify the transfer function H(z). Scale the filter for unity gain at f_1 (bandpass) or 0 (bandstop). 2. An approximate formula for the 3 dB bandwidth B of the filter as a function of the magnitude |a| of the poles (distance of pole from origin) is deltaomega = 2*|1-a|/sqrt(a), where deltaomega is the normalized bandwidth B in radians. This shows that the distance of the pole from the unit circle |1-a| controls the bandwidth. Find a numerical value for |a| such that B = 500 Hz. This formula applies for bandpass, but may not be as good for bandstop. 3. Plot the frequency response (both amplitude and phase) of H(z). Check that the power response is down 3 dB at f_1 + B/2, as it should be with the correct value of |a|. What is the phase shift at f_1 and at f_1 + B/2? Write your own program to make this plot, and compare the results with POI. 4. Take the IDFT (Inverse Discrete Fourier Transform) of the sampled frequency response to obtain the impulse response h(n). Do this manually with your own program, and with a Matlab, spreadsheet or other standard FFT routine. Use N = 1024. What is the frequency resolution ? 5. Find the difference equations by analysis and compare with POI. 6. Find the impulse response h(n) using the difference equations. Obtain numerical results for h(n) for 0 < n < 25. Spreadsheets are recommended for programming the difference equations, but other types of computer simulation (e.g. C, Fortran) are acceptable. Repeat using MATLAB. For what value of n is h(n) less than one percent of it's maximum value? 7. Find the impulse response h(n) by analysis. Take the inverse z-transform using 3 different methods long division, partial fractions with first order factors, partial fractions with quadratic factors. 8. Prepare a table with 6 columns, listing n and h(n) for the computer simulation of part 6, the 3 analytical methods in part 7, and the IDFT calculation of part 4, for 0 < n < 3. 9. Take the DFT of h(n) by computer (with your own program) and show that H(r) corresponds to the frequency response obtained in part 3. Select an appropriate FFT size to obtain a frequency resolution of 10 Hz or less. Use zero-padding if needed. 10. Demonstrate that the filter works correctly by computer simulation as follows: Evaluate the filter output y(n) with sinusoidal input x(n) by using the difference equations. Use sampled cosine waves at the center frequency f_1, repeat again at the 3 dB down frequency f_1 + B/2. Plot the input and output on the same graph. Verify from the graph that both the amplitude and phase of the y(n) cosine wave output relative to the input x(n) are as predicted by H(f). If the filter is initialed with all zeros, then how long is the transient response before the amplitude and phase reach a steady state? Note that the resulting points will not look much like a sine wave because there are only about 4 samples per cycle. You can (optionally) use an interpolation routine (a plotting option) to get a smooth sine wave curve through the sample points. 11. Repeat item 10 by computing the convolution of the input x(n) with h(n), and compare the results with the difference equation method. How many terms of h(n) are needed to get reasonable agreement? 12. Now consider an input x(n) consisting of 3 cosine waves, at frequencies f_1/3, f_1 and 5f_1/3 with amplitudes 1, 1/3 and 1/5, respectively. The sum of these 3 cosine waves will approximate a square wave. Plot the filter output. 13. Now consider an input x(n) at frequency 5,000 Hz. Plot the filter output and explain the result. Repeat for 6,000 Hz. 14. Now consider an input x(n) = u(n) and initial conditions y(-2)=-1 and y(-1) = 0. Find the output y(n) by z-transform analysis (any method) and compare with an iterative solution using the difference equations. 15. Use the filter to process the voice audio file in assignment 2 (lab6dat.mat) and describe the effect of the filter (i.e. how is the output sound different from the input). Is the voice still intelligible after filtering ? Phase 2 16. Find the impulse response h(n) by taking the inverse z-transform of H(z) using the inversion integral. Do the integral by two different methods, contour integration along a path, and residues. Obtain results for 0 < n < 3. 17. Find the impulse response h(n) using a Laurent series expansion of H(z). Find the radius of convergence of the Laurent series using both the ratio test and the root test. 18. Expand the table in part 7. above by adding 3 new columns, and show that the answers of parts 16 and 17 are equivalent to those obtained in Phase 1 for 0 < n < 3. General Title all graphs, label the axes, and include a scale with proper units. It is suggested (but not mandatory) that the final report is in pdf format.