Sunteți pe pagina 1din 20

EXPERIMENT NO.

5 DIGITAL FILTERS OBJECTIVES: To generate and plot a Digital Filters To analyze the characteristics of a Digital Filters using FIR and IIR PROCEDURE A: LOW PASS FILTER 1. Encode the following command;
-->hn=eqfir(61,[0 .1;.15 .5], [1 0], [1 1]); -->hm,fr]=frmag(hn,256); -->subplot(1,2,1); -->plot(fr,hm); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnitude'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61'); -->subplot(1,2,2); -->plot(.5*(0:255)/256,20*log10(frmag(hn,256))); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnitude in dB'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61);

2. Observe the generated output waveform.

3. Change the hn=eqfir(61,[0 .1;.15 .5], [1 0], [1 1]); to hn=eqfir(61,[0 .1;.3 .5], [1 0], [1 1]); Run again the program and observe the result. 4. Change the hn=eqfir(61,[0 .1;.15 .5], [1 0], [1 1]); to hn=eqfir(61,[0 .3;.3 .5], [1 0], [1 1]); Run again the program and observe the result. 5. Change the hn=eqfir(61,[0 .1;.15 .5], [1 0], [1 1]); to hn=eqfir(150,[0 .1;.3 .5], [1 0], [1 1]); Run again the program and observe the result. 6. Now, change the hn=eqfir(61,[0 .1;.15 .5], [1 0], [1 1]); to hn=eqfir(61,[0 .1;.3 .5], [0 1], [1 1]); Run again the program and observe the result. OBSERVATIONS: 1. In the syntax hn=eqfir(61,[0 .1;.15 .5], [1 0], [1 1]); , 0.1 and 0.15 refers to pass band edge frequency and stop edge frequency respectively. What is the effect on output waveform when altering those values? 2. What is the effect of changing the length M=61 to M=150 from procedure no.5? 3. What is the use of the parameter altered from the original program in procedure no.6 based on the output waveform observed?

PROCEDURE B: BAND PASS FILTER 1. Encode the following command; --> hz=iir(3,bp,ellip,[.15 .25],[.08 .03]); --> [hzm,fr]=frmag(hz,256); -->plot2d(fr,hzm) -->xtitle ( Discrete IIR filter band pass 0.15<fr<0.25 , ,); 2. Add the following syntax to show the response. Observe the result. -->q=poly(0,q); // to express the result in terms of the -->hzd=horner(hz,1/g) // delay operator q=z^-1 3. Change the hz=iir(3,bp,ellip,[.15 .25],[.08 .03]; to hz=iir(3,bp,ellip,[.1 .45],[.08 .03]); And run again the program. Observe the output waveform generated. 4. Change the hz=iir(3,bp,ellip,[.15 .25],[.08 .03]); to hz=iir(3,bp,ellip,[.15 .25],[.04 .12]); and run again the program. Observe the output waveform generated. 5. Change the hz=iir(3,bp,ellip,[.15 .25],[.08 .03]); to hz=iir(3,bp,ellip,[.15 .25],[.03 .001]); and run again the program. Observe the output waveform generated. OBSERVATIONS: 1. What is the effect of altering the value 0.15 and 0.25 found in the program? 2. How the parameter 0.08 and 0.03 affects the generated output waveform? ANSWER TO THE REPORT: 1. What is the use of eqfir and frmag from procedure A? 2. What is FIR (finite impulse response)? How would you compare it to IIR (infinite impulse response)? 3. What is the use of FIR and IIR in digital signal processing? 4. In what applications does a digital filters are used?

I.

PROGRAM OUTPUT

PROCEDURE A: LOW PASS FILTER 1.a) Program Output


-->hn=eqfir(61,[0 .1;.15 .5],[1 0],[1,1]); -->[hm,fr]=frmag(hn,256); -->subplot(1,2,1); -->plot(fr,hm); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnitude'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61'); -->subplot(1,2,2); -->plot(.5*(0:255)/256,20*log10(frmag(hn,256))); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnituden in dB'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61');

b) Observation
Given a frequency domain specification of a filter's amplitude response on a frequency grid, the impulse response coefficients obtained from the equation used in the syntax. For the first figure, the transition band was introduced in the magnitude of 1dB with the frequency of 0.15 which is reduced but with a slightly slower transition from the pass band to stop band. The second figure illustrates the filter falls slightly short of meeting the stop band attenuation and pass band ripple.

2. a) Program Output -->hn=eqfir(61,[0 .1;.3 .5],[1 0],[1,1]); ************ failure to converge ********** probable cause is machine rounding error - number of iterations = 6 if the number of iterations exceeds 3 the design may be correct, but should be verified with an fft -->[hm,fr]=frmag(hn,256); -->subplot(1,2,1); -->plot(fr,hm); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnitude'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61'); -->subplot(1,2,2); ->plot(.5*(0:255)/256,20*log10(frmag(hn,256))); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnituden in dB'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61');

b) Observation From the first figure, the filter frequency response with the magnitude of 1dB interrupts the values between frequency of 0.15 and 0.25. And for the second figure, with the smooth pass band at a magnitude from -120 to 0, started to roll off between 0.15 and 0.20. Rippling became more severe which illustrates also that the pass was less accurate.

3. a) Program Output -->hn=eqfir(61,[0 .3;.3 .5],[1 0],[1,1]); ************ failure to converge ********** probable cause is machine rounding error - number of iterations = 2 if the number of iterations exceeds 3 the design may be correct, but should be verified with an fft -->[hm,fr]=frmag(hn,256); -->subplot(1,2,1); -->plot(fr,hm); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnitude'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61'); -->subplot(1,2,2); ->plot(.5*(0:255)/256,20*log10(frmag(hn,256))); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnituden in dB'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61');

b) Observation From the syntax given, there are no frequency responses generated for both graphs. It may be caused of invalid set of input values for the designated indices.

4. a) Program Output

-->hn=eqfir(150,[0 .1;.3 .5],[1 0],[1,1]); ************ failure to converge ********** probable cause is machine rounding error - number of iterations = 9 if the number of iterations exceeds 3 the design may be correct, but should be verified with an fft -->[hm,fr]=frmag(hn,256); -->subplot(1,2,1); -->plot(fr,hm); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnitude'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61'); -->subplot(1,2,2); -->plot(.5*(0:255)/256,20*log10(frmag(hn,256))); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnituden in dB'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61');

b) Observation The first graph shows the pass band edge becomes narrower which makes the roll off steeper than the previous program generated. While for the second graph illustrates an increase in the magnitude of the frequency response in terms of dB compared also to the previous graph shown in the original program.

5. a) Program Output -->hn=eqfir(61,[0 .3;.3 .5],[0 1,[1,1]); !--error 2 Invalid factor. -->[hm,fr]=frmag(hn,256); -->subplot(1,2,1); -->plot(fr,hm); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnitude'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61'); -->subplot(1,2,2); -->plot(.5*(0:255)/256,20*log10(frmag(hn,256))); -->xlabel('Normalized Digital Frequency fr'); -->ylabel('Magnituden in dB'); -->title('Frequency Response of FIR LPF using REMEZ algorithm M=61');

b) Observation The generated response were almost the same with graph shown from the Procedure #2 but this time, it is the stop band is in the range from -20 to 0 dB. Also, the stop band has its smooth band and has slow roll off.

Observations:
1. As you change values for pass band edge and stop band edge respectively, the magnitude in terms of dB will be adjusted which has an equivalent to the roll off.

2. M corresponds to the magnitude response shown in the graph. Changing the values for M will adjust for the pass band edge and stop band edge respectively.

3. As you changed the parameters or the values from the original program with designated values from the last procedure, corresponds to the change from having a high band pass filter to a stop band pass filter.

PROCEDURE B: BAND PASS FILTER 1. a) Program Output -->hz=iir(3,'bp','ellip',[.15 .25],[.08 .03]); -->[hzm,fr]=frmag(hz,256); -->plot2d(fr',hzm') -->xtitle('Discrete IIR filter bandpass 0.15<fr<0.25 ',' ','');

2. a) Program Output

-->hz=iir(3,'bp','ellip',[.15 .25],[.08 .03]); -->[hzm,fr]=frmag(hz,256); -->plot2d(fr',hzm') -->xtitle('Discrete IIR filter bandpass 0.15<fr<0.25 ',' ',''); -->q=poly(0,'q'); //to express the result in terms of the ... -->hzd=horner(hz,1/q) //delay operator q=z^-1 hzd = 2 0.0476402 - 0.0423997q + 0.0013489q + 1.058D3 4 5 6 17q - 0.0013489q + 0.0423997q - 0.0476402q -----------------------------------------------2 3 1 - 1.646036q + 2.9974049q - 2.6216751q + 4 5 6 2.4255266q - 1.0411237q + 0.5045339q

b) Observation
The graph shows an elliptic type of band pass filter which has a cut off frequencies of 0.15 (the lower cut off frequency) and 0.25 (the higher cut off frequency). The curve is high when the range of frequency is from 0.15 to 0.25 and it gets lower when the frequency is not in that range.

3. a) Program Output -->hz=iir(3,'bp','ellip',[.1 .45],[.08 .03]); -->[hzm,fr]=frmag(hz,256); -->plot2d(fr',hzm') -->xtitle('Discrete IIR filter bandpass 0.15<fr<0.25 ',' ',''); -->q=poly(0,'q'); //to express the result in terms of the ... -->hzd=horner(hz,1/q) //delay operator q=z^-1 hzd = 2 0.3973347 + 0.0307760q - 1.0920839q + 4 5 6 1.0920839q - 0.0307760q - 0.3973347q -----------------------------------------------2 3 1 + 0.6431976q - 0.9515439q - 0.2066578q + 4 5 6 0.8286315q + 0.2041194q - 0.0685753q

b) Observation
By changing the value of [0.15 0.25] to [0.1 0.45], the higher and lower cut off frequencies were now changed from 0.1 (the higher cut off frequency) to 0.45 (the lower cut off frequency). The curve is high when the range of frequency is from 0.1 to 0.45 and it gets lower when the frequency is not in that range.

4. a) Program Output -->hz=iir(3,'bp','ellip',[.15 .25],[.04 .12]); -->[hzm,fr]=frmag(hz,256); -->plot2d(fr',hzm') -->xtitle('Discrete IIR filter bandpass 0.15<fr<0.25 ',' ',''); -->q=poly(0,'q'); //to express the result in terms of the ... -->hzd=horner(hz,1/q) //delay operator q=z^-1 hzd = 2 0.1088975 - 0.1120555q + 0.0545877q + 3 4 5 9.672D-17q - 0.0545877q + 0.1120555q 6 0.1088975q -----------------------------------------------2 3 1 - 1.5967293q + 2.7953342q - 2.3965675q 4 5 6 + 2.1736187q - 0.9042632q + 0.4218427q

b) Observation
The output waveform is just like the in the first step. But the ripple next to cut off frequencies now gets a little higher.

5. a) Program Output -->hz=iir(3,'bp','ellip',[.15 .25],[.03 .001]); -->[hzm,fr]=frmag(hz,256); -->plot2d(fr',hzm') -->xtitle('Discrete IIR filter bandpass 0.15<fr<0.25 ',' ',''); -->q=poly(0,'q'); //to express the result in terms of the ... -->hzd=horner(hz,1/q) //delay operator q=z^-1 hzd = 2 0.0236025 - 0.0046269q - 0.0550642q 3 4 5 2.096D-17q + 0.0550642q + 0.0046269q 6 0.0236025q -----------------------------------------------2 3 1 - 1.5755525q + 2.7041095q - 2.2713174q 4 5 6 + 2.0162331q - 0.8370882q + 0.3917251q

b) Observation
By changing the value of [.08 .03] to [.03 .001] in the program, it is now observed that the wave becomes smoother as the frequency goes beyond the cutoff frequency from 0.15 to 0.25.

Observations:
1. When the value 0.15 and 0.25 was altered in the program, it is observed that the highest amplitude in the waveform is varying depending on the values given. The values 0.15 and 0.25 determine the cut off frequencies in the graph.

2. The values 0.08 and 0.03 just affect the ripple/ wave next to cutoff frequencies. When it is increased, the ripple gets higher and when its decreased, the ripple gets lower.

ANSWERS TO THE REPORT: 1. The syntax eqfir is used in the program for the minimax approximation of FIR (finite impulse response) filter. While for the syntax frmag corresponds to the magnitude of FIR which needs the inputs such as the numerator and the denominator of the filter as well as an integer that indicates the length of the array that we are going to get. `frmag' returns frequencies in the respective range given in the said procedure. 2. FIR is the impulse response length, which must be optimized for the given design specifications in order to reduce the size of the filter. It can be implemented non-recursively by convolving its impulse response with the time data sequence it is filtering. If you put in an impulse, that is, a single "1" sample followed by many "0" samples, zeroes will come out after the "1" sample has made its way through the delay line of the filter. Compared to IIR filters, FIR filters offer the following advantages: They can easily be designed to be "linear phase" (and usually are). Put simply, linear-phase filters delay the input signal but dont distort its phase. They are simple to implement. They are suited to multi-rate applications. In contrast, if IIR filters are used, each output must be individually calculated, even if it that output will discarded (so the feedback will be incorporated into the filter). They have desireable numeric properties. In practice, all DSP filters must be implemented using finiteprecision arithmetic, that is, a limited number of bits. The use of finite-precision arithmetic in IIR filters can cause significant problems due to the use of feedback, but FIR without feedback can usually be implemented using fewer bits, and the designer has fewer practical problems to solve related to non-ideal arithmetic. 3. FIR and IIR are the two primary types of digital filters used in Digital Signal Processing (DSP). Those types of digital filter are systems that perform mathematical operations on a sampled, discrete-time signal to reduce or enhance certain aspects of that signal. 4. Applications of digital filtering to telecommunication, to be specific the PCM channel filters, and the transmultiplexer, which is a system that converts a time-division multiplex into a frequencydivision multiplex. Another application is to seismic detection and discrimination. digital filters are applied to seismic body waves to i) try to determine whether the first arrival is up or down on a seismogram corrupted with microseismic noise, 2) increase signal-to-noise ratio on seismograms where noise has almost obliterated signal 3) assign polarity to each of two seismic first motion wavelets so they can be termed "same" or "opposite," 4) remove spectrum of seismometer from data, 5) investigate the time varying spectral structure of underground nuclear shot seismograms.

S-ar putea să vă placă și