Vous êtes sur la page 1sur 33

1

DIGITAL SIGNAL PROCESSING LAB


CODE NO: EC05177 LIST OF EXPERIMENTS: 1. To study the architecture of DSP chips TMS 320C SX/6X Instructions. 2. To verify linear convolution 3. To verify the circular convolution 4. To design FIR filter (LP/HP) using windowing technique a. Using rectangular window b. Using triangular window c. Using Kaiser window 5. To implement IIR filter (LP/HP) on DSP Processors 6. N-point FFT algorithm 7. MATLAB program to generate sum of sinusoidal signals 8. MATLAB program to find frequency response of analog LP/HP filters 9. To compute power density spectrum of a sequence 10. To find the FFT of given 1-D signal and plot.

DIGITAL SIGNAL PROCESSING LAB


LIST OF EXPERIMENTS: 1. To study the architecture of DSP chips TMS 320 6713.32-bit floating point processor. 2. Introduction to MATLAB: generation of basic signals 3. To verify linear convolution 4. To verify the circular convolution 5. To design FIR filter (LP/HP) using windowing technique a. Using rectangular window b. Using triangular window c. Using Kaiser window 6. To implement IIR filter (LP/HP) & frequency response of analog LP/HP and butter worth filters & cheby shev filters. 7. N-point FFT algorithm 8. MATLAB program to generate sum of sinusoidal signals 9. To compute power density spectrum of a sequence 10. To find the FFT of given 1-D signal and plot.

1.INRTODUCTION TO TMS 320C6713 DSK ARCHITECTURE


Aim- To study the architecture of TMS320C6713 DSK

Apparatus- TMS320C6713 DSK kit THEROY- The highperformance board features the TMS320C6713 floatingpoint DSP. Capable of performing 1350 million floating point operations per second, the C6713 DSK the most powerful DSK development board. The DSK is USB port interfaced platform that allows to efficiently develop and test applications for the C6713. With extensive host PC and target DSP software support, the DSK provides ease-of-use and capabilities that are attractive to DSP engineers.

OVERVIEW The 6713 DSP Starter Kit (DSK) is a low-cost platform which lets customers evaluate and develop applications for the Texas Instruments C67X DSP family. The primary features of the DSK are: 225 MHz TMS320C6713 Floating Point DSP AIC23 Stereo Codec Four Position User DIP Switch and Four User LEDs On-board Flash and SDRAM

TIs Code Composer Studio development tools are bundled with the 6713 DSK providing the user with an industrial-strength integrated development environment for C and assembly programming. Code Composer Studio communicates with the DSP using an on-board JTAG emulator through a USB interface. The TMS320C6713 DSP is the heart of the system. It is a core member of Texas Instruments C64X line of fixed point DSPs whose distinguishing features are an extremely high performance 225MHz VLIW DSP core and 256Kbytes of internal memory. On-chip peripherals include a 32-bit external memory interface (EMIF) with integrated SDRAM controller, 2 multi-channel buffered serial ports (McBSPs), two on-board timers and an enhanced DMA controller (EDMA). The 6713 represents the high end of TIs C6700 floating point DSP line both in terms of computational performance and on-chip resources.

4 The 6713 has a significant amount of internal memory so many applications will have all code and data on-chip. External accesses are done through the EMIF which can connect to both synchronous and asynchronous memories. The EMIF signals are also brought out to standard TI expansion bus connectors so additional functionality can be added on daughter card modules.

TMS320C6713 DSK Overview Block Diagram

DSPs are frequently used in audio processing applications so the DSK includes an on-board codec called the AIC23. Codec stands for coder/decoder, the job of the AIC23 is to code analog input samples into a digital format for the DSP to process, then decode data coming out of the DSP to generate the processed analog output. Digitial data is sent to and from the codec on McBSP1.

The DSK has 4 light emitting diodes (LEDs) and 4 DIP switches that allow users to interact with programs through simple LED displays and user input on the switches. Many of the included examples make use of these user interface options.

The DSK implements the logic necessary to tie board components together in a programmable logic device called a CPLD. In addition to random glue logic, the CPLD implements a set of 4 software programmable registers that can be used to access the on-board LEDs and DIP switches as well as control the daughter card interface. DEVELOPMENT ENVIRONMENT Code Composer Studio is TIs flagship development tool. It consists of an assembler, a C compiler, an integrated development environment (IDE, the graphical interface to the tools) and numerous support utilities like a hex format conversion tool. The DSK includes a special version of Code Composer specially tailored to features on the 6713 DSK board. Other versions of Code Composer are available that fully support each of TIs processor families on a wide variety of hardware targets. The Code Composer IDE is the piece you see when you run Code Composer. It consists of an editor for creating source code, a project manager to identify the source files and options necessary for your programs and an integrated source level debugger that lets you examine the behavior of your program while it is running. The IDE is responsible for calling other components such as the compiler and assembler so developers dont have to deal with the hassle of running each tool manually. The 6713 DSK includes a special device called a JTAG emulator on-board that can directly access the register and memory state of the 6713 chip through a standardized JTAG interface port. When a user wants to monitor the progress of his program, Code Composer sends commands to the emulator through its USB host interface to check on any data the user is interested in. This debugging method is extremely powerful because programs can be debugged unobtrusively on real hardware targets without making any special provisions for debug like external probes, software monitors or simulated hardware. When designing your own hardware around the 6713 you can debug your application with the same rich functionality of the DSK simply by using Code Composer with an external emulator and including a header for the JTAG interface signals. You should always be aware that the DSK as a different system than your PC, when you recompile a program in Code Composer on your PC you must specifically load it onto the 6713 on the DSK. Other things to be aware of are:

When you tell Code Composer to run, it simply starts executing at the current program counter. If you want to restart the program, you must reset the

6 program counter by using Debug Restart or re-loading the program which sets the program counter implicitly. After you start a program running it continues running on the DSP indefinitely. To stop it you need to halt it with Debug Halt.

LOADING AND RUNNING A PROGRAM The best way to get started with Code Composer is to run some of the simple examples included with the DSK. The LED example is the easiest example to get started with to become familiar with the DSK and make sure your development tools are configured correctly. When run, it will: Continuously blink LED #0 about 2.5 times per second. Continuously read the value of DIP switch #3 and display it on LED #3.

To run the program, perform the following steps:

1. Open the led.pjt Code Composer project using Project Open and selecting led.pjt. It is in the directory c:\CCStudio_v3.1\examples\dsk6713\bsl\led. 2. Load the led.out executable file. Select File Load Program. It will open a file browser dialog. Select the led.out file in the led\Debug directory in the file browser and hit "Open" to load the executable file. You must reload the compiled executable every time you make changes to the program. 3. Select the Debug a Run option under the Debug menu. LED #0 will start blinking slowly. 4. Move DIP switch #3 up and down, you will see LED #3 change with it. 5. When you are satisfied that the program is indeed running correctly, stop the program by selecting Debug Halt. RESULT- Thus, the TMS320C6713DSK Architecture is studied.

2. VERIFY LINEAR CONVOLUTION


LINEAR CONVOLUTION USING MAT LAB AIM : To perform linear convolution of two sequences using MATLAB. Requirements : Computer with MATLAB software PROGRAM : %linear convolution program clc; clear all; close all; disp('linear convolution program'); x=input('enter i/p x(n):'); m=length(x); h=input('enter i/p h(n):'); n=length(h); x=[x,zeros(1,n)]; subplot(2,2,1), stem(x); title('i/p sequence x(n)is:'); xlabel('---->n'); ylabel('---->x(n)');grid; h=[h,zeros(1,m)]; subplot(2,2,2), stem(h); title('i/p sequence h(n)is:'); xlabel('---->n'); ylabel('---->h(n)');grid; disp('convolution of x(n) & h(n) is y(n):'); y=zeros(1,m+n-1); for i=1:m+n-1 y(i)=0; for j=1:m+n-1 if(j<i+1) y(i)=y(i)+x(j)*h(i-j+1); end end end y subplot(2,2,[3,4]),stem(y); title('convolution of x(n) & h(n) is :'); xlabel('---->n'); ylabel('---->y(n)');grid;

PROCEDURE: 1) Generate the first input sequence x. 2) Plot the sequence in discrete form. [Make use of stem( )] 3) Give some relevant names to x-axis and y-axis. 4) Generate second input sequence y. 5) Repeat steps (2) and (3) for second sequence y. 6) Use the inbuilt function conv( ) to compute linear convolution of x and y. z = conv(x,y) 7) Plot the output sequence z. [Repeat steps 2 and 3] 8) Make use of subplot ( ) to plot the inputs and output sequences in a single window.

Result: enter value for m4 enter value for n4 Enter values for i/p 1234 Enter Values for n 1234 The Value of output y[0]=1 The Value of output y[1]=4 The Value of output y[2]=10 The Value of output y[3]=20 The Value of output y[4]=25 The Value of output y[5]=24 The Value of output y[6]=16

9 Waveform:
stem x 10

amp..

5 0

1.5

2.5

3.5 (a)n.. stem h

4.5

5.5

10

amp..

5 0 1 1.5 2 2.5 3 (b)n.. stem y 3.5 4 4.5 5

100

amp..

50 0

5 (c)n..

10

FIG: Linear convolution of two sequences Result : Linear convolution of two sequences using MATLAB is obtained. VIVA QUESTIONS: 1. What is the purpose of using convolution? 2. Give the formula for calculating linear convolution.

10 LINEAR CONVOLUTION USING TMS320C6713 KIT

Aim: To implement linear convolution. Apparatus: DSK 6713 DSP Trainer kit. USB Cable Power supply Program: #include<stdio.h> int x[15],h[15],y[15]; main() { int i,j,m,n; printf("\n enter value for m"); scanf("%d",&m); printf("\n enter value for n"); scanf("%d",&n); printf("Enter values for i/p x(n):\n"); for(i=0;i<m;i++) scanf("%d",&x[i]); printf("Enter Values for i/p h(n) \n"); for(i=0;i<n; i++) scanf("%d",&h[i]); // padding of zeros for(i=m;i<=m+n-1;i++) x[i]=0; for(i=n;i<=m+n-1;i++) h[i]=0; /* convolution operation */ for(i=0;i<m+n-1;i++) { y[i]=0; for(j=0;j<=i;j++) { y[i]=y[i]+(x[j]*h[i-j]); }} //displaying the o/p for(i=0;i<m+n-1;i++) printf("\n The Value of output y[%d]=%d",i,y[i]); }

11 Procedure: Open code composer studio, make sure the DSP kit is turned on. Start a new project using project-new pull down menu, save it in a separate directory (c:\ccstudio\myprojects) with the name file name. pjt. Add the source file of linear convolution to the project using project-add files to project pull down menu. Add the linker command file hello. cmd (c\ccstudio\tutorials\dsk6713\hello1\hello.cmd) Add the run time support library file rts6700.lib (c-ccstudio\c6000\cgtools\lib\rts6700.lib) Compile program using the project-compile pull down menu or by clicking the short cut icon on the left side of program window. Build the program using project-build pull down menu or by clicking the icon on the left side of the program window. Load the program in program memory of DSP chip using the file-load program pull down menu. To view o/p graphically, select View graph-time and frequency.

12

Precautions: Switch ON the computer only after connecting USB cable and make sure the DSP kit is ON. Perform the diagnostic check before opening code composer studio. All the connections must be tight.

Result

: The linear convolution is obtained and the graphs are plotted.

13

3. VERIFY CIRCULAR CONVOLUTION


CIRCULAR CONVOLUTION USING MATLAB AIM: To perform circular convolution of two sequences using MATLAB. Requirements : Computer with MATLAB software Program : clc; clear all; close all; disp('circular convolution program'); x=input('enter i/p x(n):'); m=length(x); h=input('enter i/p sequence h(n)'); n=length(h); subplot(2,2,1), stem(x); title('i/p sequencce x(n)is:'); xlabel('---->n'); ylabel('---->x(n)');grid; subplot(2,2,2), stem(h); title('i/p sequencce h(n)is:'); xlabel('---->n'); ylabel('---->h(n)');grid; disp('circular convolution of x(n) & h(n) is y(n):'); if(m-n~=0) if(m>n) h=[h,zeros(1,m-n)]; n=m; end x=[x,zeros(1,n-m)]; m=n; end y=zeros(1,n); y(1)=0; a(1)=h(1); for j=2:n a(j)=h(n-j+2); end %ciruclar conv for i=1:n y(1)=y(1)+x(i)*a(i); end for k=2:n

14 y(k)=0; % circular shift for j=2:n x2(j)=a(j-1); end x2(1)=a(n); for i=1:n if(i<n+1) a(i)=x2(i); y(k)=y(k)+x(i)*a(i); end end end y subplot(2,2,[3,4]),stem(y); title('convolution of x(n) & h(n) is:'); xlabel('---->n'); ylabel('---->y(n)');grid; Procedure: 1) Generate the first input sequence x. 2) Plot the sequence in discrete form. [Make use of stem( )] 3) Give some relavent names to x-axis and y-axis. 4) Generate second input sequence h. 5) Repeat steps (2) and (3) for second sequence h. 6) Find out the length of first sequence and store it in variable n1. [Make use of length ( )] 7) Similarly find out the length of second sequence and store it in variable n2. 8) Find out the maximum length sequence among x and h. Let the length of larger sequence be n3. [Make use of max( ) function for this purpose] 9) Make the length of smaller sequence equal to the larger sequence by padding zeros to it.

15 10) Perform circular convolution of the sequences x and h and store it in y. Circular convolution of x and h is given by the following equation: y(n)= x(i) h(j) n=0 where n=0 to (n3-1) j=(n-i)n3

But in MATLAB x(0) doesnt exist. So i takes values from 1 to n3. Similarly for n. Therefore the above equation becomes; y(n)= x(i) h(j) n=1 where, n=1 to n3 j=(n-i+1)n3

3) Display and plot the convoled sequence. [Repeat steps (2) and (3)] 4) Make use of subplot to plot the inputs and output sequences in a single window. 5) Compare theoretical and practical values.

OUTPUT:Enter the length of the first sequence 4 Enter the length of the second sequence 3 Enter the first sequence 1234 Enter the second sequence 123 The circular convolution is 18 16 10 16

16 OUT PUT WAVE FORM:

Result: circular convolution of two sequences using MATLAB is obtained. VIVA QUESTIONS: 1. What is the different between Circular and Linear convolution? 2. What is the function in MATLAB used for padding zeros to a sequence? If your sequence is, x = [1 2 3 4] and you want to pad zeros to it. How can you do that in MATLAB? 3.What is the use of following functions in MATLAB: i. length( ) ii. max( ) iii. min( ) 4.Give the steps to get the result of linear convolution from the method of circular convolution 5. What is the circular convolution 6.Explain how cyclic (circular) convolution of two periodic sequences can be obtained using DFT techniques

17

CIRCULAR CONVOLUTION USING TMS320C6713 KIT Aim: To implement circular convolution. Apparatus: DSK 6713 DSP Trainer kit. USB Cable Power supply Program:
#include<stdio.h> int m,n,x[30],h[30],y[30],i,j, k,x2[30],a[30]; void main() { printf(" Enter the length of the first sequence\n"); scanf("%d",&m); printf(" Enter the length of the second sequence\n"); scanf("%d",&n); printf(" Enter the first sequence\n"); for(i=0;i<m;i++) scanf("%d",&x[i]); printf(" Enter the second sequence\n"); for(j=0;j<n;j++) scanf("%d",&h[j]); if(m-n!=0) /*If length of both sequences are not equal*/ { if(m>n) /* Pad the smaller sequence with zero*/ { for(i=n;i<m;i++) h[i]=0; n=m; } for(i=m;i<n;i++) x[i]=0; m=n; } y[0]=0; a[0]=h[0]; for(j=1;j<n;j++) /*folding h(n) to h(-n)*/ a[j]=h[n-j]; /*Circular convolution*/ for(i=0;i<n;i++) y[0]+=x[i]*a[i]; for(k=1;k<n;k++) { y[k]=0; /*circular shift*/ for(j=1;j<n;j++)

18
x2[j]=a[j-1]; x2[0]=a[n-1]; for(i=0;i<n;i++) { a[i]=x2[i]; y[k]+=x[i]*x2[i]; } } /*displaying the result*/ printf(" The circular convolution is\n"); for(i=0;i<n;i++) printf("%d \t",y[i]); }

Procedure: Open code composer studio, make sure the DSP kit is turned on. Start a new project using project-new pull down menu, save it in a separate directory (c:\ccstudio\myprojects) with the name file name. pjt. Add the source file of linear convolution to the project using project-add files to project pull down menu. Add the linker command file hello. cmd (c\ccstudio\tutorials\dsk6713\hello1\hello.cmd) Add the run time support library file rts6700.lib (c-ccstudio\c6000\cgtools\lib\rts6700.lib) Compile program using the project-compile pull down menu or by clicking the short cut icon on the left side of program window. Build the program using project-build pull down menu or by clicking the icon on the left side of the program window. Load the program in program memory of DSP chip using the file-load program pull down menu. To view o/p graphically, select View graph-time and frequency.

19 OUTPUT:

Precautions : switch ON the computer only after connecting USB cable and make sure the DSP kit is ON. Perform the diagnostic check before opening code composer studio. All the connections must be tight.

Result : The circular convolution is obtained and the graphs are plotted.

20

4.DESIGN FIR FILTER (LP/HP) USING WINDOWING TECHNIQUE


FIR FILTERS (LP/HP) USING WINDOWING TECHNIQUE a) Using Rectangular Window b) Using Triangular Window c) Using Kaiser Window AIM: To design of FIR (LP/HP) filters using rectangular window, Triangular window and Kaiser window. Requirements : Computer with MATLAB software PROGRAM clc; clear all; close all; rp=input('enter passband ripple'); rs=input('enter the stopband ripple'); fp=input('enter passband freq'); fs=input('enter stopband freq'); f=input('enter sampling freq '); wp=2*fp/f; ws=2*fs/f; num=-20*log10(sqrt(rp*rs))-13; dem=14.6*(fs-fp)/f; n=ceil(num/dem); n1=n+1; if(rem(n,2)~=0) n1=n; n=n-1; end c=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n '); if(c==1) y=rectwin(n1); disp('Rectangular window filter response'); end if (c==2) y=triang(n1); disp('Triangular window filter response'); end if(c==3) y=kaiser(n1); disp('kaiser window filter response'); end

21 %LPF b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1);plot(o/pi,m); title('LPF'); ylabel('Gain in dB-->'); xlabel('(a) Normalized frequency-->'); %HPF b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2);plot(o/pi,m); title('HPF'); ylabel('Gain in dB-->'); xlabel('(b) Normalized frequency-->'); %BPF wn=[wp ws]; b=fir1(n,wn,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,3);plot(o/pi,m); title('BPF'); ylabel('Gain in dB-->'); xlabel('(c) Normalized frequency-->'); %BSF b=fir1(n,wn,'stop',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,4);plot(o/pi,m); title('BSF'); ylabel('Gain in dB-->'); xlabel('(d) Normalized frequency-->'); INPUT enter the passband ripple.01 enter the stopband ripple.04 enter the passband frequency1500 enter the stopband frequency2000 enter the sampling freq9000

22
Output:-

23
Output:-

PROCEDURE: 1) Enter the passband ripple (rp) and stopband ripple (rs). 2) Enter the passband frequency (fp) and stopband frequency (fs). 3) Enter the sampling frequency (f). 4) Calculate the analog passband edge frequency (wp) and stop band edge frequency (ws) wp=2*fp/f ws=2*fs/f 5) Calculate the order of the filter using the following formula, (-20log10 ( rp.rs) 13) n= ___________________ (14.6 (fs-fp)/f). [Use ceil( ) for rounding off the value of n to the nearest integer] if n is an odd number, then reduce its value by 1. 6) Generate (n+1)th point window coefficients.For example boxcar(n+1) generates a rectangular window. y=boxcar(n+1)

24

7) Design an nth order FIR filter using the previously generated (n+1) length window function. b=fir1(n,wp,y) 8) Find the frequency response of the filter by using freqz( ) function. [h,o]=freqz(b,a,k) This function returns k-point complex frequency response vector h and k-point frequency vector o in radians/samples of the filetr. B(ejw) b(1)+b(2)e-jw+..b(m+1)e-jmw H(eiw)= ______ = __________________________________ A(ejw) a(1)+a(2)e-jw+.a(n+1)e-jnw Where a,b are vectors containing the denominator and numerator coefficients. Here a=1. 9) Calculate the magnitude of the frequency response in decibels(dB). m= 20*log10(abs(h)) 10) Plot the magnitude response [magnitude in dB Vs normalized frequency (o/pi)] 11)Give relevant names to x- and y- axes and give an appropriate title for the plot. 12) Repeat the procedure for high pass, band pass, and band stop filters. 13) Plot all the responses in a single figure window.[Make use of Subplot]. 14) Repeat the program for different types of windows available: a. rectangular window b. triangular window c. Kaiser window

Result : The design of FIR (LP/HP) filters using rectangular window, Triangular window and Kaiser window is performed.

25 FIR FILTER DESIGN (LP/HP) USING TMS320C6713 KIT Aim: To design of FIR (LP/HP) filters using rectangular window, Triangular window and Kaiser window. Apparatus: DSK 6713 DSP Trainer kit. USB Cable Power supply Program: #include<stdio.h> #include<math.h> #define pi 3.1415 int n,N,c; float wr[64],wt[64]; void main() { printf("\n enter no. of samples,N= :"); scanf("%d",&N); printf("\n enter choice of window function\n 1.rect \n 2. triang \n c= :"); scanf("%d",&c); printf("\n elements of window function are:"); switch(c) { case 1: for(n=0;n<=N-1;n++) { wr[n]=1; printf(" \n wr[%d]=%f",n,wr[n]); } break; case 2: for(n=0;n<=N-1;n++) { wt[n]=1-(2*(float)n/(N-1)); printf("\n wt[%d]=%f",n,wt[n]); } break; }}

26 Output:

Result : The design of FIR (LP/HP) filters using rectangular window, Triangular window and Kaiser window is performed.

27

VIVA QUESTIONS: 1. What are the uses of function ceil and for? 2. Define boxcar 3. Define Kaiser 4. Define Bartlett 5. What is an FIR system? Compare FIR and IIR system? 6. What are effects of windowing? 7. Explain the process of windowing

28

5.IMPLEMENT IIR FILTER (LOW PASS & HIGH PASS)


IIR FILTER (LP/HP) USING BUTTER WORTH (ANLOG & DIGITAL) FILTERS AIM: To design of Butterworth Digital (low pass & high pass) filter using MATLAB. Requirements: Computer with MATLAB software PROGRAM: clc; clear all; close all; disp('enter the IIR filter design specifications'); rp=input('enter the passband ripple'); rs=input('enter the stopband ripple'); wp=input('enter the passband freq'); ws=input('enter the stopband freq'); fs=input('enter the sampling freq'); w1=2*wp/fs;w2=2*ws/fs; [n,wn]=buttord(w1,w2,rp,rs,'s'); c=input('enter choice of filter 1. LPF 2. HPF \n '); if(c==1) disp('Frequency response of IIR LPF is:'); [b,a]=butter(n,wn,'low','s'); end if(c==2) disp('Frequency response of IIR HPF is:'); [b,a]=butter(n,wn,'high','s'); end w=0:.01:pi; [h,om]=freqs(b,a,w); m=20*log10(abs(h)); an=angle(h); figure,subplot(2,1,1);plot(om/pi,m); title('magnitude response of IIR filter is:'); xlabel('(a) Normalized freq. -->'); ylabel('Gain in dB-->'); subplot(2,1,2);plot(om/pi,an); title('phase response of IIR filter is:'); xlabel('(b) Normalized freq. -->'); ylabel('Phase in radians-->');

29 INPUT: Assume: enter the passband ripple.5 enter stopband ripple50 enter passband freq1200 enter stopband freq2400 enter sampling freq10000

PROCEDURE: 1) Enter the pass band ripple (rp) and stop band ripple (rs). 2) Enter the pass band frequency (fp) and stop band frequency (fs). 3) Get the sampling frequency (f). 4) Calculate the analog pass band edge frequencies, w1 and w2. w1 = 2*fp/f w2 = 2*fs/f 5) Calculate the order and 3dB cutoff frequency of the analog filter. [Make use of the following function] [n,wn]=buttord(w1,w2,rp,rs,s) 6) Design an nth order analog lowpass Butter worth filter using the following statement. [b,a]=butter(n,wn,s) 7) Find the complex frequency response of the filter by using freqs( ) function [h,om]=freqs(b,a,w) where, w = 0:.01:pi This function returns complex frequency response vector h and frequency vector om in radians/samples of the filter. b(s) b(1)Snb-1+b(2)Snb-2+b(nb) H(s)= ____ = _________________________________ a(s) a(1)Sna-1+a(2)Sna-2+..a(na) Where a,b are the vectors containing the denominator and numerator coeffients. 8) Calculate the magnitude of the frequency response in decibels (dB) m=20*log10(abs(h))

30 9) Plot the magnitude response [magnitude in dB Vs normalized frequency (om/pi)] 10) Give relevant names to x and y axes and give an appropriate title for the plot. 11) Repeat the procedure for highpass, bandpass, bandstop filters.

12) Plot all the responses in a single figure window.[Make use of subplot()].

Output:

31

Result: The design of Butterworth Digital (low pass & high pass) filter is performed.

32

IIR FILTER (LP/HP) USING BUTTER WORTH (ANLOG & DIGITAL) FILTERS AIM: To design of Butterworth Digital (low pass & high pass) filter using CCStudio. Apparatus: DSK 6713 DSP Trainer kit. USB Cable Power supply Program: #include<stdio.h> #include<math.h> int i,w,wc,c,N; float H[100]; float mul(float, int); void main() { printf("\n enter order of filter "); scanf("%d",&N); printf("\n enter the cutoff freq "); scanf("%d",&wc); printf("\n enter the choice for IIR filter 1. LPF 2.HPF "); scanf("%d",&c); switch(c) { case 1: for(w=0;w<100;w++) { H[w]=1/sqrt(1+mul((w/(float)wc),2*N)); printf("H[%d]=%f\n",w,H[w]); } break; case 2: for(w=0;w<=100;w++) { H[w]=1/sqrt(1+mul((float)wc/w,2*N)); printf("H[%d]=%f\n",w,H[w]); } break; }} float mul(float a,int x) { for(i=0;i<x-1;i++) a*=a; return(a);

33 } OUT PUT WAVE FORMS:

Result: The design of Butterworth Digital (low pass & high pass) filter is performed.

Vous aimerez peut-être aussi