Design Of A Digital Filter Engineering Essay

Design Of A Digital Filter Engineering Essay

Digital filters are equations that describe how the clip signal is processed in order to rarefy signals at a certain scope of frequences. Those equations are so planted on hardware ( DSP Processors ) or any available agencies to function signal processing intents. When we design digital filters, our chief aim is to obtain the coefficients of the aforesaid equations. There are two chief types of digital filters:

Finite Impulse Response Filter ( FIR )

Infinite Impulse Response Filters ( IIR )

The chief difference between FIR and IIR filters is that in IIR filters there is a feedback cringle and in FIR filters there is no feedback cringle. Transfer map of FIR filter has zero poles, where in IIR filters the transportation map has poles and may hold nothings.

In today ‘s digital universe, digital processors are used in assorted applications, telecommunications is one of them. In this experiment we will travel through the design of filters for the intent of audio noise decrease.

Aim

Identify and analyse a digital audio signal with some added noise.

Identify unknown noise signals to obtain the filter specification and to extinguish them utilizing a suited digital filter implemented in MATLAB.

Design the filter that meet the specification by finding the filter order and happening the filter coefficients.

Procedures

With the aid of MATLAB we obtain the frequence spectrum of both clean and noisy signals from which we can happen the specifications of the filter.

Execution of a FIR filter that suits the specifications.

Execution of an IIR filter that meets the specifications.

Comparison of the public presentations of each of the filters used.

Consequences and Discussion

1. Filter specifications

a ) First, secret plan the spectrum of the clean and noisy signals utilizing the undermentioned codification:

% % % % Noisy Signal % % % %

[ An, fsn, spots ] = wavread ( ‘7n.wav ‘ ) ;

Nn = length ( An ) ;

Xn = fft ( An, Nn ) ;

index = 1: Nn ;

wn = ( 0: ( Nn-1 ) ) /Nn * 2*pi ;

fvec = wn*fsn/ ( 2*pi ) ;

% % Plot from 0 to half sampling frequence ( Hertz )

NHALF = unit of ammunition ( length ( fvec ) /2 ) ;

fv = fvec ( 1: NHALF ) ;

magX = acrylonitrile-butadiene-styrene ( Xn ) ;

XnHALF = magX ( 1: NHALF ) ;

Figure

secret plan ( fv, abs ( XnHALF ) ) ;

rubric ( ‘Noisy Signal ‘ ) ;

xlabel ( ‘Analog frequence in hertz 0- & A ; gt ; 1/2 fsampling ( Hertz ) , fsampling = 11205 ‘ ) ;

ylabel ( ‘ magnitude of fourier transform coefficients ‘ ) ;

% % % % Clean Signal % % % %

[ Ao, fso, obits ] = wavread ( ‘7o.wav ‘ ) ;

No = length ( Ao ) ;

Xo=fft ( Ao, No ) ;

index = 1: No ;

wo = ( 0: ( No-1 ) ) /No * 2*pi ;

fvec = wo*fso/ ( 2*pi ) ;

% % Plot from 0 to half sampling frequence ( Hertz )

NoHALF = unit of ammunition ( length ( fvec ) /2 ) ;

fv = fvec ( 1: NoHALF ) ;

magXo = acrylonitrile-butadiene-styrene ( Xo ) ;

XoHALF = magXo ( 1: NoHALF ) ;

Figure

secret plan ( fv, abs ( XoHALF ) ) ;

rubric ( ‘Clean Signal ‘ ) ;

xlabel ( ‘Analog frequence in hertz 0- & A ; gt ; 1/2 fsampling ( Hertz ) , fsampling = 11205 ‘ ) ;

ylabel ( ‘ magnitude of fourier transform coefficients ‘ ) ;

B ) From these spectra, the specifications of the digital filter were determined as follows:

I ) Passband border frequence = 2699Hz,

two ) Stopband border frequence = 2851Hz,

three ) Passband fading = 3dB

four ) Stopband fading = 50dB

Low-pass filter.

2. Digital FIR filter design

With stopband fading of 50dB, the options we have are Hamming, Blackman and Kaiser. To take which window to utilize, we calculate a?†? to happen the minimal order.

It is noticed that Overacting window achieved the lowest order among the three Windowss which could supply the coveted stopband fading and therefore the window chosen here is Overacting window.

After finding the filter variables, it is clip to plot the frequence response.

fs=11025 ;

Wc = 0.5034 ;

order = 240 ;

B = fir1 ( order, Wc )

[ H, Wc ] =freqz ( B,1, order ) ;

figure

secret plan ( Wc*fs/ ( 2*pi ) , abs ( H ) ) ;

rubric ( ‘Frequency Response of FIR filter ‘ ) ;

xlabel ( ‘Frequency ‘ ) ;

ylabel ( ‘Gain ‘ ) ;

It is noticed that the filter meets the specifications.

Filter Coeffcients:

B =

Columns 1 through 9

0.0002 -0.0001 -0.0002 0.0001 0.0002 -0.0001 -0.0002 0.0001 0.0002

Columns 10 through 18

-0.0001 -0.0003 0.0001 0.0003 -0.0001 -0.0003 0.0002 0.0003 -0.0002

Columns 19 through 27

-0.0004 0.0002 0.0004 -0.0002 -0.0004 0.0003 0.0005 -0.0003 -0.0005

Columns 28 through 36

0.0004 0.0006 -0.0004 -0.0006 0.0005 0.0007 -0.0005 -0.0007 0.0006

Columns 37 through 45

0.0008 -0.0007 -0.0009 0.0008 0.0009 -0.0009 -0.0010 0.0010 0.0011

Columns 46 through 54

-0.0011 -0.0011 0.0012 0.0012 -0.0013 -0.0013 0.0015 0.0014 -0.0016

Columns 55 through 63

-0.0015 0.0018 0.0015 -0.0020 -0.0016 0.0022 0.0017 -0.0024 -0.0018

Columns 64 through 72

0.0026 0.0019 -0.0029 -0.0020 0.0032 0.0021 -0.0035 -0.0021 0.0038

Columns 73 through 81

0.0022 -0.0041 -0.0023 0.0045 0.0024 -0.0049 -0.0025 0.0053 0.0025

Columns 82 through 90

-0.0058 -0.0026 0.0064 0.0027 -0.0069 -0.0028 0.0076 0.0028 -0.0083

Columns 91 through 99

-0.0029 0.0091 0.0030 -0.0101 -0.0030 0.0111 0.0031 -0.0123 -0.0031

Columns 100 through 108

0.0138 0.0032 -0.0155 -0.0032 0.0176 0.0032 -0.0202 -0.0033 0.0236

Columns 109 through 117

0.0033 -0.0282 -0.0033 0.0348 0.0034 -0.0450 -0.0034 0.0633 0.0034

Columns 118 through 126

-0.1059 -0.0034 0.3182 0.5033 0.3182 -0.0034 -0.1059 0.0034 0.0633

Columns 127 through 135

-0.0034 -0.0450 0.0034 0.0348 -0.0033 -0.0282 0.0033 0.0236 -0.0033

Columns 136 through 144

-0.0202 0.0032 0.0176 -0.0032 -0.0155 0.0032 0.0138 -0.0031 -0.0123

Columns 145 through 153

0.0031 0.0111 -0.0030 -0.0101 0.0030 0.0091 -0.0029 -0.0083 0.0028

Columns 154 through 162

0.0076 -0.0028 -0.0069 0.0027 0.0064 -0.0026 -0.0058 0.0025 0.0053

Columns 163 through 171

-0.0025 -0.0049 0.0024 0.0045 -0.0023 -0.0041 0.0022 0.0038 -0.0021

Columns 172 through 180

-0.0035 0.0021 0.0032 -0.0020 -0.0029 0.0019 0.0026 -0.0018 -0.0024

Columns 181 through 189

0.0017 0.0022 -0.0016 -0.0020 0.0015 0.0018 -0.0015 -0.0016 0.0014

Columns 190 through 198

0.0015 -0.0013 -0.0013 0.0012 0.0012 -0.0011 -0.0011 0.0011 0.0010

Columns 199 through 207

-0.0010 -0.0009 0.0009 0.0008 -0.0009 -0.0007 0.0008 0.0006 -0.0007

Columns 208 through 216

-0.0005 0.0007 0.0005 -0.0006 -0.0004 0.0006 0.0004 -0.0005 -0.0003

Columns 217 through 225

0.0005 0.0003 -0.0004 -0.0002 0.0004 0.0002 -0.0004 -0.0002 0.0003

Columns 226 through 234

0.0002 -0.0003 -0.0001 0.0003 0.0001 -0.0003 -0.0001 0.0002 0.0001

Columns 235 through 241

-0.0002 -0.0001 0.0002 0.0001 -0.0002 -0.0001 0.0002

2. Digital IIR filter design

To acquire a precise cutoff frequence, elliptic filter seems to be the best option because it has a shorter passage set than other IIR filters.

Code

Consequence

Wp=0.4896 ;

Ws=0.5172 ;

Rp=3 ;

Rs=50 ;

[ N, Wn ] = ellipord ( Wp, Ws, Rp, Rs )

[ B, A ] = ellip ( N, Rp, Rs, Wn ) ;

figure ;

freqz ( B, A ) ;

N = 7

Wn = 0.4896

It is noticed that the filter meets the specifications.

Filter Coeffcients:

B =

0.0364 0.0829 0.1678 0.2150 0.2150 0.1678 0.0829 0.0364

A =

1.0000 -1.7180 3.5340 -3.8247 3.7334 -2.5087 1.2065 -0.4186

3. Spectral Analysis

Fir

IIR

[ An, fsn, spots ] = wavread ( ‘7n.wav ‘ ) ;

Nn = length ( An ) ;

Xn = fft ( An, Nn ) ;

index = 1: Nn ;

wn = ( 0: ( Nn-1 ) ) /Nn * 2*pi ;

fvec = wn*fsn/ ( 2*pi ) ;

% % Plot from 0 to half sampling frequence ( Hertz )

NHALF = unit of ammunition ( length ( fvec ) /2 ) ;

fv = fvec ( 1: NHALF ) ;

magX = acrylonitrile-butadiene-styrene ( Xn ) ;

XnHALF = magX ( 1: NHALF )

figure

secret plan ( fv, abs ( XnHALF ) ) ;

rubric ( ‘Noisy Signal ‘ ) ;

xlabel ( ‘Analog frequence in hertz 0- & A ; gt ; 1/2 fsampling ( Hertz ) , fsampling = 11205 ‘ ) ;

ylabel ( ‘ magnitude of fourier transform coefficients ‘ ) ;

% % FIR filter design % %

Wc = 0.5034 ;

order = 240 ;

B = fir1 ( order, Wc ) ;

% % Filtering % %

An_=filter ( B,1, An ) ;

fft_An=fft ( An_ ) ;

fft_An_abs=abs ( fft_An ) ;

figure

secret plan ( fv, fft_An_abs ( 1:32768 ) ) ;

rubric ( ‘Filtered Signal ‘ ) ;

xlabel ( ‘Analog frequence in hertz 0- & A ; gt ; 1/2 fsampling ( Hertz ) , fsampling = 11205 ‘ ) ;

ylabel ( ‘ magnitude of fourier transform coefficients ‘ ) ;

% % Save and play % %

wavplay ( An_ ) ;

wavwrite ( An_ , fsn, ‘1071119357f.wav ‘ ) ;

[ An, fsn, spots ] = wavread ( ‘7n.wav ‘ ) ;

Nn = length ( An ) ;

Xn = fft ( An, Nn ) ;

index = 1: Nn ;

wn = ( 0: ( Nn-1 ) ) /Nn * 2*pi ;

fvec = wn*fsn/ ( 2*pi ) ;

% % Plot from 0 to half sampling frequence ( Hertz )

NHALF = unit of ammunition ( length ( fvec ) /2 ) ;

fv = fvec ( 1: NHALF ) ;

magX = acrylonitrile-butadiene-styrene ( Xn ) ;

XnHALF = magX ( 1: NHALF )

figure

secret plan ( fv, abs ( XnHALF ) ) ;

rubric ( ‘Noisy Signal ‘ ) ;

xlabel ( ‘Analog frequence in hertz 0- & A ; gt ; 1/2 fsampling ( Hertz ) , fsampling = 11205 ‘ ) ;

ylabel ( ‘ magnitude of fourier transform coefficients ‘ ) ;

% % IIR filter design % %

Wp=0.4896 ;

Ws=0.5172 ;

Rp=3 ;

Rs=50 ;

[ N, Wn ] = ellipord ( Wp, Ws, Rp, Rs )

[ B, A ] = ellip ( N, Rp, Rs, Wn )

% % Filtering % %

An_=filter ( B,1, An ) ;

fft_An=fft ( An_ ) ;

fft_An_abs=abs ( fft_An ) ;

figure

secret plan ( fv, fft_An_abs ( 1:32768 ) ) ;

rubric ( ‘Filtered Signal ‘ ) ;

xlabel ( ‘Analog frequence in hertz 0- & A ; gt ; 1/2 fsampling ( Hertz ) , fsampling = 11205 ‘ ) ;

ylabel ( ‘ magnitude of fourier transform coefficients ‘ ) ;

% % Save and play % %

wavplay ( An_ ) ;

wavwrite ( An_ , fsn, ‘1071119357i.wav ‘ ) ;

Remark on the frequence response of each filter:

The design process indicates that IIR elliptic has a much lower order than the FIR filter, that shows efficiency of the IIR filter. This efficiency comes at the disbursal of the loss of some of the signal during processing. The passage set of FIR filter is shorter so FIR filter provides a faster passage from passband to stopband frequences. The audio end product of the FIR is better in footings of noise remotion where IIR filter is still acceptable.

Why filtered signal is non indistinguishable to the original signal?

Because when noise is applied to the signal, it is spread over all the frequences with different magnitudes and hence distorts the original signal, it is about impossible to exclude all the noise because it already assorted with the original signal.

Decision

There are two chief types of digital filters, finite impulse response filters and infinite impulse response filters. Merits and demerits of each type were learnt throughout the experiment.

MATLAB is a powerful tool for digital filters design and signals processing, the lone drawback is that MATLAB does non treat signals in existent clip. Real life applications use digital processors to treat signals in existent clip.

When planing FIR filters, we choose the window that offers us the lowest order possible.

IIR Elliptic filter has the shortest passage period among the IIR filters.