70
Digital signal processing Lab Manual DEPARTMENT OF ECE 1 EXPERIMENT No. 1 Generation of Sinusoidal waveform/ Signal based on recursive difference equations %program to generate sinusoidal signals with different amplitudes title('sine waves'); t=0:.5:2*pi; y=sin(t) y1=5*sin(t) y2=10*sin(t) y3=15*sin(t) subplot(4,2,1); plot(y); xlabel('time'); ylabel('amplitude'); subplot(4,2,2); stem(y) xlabel('n---->'); ylabel('amplitude'); subplot(4,2,3); plot(y1); xlabel('time'); ylabel('amplitude'); subplot(4,2,4); stem(y1) xlabel('n---->'); ylabel('amplitude'); subplot(4,2,5); plot(y2); xlabel('time'); ylabel('amplitude'); subplot(4,2,6); stem(y2) xlabel('n--->'); ylabel('amplitude'); subplot(4,2,7); plot(y3); xlabel('time'); ylabel('amplitude'); subplot(4,2,8); stem(y3) xlabel('n-->'); ylabel('amplitude');

EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

1

EXPERIMENT No. 1

Generation of Sinusoidal waveform/ Signal based on recursive difference equations

%program to generate sinusoidal signals with different amplitudes

title('sine waves');

t=0:.5:2*pi;

y=sin(t)

y1=5*sin(t)

y2=10*sin(t)

y3=15*sin(t)

subplot(4,2,1);

plot(y);

xlabel('time');

ylabel('amplitude');

subplot(4,2,2);

stem(y)

xlabel('n---->');

ylabel('amplitude');

subplot(4,2,3);

plot(y1);

xlabel('time');

ylabel('amplitude');

subplot(4,2,4);

stem(y1)

xlabel('n---->');

ylabel('amplitude');

subplot(4,2,5);

plot(y2);

xlabel('time');

ylabel('amplitude');

subplot(4,2,6);

stem(y2)

xlabel('n--->');

ylabel('amplitude');

subplot(4,2,7);

plot(y3);

xlabel('time');

ylabel('amplitude');

subplot(4,2,8);

stem(y3)

xlabel('n-->');

ylabel('amplitude');

Page 2: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

2

RESULT:

%program to generate sum of sine sequences

title('sum of sin waves');

t=0:.5:2*pi;

x=sin(t);

subplot(4,2,1);

stem(x);

xlabel('n---->');

ylabel('amplitude');

title('sin wave');

subplot(4,2,2);

plot(x);

xlabel('n---->');

ylabel('amplitude');

title('sin wave');

y1=sin(t)+5*sin(2*t);

subplot(4,2,3);

stem(y1);

xlabel('n---->');

ylabel('amplitude');

title('sin wave with harmonic');

subplot(4,2,4);

plot(y1);

xlabel('n---->');

ylabel('amplitude');

title('sin wave with harmonic');

Page 3: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

3

y2=sin(t)+5*sin(2*t)+10*sin(3*t);

subplot(4,2,5);

stem(y2);

xlabel('n---->');

ylabel('amplitude');

title('sin wave with two harmonics');

subplot(4,2,6);

plot(y2);

xlabel('n---->');

ylabel('amplitude');

title('sin wave with two harmonics');

y3=sin(t)+5*sin(2*t)+10*sin(3*t)+15*sin(4*t);

subplot(4,2,7);

stem(y3);

xlabel('n---->');

ylabel('amplitude');

title('sin wave with three harmonics');

subplot(4,2,8);

plot(y3);

xlabel('n---->');

ylabel('amplitude');

title('sin wave with three harmonics');

RESULT:-

Page 4: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

4

VIVA QUESTIONS

1.what is the difference between sin & cos signals?

2.What is meant by signal?

3. What is the difference between time domain & frequency domain signal?

4. What is the difference between periodic & a periodic signal.

5. What is the difference between orthogonal and orthonormal signals?

6. What is the need for Fourier series & Fourier transform?

7. What is the difference between discrete & digital signals?

8. What is the difference between even signal & odd signal?

9. What is the difference between power signal & energy signal?

Page 5: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

5

EXPERIMENT No. 2

To find DFT/IDFT of a given sequence

%program to generate DFT of a given sequence

clc;

clear all;

close all;

x=input('enter sequence');

L=length(x);

for i=1:L

s=0;

for k=1:L

s=s+x(k).*exp(-j*2*pi*(i-1)*(k-1)/L);

end;

c(i)=s;

a=abs(c)

end;

display(c);

RESULT

enter sequence[1,2,3]

>> c

c

6.0000 -1.5000 + 0.8660i -1.5000 - 0.8660i

>> fft(x)

ans =

-1.5000 + 0.8660i -1.5000 - 0.8660i

Page 6: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

6

%program to generate IDFT of a given sequence

clc;

clear all;

close all;

x=input('enter sequence');

L=length(x);

for i=1:L

s=0;

for k=1:L

s=s+x(k).*exp(j*2*pi*(i-1)*(k-1)/L);

end;

c(i)=s/L;

end;

display(c);

RESULT:

enter sequence[1,2,3]

>> c

c =

2.0000 -0.5000 - 0.2887i -0.5000 + 0.2887i

Page 7: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

7

VIVA QUESTIONS

1. How many multiplication and additions are required to compute N point DFT using

radix 2 FFT?

2. Define DTFT pair.

3. What are Twiddle factors of the DFT?

4. State Periodicity Property of DFT.

5. What is the difference between DFT and DTFT?

6. Why need of FFT?

7. Find the IDFT of Y (k) = (1, 0, 1, 0)

8. Compute the Fourier transform of the signal x(n) = u(n) – u(n-1).

9. Compare DIT and DIF?

10. What is meant by in place in DIT and DIF algorithm?

11. Is the DFT of a finite length sequence is periodic? If so, state the reason.

Page 8: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

8

EXPERIMENT No. 3 To find frequency response of a given system given in (transfer function/difference form)

y(n)-1/12y(n-1)-1/12y(n-2)=x(n)

%program to generate frequency response of a given difference equation

clc;

clear all;

close all;

b=[12 0 0];

a=[12 -1 -1];

zplane(b,a);

figure;

w=0:0.1:pi;

[h,w]=freqz(b,a,w);

m=20*log(abs(h));

subplot(121);

plot(w/pi,m);

xlabel('freq');

ylabel('magnitude');

title('magnitude of transfer function');

p=(angle(h)*180/pi);

subplot(122);

plot(w/pi,p);

xlabel('freq');

ylabel('phase');

title('phase of transfer function');

RESULT:

-1 -0.5 0 0.5 1

-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

2

Real Part

Imag

inar

y Pa

rt

Page 9: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

9

0 0.5 1-2

-1

0

1

2

3

4

freq

magnitude

magnitude of transfer function

0 0.5 1-10

-8

-6

-4

-2

0

2

freq

phase

phase of transfer function

B=[1 0 0.9], A=[1 0 0.4]

%program to generate frequency response of a given transfer function

clc;

clear all;

close all;

b=[1 0 0.9];

a=[1 0 0.4];

zplane(b,a);

figure;

w=0:0.1:pi;

[h,w]=freqz(b,a,w);

m=20*log(abs(h));

subplot(121);

plot(w/pi,m);

xlabel('freq');

ylabel('magnitude');

title('magnitude of transfer function');

p=(angle(h)*180/pi);

subplot(122);

plot(w/pi,p);

xlabel('freq');

ylabel('phase');

title('phase of transfer function');

Page 10: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

10

RESULT:

-1 -0.5 0 0.5 1

-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

Real Part

Imag

inar

y P

art

0 0.5 1-35

-30

-25

-20

-15

-10

-5

0

5

10

freq

mag

nitu

de

magnitude of transfer function

0 0.5 1-60

-40

-20

0

20

40

60

freq

phas

e

phase of transfer function

VIVA QUESTIONS

1. What is mean by difference equation?

2. what is the difference between recursive and non recursive difference equation.

3. What is transfer function.

4. How to calculate magnitude in decibels.

5. How to calculate frequency response in MATLAB.

Page 11: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

11

EXPERIMENT No. 4

Implementation of FFT /IFFT of a sequence

%program to generate FFT of a given sequence

clc;

clear all;

close all;

x=input('enter input sequence');

n=input('enter the order');

y=fft(x,n);

display(abs(y));

subplot(1,2,1);

stem(x);

xlabel('n');

ylabel('magnitude');

title('plot of input sequences');

subplot(1,2,2);

stem(abs(y));

xlabel('n');

ylabel('magnitude');

title('plot of output fft');

Input:

enter input sequence[1 2 3 4]

enter the order: 8

Output:

ans =

Columns 1 through 6

10.0000 7.2545 2.8284 2.7153 2.0000 2.7153

Columns 7 through 8

2.8284 7.2545

Page 12: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

12

Expected graph:

1 2 3 40

0.5

1

1.5

2

2.5

3

3.5

4

n

mag

nitu

de

plot of input sequences

0 2 4 6 80

1

2

3

4

5

6

7

8

9

10

n

mag

nitu

de

plot of output fft

%program to generate IFFT of a given sequence

clc;

clear all;

close all;

x=input('enter input sequence');

n=input('enter the order');

y=ifft(x,n);

display(abs(y));

subplot(1,2,1);

stem(x);

xlabel('n');

ylabel('magnitude');

title('plot of input sequences');

subplot(1,2,2);

stem(abs(y));

xlabel('n');

ylabel('magnitude');

title('plot of output ifft');

Input:

enter input sequence[10.0000 7.2545 2.8284 2.7153 2.0000 2.7153 2.8284 7.2545]

enter the order: 8

Output:

ans =

Page 13: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

13

Columns 1 through 6

37.5964 14.4194 6.3432 1.5806 2.2828 1.5806

Columns 7 through 8

6.3432 14.4194

Expected graph:

0 2 4 6 80

1

2

3

4

5

6

7

8

9

10

n

mag

nitu

de

plot of input sequences

0 2 4 6 80

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

n

mag

nitu

deplot of output ifft

VIVA QUESTIONS

1. What is meant by radix 2 FFT?

2 . State the properties of W N(k) ?

3. What is bit reversal in FFT?

4. Determine the no of bits required in computing the DFT of a 1024 point sequence

with SNR of 30dB.

5. What is the use of Fourier transform?

6. What are the advantages FFT over DFT?

Page 14: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

14

EXPERIMENT No. 5

Determination of Power Spectrum of a given sequence

Consider the input signal x(n) of length N in matrix form and the correlated signal is denoted as

y(n).

y(n) is given by the formula.

y(n) =

k

nkxkx )()(

where n = - (N-1) to (N-1)

Now the PSD = FFT ( Auto-correlation function y(n) ).

%program for auto & psd

clc;

clear all;

close all;

x=input('enter the sequence');

y=xcorr(x,x);

subplot(3,1,1);

stem(x);

ylabel('Amplitude--->');

xlabel(' n----->');

title('input seq');

subplot(3,1,2);

stem(y);

ylabel('Amplitude----.');

xlabel('n---->');

title('autocorr seq for input');

disp('autocorr seq for input');

N=4;

p=fft(y,N);

ylabel('Amplitude--->');

xlabel('K----->');

title('psd of input');

subplot(3,1,3);

stem(p);

disp('the psd fun');

Input:

Input sequence : [1,1.5,2,2.5,3,3.5,4]

Output:

Page 15: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

15

VIVA QUESTIONS

1. How to calculate PSD.

2. What is PSD.

3. What is the relation between PSD and auto correlation function.

4. What is the definition for energy and power?

Page 16: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

16

EXPERIMENT No. 6

Implementation of LP FIR filer for a given sequence

%program to implement LP FIR filter for a given sequence using Rectangular Window

clc;

clear all;

close all;

rp=input('Enter the pass band ripple');

rs=input('Enter the stop band ripple');

fp=input('Enter the pass band frequency');

fs=input('Enter the stop band frequency');

f=input('Enter the sampling frequency');

wp=2*fp/f;

ws=2*fs/f;

num=-20*log10(sqrt(rp*rs));

dem=14.6*(fs-fp)/f;

n=ceil(num/dem);

n1=n+1;

if(rem(n,2)~=0)

n1=n;

n=n-1;

end

y=boxcar(n1);

b=fir1(n,wp,y);

[h,om]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,1,1);

plot(om/pi,m);

xlabel('frequency');

ylabel('gain’);

title('Rectangular window for Low pass filter magnitude response');

an=angle(h);

subplot(2,1,2);

plot(om/pi,an);

xlabel('frequency');

ylabel('phase’);

title('Rectangular window for Low pass filter phase response');

Input:

Enter the pass band ripple: 0.45

Enter the stop band ripple: 0.56

Enter the pass band frequency: 125

Enter the stop band frequency: 150

Enter the sampling frequency: 1000

Page 17: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

17

Expected graph

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

-50

0

50

frequency

magnitude

Rectangular window for Low pass filter magnitude response

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

-2

0

2

4

frequency

phase

Rectangular window for Low pass filter phase response

%program to implement LP FIR filter for a given sequence using Triangular Window

clc;

clear all;

close all;

rp=input('Enter the pass band ripple');

rs=input('Enter the stop band ripple');

fp=input('Enter the pass band frequency');

fs=input('Enter the stop band frequency');

f=input('Enter the sampling frequency');

wp=2*fp/f;

ws=2*fs/f;

num=-20*log10(sqrt(rp*rs));

dem=14.6*(fs-fp)/f;

n=ceil(num/dem);

n1=n+1;

if(rem(n,2)~=0)

n1=n;

n=n-1;

end

y=triang(n1);

b=fir1(n,wp,y);

[h,om]=freqz(b,1,256);

m=20*log10(abs(h));

Page 18: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

18

subplot(2,1,1);

plot(om/pi,m);

xlabel('frequency');

ylabel('gain');

title('Triangular window for low pass filter magnitude response');

an=angle(h);

subplot(2,1,2);

plot(om/pi,an);

xlabel('frequency');

ylabel('phase’);

title('Triangular window for Low pass filter phase response');

Input:

Enter the pass band ripple: 0.45

Enter the stop band ripple: 0.56

Enter the pass band frequency: 125

Enter the stop band frequency: 150.

Enter the sampling frequency: 1000

Expected graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-40

-20

0

20

frequency

gain

Triangular window for low pass filter magnitude response

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

-2

0

2

4

frequency

phase

Triangular window for Low pass filter phase response

Page 19: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

19

%program to implement LP FIR filter for a given sequence using Kaiser Window

clc;

clear all;

close all;

rp=input('Enter the pass band ripple');

rs=input('Enter the stop band ripple');

fp=input('Enter the pass band frequency');

fs=input('Enter the stop band frequency');

f=input('Enter the sampling frequency');

wp=2*fp/f;

ws=2*fs/f;

num=-20*log10(sqrt(rp*rs));

dem=14.6*(fs-fp)/f;

n=ceil(num/dem);

n1=n+1;

if(rem(n,2)~=0)

n1=n;

n=n-1;

end

y=kaiser(n1);

b=fir1(n,wp,,y);

[h,om]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,1,1);

plot(om/pi,m);

xlabel('frequency');

ylabel('gain');

title('Kaiser window for low pass filter magnitude response');

an=angle(h);

subplot(2,1,2);

plot(om/pi,an);

xlabel('frequency');

ylabel('phase’);

title('Kaiser window for Low pass filter phase response');

Input:

Enter the pass band ripple: 0.45

Enter the stop band ripple: 0.56

Enter the pass band frequency: 125

Enter the stop band frequency: 150.

Enter the sampling frequency: 1000

Page 20: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

20

Expected graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

-50

0

50

frequency

gain

Kaiser window for low pass filter magnitude response

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

-2

0

2

4

frequency

phase

Kaiser window for Low pass filter phase response

Page 21: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

21

EXPERIMENT No. 7

Implementation of HP FIR filer for a given sequence

%program to implement HP FIR filter for a given sequence using Rectangular Window

clc;

clear all;

close all;

rp=input('Enter the pass band ripple');

rs=input('Enter the stop band ripple');

fp=input('Enter the pass band frequency');

fs=input('Enter the stop band frequency');

f=input('Enter the sampling frequency');

wp=2*fp/f;

ws=2*fs/f;

num=-20*log10(sqrt(rp*rs));

dem=14.6*(fs-fp)/f;

n=ceil(num/dem);

n1=n+1;

if(rem(n,2)~=0)

n1=n;

n=n-1;

end

y=boxcar(n1);

b=fir1(n,wp,'high',y);

[h,om]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,1,1);

plot(om/pi,m);

xlabel('frequency');

ylabel('gain’);

title('Rectangular window for High pass filter magnitude response');

an=angle(h);

subplot(2,1,2);

plot(om/pi,an);

xlabel('frequency');

ylabel('phase’);

title('Rectangular window for High pass filter phase response');

Input:

Enter the pass band ripple: 0.45

Enter the stop band ripple: 0.56

Enter the pass band frequency: 125

Enter the stop band frequency: 150.

Enter the sampling frequency: 1000

Page 22: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

22

Expected graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

-50

0

50

frequency

gain

Rectangular window for High pass filter magnitude response

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

-2

0

2

4

frequency

phase

Rectangular window for High pass filter phase response

%program to implement HP FIR filter for a given sequence using Triangular Window

clc;

clear all;

close all;

rp=input('Enter the pass band ripple');

rs=input('Enter the stop band ripple');

fp=input('Enter the pass band frequency');

fs=input('Enter the stop band frequency');

f=input('Enter the sampling frequency');

wp=2*fp/f;

ws=2*fs/f;

num=-20*log10(sqrt(rp*rs));

dem=14.6*(fs-fp)/f;

n=ceil(num/dem);

n1=n+1;

if(rem(n,2)~=0)

n1=n;

n=n-1;

end

y=triang(n1);

b=fir1(n,wp,'high',y);

[h,om]=freqz(b,1,256);

Page 23: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

23

m=20*log10(abs(h));

subplot(2,1,1);

plot(om/pi,m);

xlabel('frequency');

ylabel('gain');

title('Triangular window for High pass filter magnitude response');

an=angle(h);

subplot(2,1,2);

plot(om/pi,an);

xlabel('frequency');

ylabel('phase’);

title('Triangular window for High pass filter phase response');

Input:

Enter the pass band ripple: 0.45

Enter the stop band ripple: 0.56

Enter the pass band frequency: 125

Enter the stop band frequency: 150.

Enter the sampling frequency: 1000

Expected graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-30

-20

-10

0

10

frequency

gain

Triangular window for High pass filter magnitude response

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

-2

0

2

4

frequency

phase

Triangular window for High pass filter phase response

Page 24: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

24

%program to implement HP FIR filter for a given sequence using Kaiser Window

clc;

clear all;

close all;

rp=input('Enter the pass band ripple');

rs=input('Enter the stop band ripple');

fp=input('Enter the pass band frequency');

fs=input('Enter the stop band frequency');

f=input('Enter the sampling frequency');

wp=2*fp/f;

ws=2*fs/f;

num=-20*log10(sqrt(rp*rs));

dem=14.6*(fs-fp)/f;

n=ceil(num/dem);

n1=n+1;

if(rem(n,2)~=0)

n1=n;

n=n-1;

end

y=kaiser(n1,1);

b=fir1(n,wp,'high',y);

[h,om]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,1,1);

plot(om/pi,m);

xlabel('frequency');

ylabel('gain');

title('Kaiser window for High pass filter magnitude response');

an=angle(h);

subplot(2,1,2);

plot(om/pi,an);

xlabel('frequency');

ylabel('phase’);

title('Kaiser window for High pass filter phase response');

Input:

Enter the pass band ripple: 0.45

Enter the stop band ripple: 0.56

Enter the pass band frequency: 125

Enter the stop band frequency: 150.

Enter the sampling frequency: 1000

Page 25: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

25

Expected graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

-50

0

50

frequency

gain

Kaiser window for High pass filter magnitude response

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

-2

0

2

4

frequency

phase

Kaiser window for High pass filter phase response

VIVA QUESTIONS

1. What is FIR

2. What is the difference between FIR and IIR.

3. What is the equation for FIR.

4. Is FIR is stable.

5. Is FIR recursive.

6. What are the different windowing techniques used in FIR.

7. What is the need of Windowing techniques.

Page 26: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

26

EXPERIMENT No. 8

Implementation of LP IIR filer for a given sequence

%program to implement LP IIR filter for a given sequence using Butterworth filter

clc;

clear all;

close all;

rp=input('Enter the pass band ripple');

rs=input('Enter the stop band ripple');

wp=input('Enter the pass band frequency');

ws=input('Enter the stop band frequency');

f=input('Enter the sampling frequency');

w1=wp/f;

w2=ws/f;

[n,wn]=buttord(w1,w2,rp,rs);

[b,a]=butter(n,wn);

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log10(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain');

xlabel('normal frequency');

subplot(2,1,2);

plot(om/pi,an);

ylabel('phase');

xlabel('normal frequency');

title('Butterworth LP IIR filter');

Input:

Enter the pass band ripple: 0.45

Enter the stop band ripple: 0.56

Enter the pass band frequency: 125

Enter the stop band frequency: 150.

Enter the sampling frequency: 1000

Page 27: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

27

Expected graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-80

-60

-40

-20

0

gain

normal frequency

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-2

-1.5

-1

-0.5

0

phase

normal frequency

Butterworth LP IIR filter

Page 28: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

28

%program to implement LP IIR filter for a given sequence using Chebyshev filter

clc;

clear all;

close all;

rp=input('Enter the pass band ripple');

rs=input('Enter the stop band ripple');

wp=input('Enter the pass band frequency');

ws=input('Enter the stop band frequency');

f=input('Enter the sampling frequency');

w1=2*wp/f;

w2=2*ws/f;

[n,wn]=cheb1ord(w1,w2,rp,rs);

[b,a]=cheby1(n,rp,wn);

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log10(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain');

xlabel('normal frequency');

subplot(2,1,2);

plot(om/pi,an);

ylabel('phase');

xlabel('normal frequency');

title(Chebyshev LP IIR filter');

Input:

Enter the pass band ripple: 0.45

Enter the stop band ripple: 0.56

Enter the pass band frequency: 125

Enter the stop band frequency: 150.

Enter the sampling frequency: 1000

Page 29: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

29

Expected graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-80

-60

-40

-20

0

gain

normal frequency

Chebyshev LP IIR filter

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-2

-1.5

-1

-0.5

0

phase

normal frequency

Chebyshev LP IIR filter

Page 30: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

30

EXPERIMENT No. 9

Implementation of HP IIR filer for a given sequence

%program to implement HP IIR filter for a given sequence using Butterworth filter

clc;

clear all;

close all;

rp=input('Enter the pass band ripple');

rs=input('Enter the stop band ripple');

wp=input('Enter the pass band frequency');

ws=input('Enter the stop band frequency');

f=input('Enter the sampling frequency');

w1=wp/f;

w2=ws/f;

[n,wn]=buttord(w1,w2,rp,rs);

[b,a]=butter(n,wn,'high');

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log10(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain');

xlabel('normal frequency');

subplot(2,1,2);

plot(om/pi,an);

ylabel('phase');

xlabel('normal frequency');

title('Butterworth IIR HP filter');

Input:

Enter the pass band ripple: 0.45

Enter the stop band ripple: 0.56 Enter the pass band frequency: 125

Enter the stop band frequency: 150.

Enter the sampling frequency: 1000

Page 31: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

31

Expected graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-60

-40

-20

0

gain

normal frequency

Butterworth IIR HP filter

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

2

phase

normal frequency

Butterworth IIR HP filter

%program to implement HP IIR filter for a given sequence using Chebyshev filter

clc;

clear all;

close all;

rp=input('Enter the pass band ripple');

rs=input('Enter the stop band ripple');

wp=input('Enter the pass band frequency');

ws=input('Enter the stop band frequency');

f=input('Enter the sampling frequency');

w1=2*wp/f;

w2=2*ws/f;

[n,wn]=cheb1ord(w1,w2,rp,rs);

[b,a]=cheby1(n,rp,wn,'high');

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log10(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain');

xlabel('normal frequency');

subplot(2,1,2);

Page 32: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

32

plot(om/pi,an);

ylabel('phase');

xlabel('normal frequency');

title('frequency response of hpf filter');

Input:

Enter the pass band ripple: 0.45

Enter the stop band ripple: 0.56

Enter the pass band frequency: 125

Enter the stop band frequency: 150.

Enter the sampling frequency: 1000

Expected graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-30

-20

-10

0

gain

normal frequency

frequency response of hpf filter

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

2

phase

normal frequency

frequency response of hpf filter

VIVA QUESTIONS

1. What is IIR

2. What is the difference between FIR and IIR.

3. What is the equation for IIR.

4. Is IIR is stable.

5. Is IIR recursive.

6. What are the different filtering techniques used in IIR.

7. What is the need of filtering techniques.

Page 33: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

33

EXPERIMENT No: 10

Generation of DTMF signals

clc;

d = input('Type in the telephone digit = ', 's');

symbol = abs(d);

tm = [49 50 51 65;52 53 54 66;55 56 57 67;42 48 35 68];

for p = 1:4;

for q = 1:4;

if tm(p,q) == abs(d);break,end

end

if tm(p,q) == abs(d);break,end

end

f1 = [697 770 852 941];

f2 = [1209 1336 1477 1633];

n = 0:204;

x = sin(2*pi*n*f1(p)/8000) + sin(2*pi*n*f2(q)/8000);

k = [18 20 22 24 31 34 38 42];

val = zeros(1,8);

for m = 1:8;

Fx(m) = goertzel(x,k(m)+1);

end

val = abs(Fx);

stem(k,val);grid; xlabel('k');ylabel('|X[k]|');

limit = 80;

for s = 5:8;

if val(s) > limit,break,end

end

for r = 1:4;

if val(r) > limit,break,end

end

disp(['Touch-Tone Symbol = ',setstr(tm(r,s-4))])

Input:

Type in the telephone digit = 4

Touch-Tone Symbol = 4

Page 34: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

34

15 20 25 30 35 40 450

20

40

60

80

100

120

k

|X[k

]|

VIVA QUESTIONS

1. What is DTMF

2. Where it is used.

3. why it is used in DSP.

Page 35: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

35

EXPERIMENT No:11

Implementation of Decimation process

% Illustration of Decimation Process

clc;

M = input('Down-sampling factor = ');

n = 0:99;

x = sin(2*pi*0.043*n) + sin(2*pi*0.031*n);

y = decimate(x,M,'fir');

subplot(2,1,1);

stem(n,x(1:100));

title('Input Sequence');

xlabel('Time index n');ylabel('Amplitude');

subplot(2,1,2);

m = 0:(100/M)-1;

stem(m,y(1:100/M));

title('Output Sequence');

xlabel('Time index n');

ylabel('Amplitude');

Input:

Down-sampling factor = 4

Expected graph:

0 10 20 30 40 50 60 70 80 90 100-2

-1

0

1

2Input Sequence

Time index n

Am

plitu

de

0 5 10 15 20 25-2

-1

0

1

2Output Sequence

Time index n

Am

plitu

de

Page 36: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

36

EXPERIMENT No: 12

Implementation of Interpolation process

% Illustration of Interpolation Process

clc;

L = input('Up-sampling factor = ');

% Generate the input sequence

n = 0:49;

x = sin(2*pi*0.043*n) + sin(2*pi*0.031*n);

% Generate the interpolated output sequence

y = interp(x,L);

% Plot the input and the output sequences

subplot(2,1,1);

stem(n,x(1:50));

title('Input Sequence');

xlabel('Time index n'); ylabel('Amplitude');

subplot(2,1,2);

m = 0:(50*L)-1;

stem(m,y(1:50*L));

title('Output Sequence');

xlabel('Time index n'); ylabel('Amplitude');

Input:

Up-sampling factor = 2

Expected graph:

0 5 10 15 20 25 30 35 40 45 50-2

-1

0

1

2Input Sequence

Time index n

Am

plitu

de

0 10 20 30 40 50 60 70 80 90 100-2

-1

0

1

2Output Sequence

Time index n

Am

plitu

de

Page 37: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

37

EXPERIMENT No: 13

Implementation of I/D sampling rate converters

% Illustration of Sampling Rate Alteration by a Ratio of Two Integers

clc;

L = input('Up-sampling factor = ');

M = input('Down-sampling factor = ');

n = 0:29;

x = sin(2*pi*0.43*n) + sin(2*pi*0.31*n);

y = resample(x,L,M);

subplot(2,1,1);

stem(n,x(1:30));axis([0 29 -2.2 2.2]);

title('Input Sequence');

xlabel('Time index n');

ylabel('Amplitude');

subplot(2,1,2);

m = 0:(30*L/M)-1;

stem(m,y(1:30*L/M));

axis([0 (30*L/M)-1 -2.2 2.2]);

title('Output Sequence');

xlabel('Time index n');

ylabel('Amplitude');

Input:

Up-sampling factor = 3, Down-sampling factor = 2

Expected graph:

0 5 10 15 20 25

-2

-1

0

1

2

Input Sequence

Time index n

Ampl

itude

0 5 10 15 20 25 30 35 40

-2

-1

0

1

2

Output Sequence

Time index n

Ampl

itude

Page 38: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

38

VIVA QUESTIONS

1. What is decimation .

2. What is interpolation

3. What is I/D

4. What is know to be subband coding

5. Define sampling rate conversion

6. How the image enchancement is achieved using DSP

7. Define compression

8. What are various compression technique

9. Explain subband coding

Page 39: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

39

INTRODUCTION TO CODE COMPOSER STUDIO

Code Composer is the DSP industry's first fully integrated development environment (IDE)

with DSP-specific functionality. With a familiar environment liked MS-based C++TM, Code

Composer lets you edit, build, debug, profile and manage projects from a single unified environment.

Other unique features include graphical signal analysis, injection/extraction of data signals via file

I/O, multi-processor debugging, automated testing and customization via a C-interpretive scripting

language and much more.

CODE COMPOSER FEATURES INCLUDE:

IDE

Debug IDE

Advanced watch windows

Integrated editor

File I/O, Probe Points, and graphical algorithm scope probes

Advanced graphical signal analysis

Interactive profiling

Automated testing and customization via scripting

Visual project management system

Compile in the background while editing and debugging

Multi-processor debugging Help on the target DSP

TMS320C6713 DSP FEATURES

Highest-Performance Floating-Point Digital Signal Processor (DSP):

Eight 32-Bit Instructions/Cycle

32/64-Bit Data Word

300-, 225-, 200-MHz (GDP), and 225-, 200-, 167-MHz (PYP) Clock Rates

3.3-, 4.4-, 5-, 6-Instruction Cycle Times

2400/1800, 1800/1350, 1600/1200, and 1336/1000 MIPS /MFLOPS

Rich Peripheral Set, Optimized for Audio

Highly Optimized C/C++ Compiler

Extended Temperature Devices Available

Advanced Very Long Instruction Word (VLIW) TMS320C67x™ DSP Core

Eight Independent Functional Units:

Two ALUs (Fixed-Point)

Four ALUs (Floating- and Fixed-Point)

Two Multipliers (Floating- and Fixed-Point)

Load-Store Architecture With 32 32-Bit General-Purpose Registers

Instruction Packing Reduces Code Size

Page 40: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

40

All Instructions Conditional

Instruction Set Features

Native Instructions for IEEE 754

Single- and Double-Precision

Byte-Addressable (8-, 16-, 32-Bit Data)

8-Bit Overflow Protection

Saturation; Bit-Field Extract, Set, Clear; Bit-Counting; Normalization

L1/L2 Memory Architecture

4K-Byte L1P Program Cache (Direct-Mapped)

4K-Byte L1D Data Cache (2-Way)

256K-Byte L2 Memory Total: 64K-Byte L2 Unified Cache/Mapped RAM, and 192K-Byte

Additional L2 Mapped RAM

Device Configuration

Boot Mode: HPI, 8-, 16-, 32-Bit ROM Boot

Endianness: Little Endian, Big Endian

32-Bit External Memory Interface (EMIF)

Glueless Interface to SRAM, EPROM, Flash, SBSRAM, and SDRAM

512M-Byte Total Addressable External Memory Space

Enhanced Direct-Memory-Access (EDMA) Controller (16 Independent Channels)

16-Bit Host-Port Interface (HPI)

Two Multichannel Audio Serial Ports (McASPs)

Two Independent Clock Zones Each (1 TX and 1 RX)

Eight Serial Data Pins Per Port:

Individually Assignable to any of the Clock Zones

Each Clock Zone Includes:

Programmable Clock Generator

Programmable Frame Sync Generator

TDM Streams From 2-32 Time Slots

Support for Slot Size:

8, 12, 16, 20, 24, 28, 32 Bits

Data Formatter for Bit Manipulation

Wide Variety of I2S and Similar Bit Stream Formats

Integrated Digital Audio Interface Transmitter (DIT) Supports:

S/PDIF, IEC60958-1, AES-3, CP-430 Formats

Up to 16 transmit pins

Enhanced Channel Status/User Data

Extensive Error Checking and Recovery

Two Inter-Integrated Circuit Bus (I2C Bus™) Multi-Master and Slave Interfaces

Two Multichannel Buffered Serial Ports:

Serial-Peripheral-Interface (SPI)

High-Speed TDM Interface

AC97 Interface

Two 32-Bit General-Purpose Timers

Dedicated GPIO Module With 16 pins (External Interrupt Capable)

Flexible Phase-Locked-Loop (PLL) Based Clock Generator Module

IEEE-1149.1 (JTAG ) Boundary-Scan-Compatible

Package Options:

208-Pin PowerPAD™ Plastic (Low-Profile) Quad Flatpack (PYP)

272-BGA Packages (GDP and ZDP)

Page 41: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

41

0.13-µm/6-Level Copper Metal Process

CMOS Technology

3.3-V I/Os, 1.2 -V Internal (GDP & PYP)

3.3-V I/Os, 1.4-V Internal (GDP)(300 MHz only)

TMS320C6713 DSK Overview Block Diagram

Page 42: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

42

EXPERIMENT No. 1

AIM:

To verify the linear convolution operation Using DSK Code composer studio

EQUIPMENTS NEEDED:

Host (PC) with windows (95/98/Me/XP/NT/2000).

TMS320C6713 DSP Starter Kit (DSK).

INTRODUCTION:

Linear Convolution involves the following operations.

Folding

Multiplication

Addition

Shifting

These operations can be represented by a Mathematical Expression as follows:

x[ ]= Input signal Samples

h[ ]= Impulse response co-efficient.

y[ ]= Convolution output.

n = No. of Input samples

h = No. of Impulse response co-efficient.

Eg: x[n] = {1, 2, 3, 4}

h[k] = {1, 2, 3, 4}

Where: n=4, k=4. ;Values of n & k should be a multiple of 4.

If n & k are not multiples of 4, pad with zero’s to make

multiples of 4

r= n+k-1 ; Size of output sequence.

= 4+4-1

= 7.

r= 0 1 2 3 4 5 6

n= 0 x[0]h[0] x[0]h[1] x[0]h[2] x[0]h[3]

1 x[1]h[0] x[1]h[1] x[1]h[2] x[1]h[3]

2 x[2]h[0] x[2]h[1] x[2]h[2] x[2]h[3]

3 x[3]h[0] x[3]h[1] x[3]h[2] x[3]h[3]

Page 43: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

43

Output: y[r] = { 1, 4, 10, 20, 25, 24, 16}.

NOTE: At the end of input sequences pad ‘n’ and ‘k’ no. of zero’s

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:\ti\myprojects) with name lconv.pjt.

Add the source files conv.asm.

to the project using ‘Projectadd files to project’ pull down menu.

Add the linker command file hello.cmd.

(Path: c:\ti\tutorial\dsk6713\hello1\hello.cmd)

Add the run time support library file rts6700.lib.

(Path: c:\ti\c6000\cgtools\lib\rts6700.lib)

Compile the program using the ‘Project-compile’ pull down menu or by

clicking the shortcut icon on the left side of program window.

Build the program using the ‘Project-Build’ pull down menu or by

clicking the shortcut icon on the left side of program window.

Load the program (lconv.out) in program memory of DSP chip using the

‘File-load program’ pull down menu.

To View output graphically

Select view graph time and frequency.

PROGRAMMING FOR LINEAR CONVOLUTION IN ‘C’ LANGUAGE:

#include<stdio.h>

main()

{ int m=4; /*Lenght of i/p samples sequence*/

int n=4; /*Lenght of impulse response Co-efficients */

int i=0,j;

int x[10]={1,2,3,4,0,0,0,0}; /*Input Signal Samples*/

int h[10]={1,2,3,4,0,0,0,0}; /*Impulse Response Co-efficients*/

/*At the end of input sequences pad ‘M’ and ‘N’ no. of zero’s*/

int y[10];

for(i=0;i<m+n-1;i++)

{

y[i]=0;

for(j=0;j<=i;j++)

y[i]+=x[j]*h[i-j];

Page 44: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

44

}

for(i=0;i<m+n-1;i++)

printf("%d\n",y[i]);

}

RESULT:

Configure the graphical window as shown below

INPUT

x[n] = {1, 2, 3, 4,0,0,0,0}

h[k] = {1, 2, 3, 4,0,0,0,0}

OUTPUT:

Note:

To execute the above program follow “ procedure to work on code composer studio”

To view graphical output follow the above procedure.

QUESTIONS

1. What is the requirement for convolution?.

2. What is the difference between convolution & correlation?

3. What is meant by impulse response?

4. Is it possible to represent any discrete time signal in terms of impulses? If yes,

represent by using example.

5. Draw the h(2n-k) & h(n-2k) for the following sequence

h(n) = { 4 3 2 1} assume (i) k= 3 (ii) k =5.

6. Write the expressions for LTI system convolution formula & causal LTI system

convolution formula.

7. What us the length of linear convolution if length of input & impulse responses

are N1 & N2 respectively?

Page 45: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

45

EXPERIMENT No. 2

AIM: To verify the circular convolution operation Using DSK Code composer studio.

EQUIPMENTS NEEDED:

Host (PC) with windows (95/98/Me/XP/NT/2000).

TMS320C6713 DSP Starter Kit (DSK).

CRO, Function Generators, Connecting wires

INTRODUCTION:

Steps for circular Convolution

Steps for circular convolution are the same as the usual convolution, except all index calculations are

done "mod N" = "on the wheel"

Steps for Cyclic Convolution

Step1: “Plot f[m] and h[−m]

Subfigure 1.1 Subfigure 1.2

Step 2: "Spin" h[−m] n times Anti Clock Wise (counter-clockwise) to get h[n-m]

(i.e. Simply rotate the sequence, h[n], clockwise by n steps)

Step 3: Point wise multiply the f[m] wheel and the h[n−m] wheel. sum=y[n]

Step 4: Repeat for all 0≤n≤N−1

Example 1: Convolve (n = 4)

Figure 2: Step 2

Page 46: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

46

Subfigure 3.1 Subfigure 3.2

Figure 3: Two discrete-time signals to be convolved.

h[−m] =

Figure 4

Multiply f[m] and sum to yield: y[0] =3

h[1−m]

Figure 5

Multiply f[m] and sum to yield: y[1] =5

h[2−m]

Figure 6

Multiply f[m] and sum to yield: y[2] =3

h[3−m]

Figure 7

Page 47: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

47

Multiply f[m] and sum to yield: y[3] =1

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:\ti\myprojects) with name cir conv.pjt.

Add the source files Circular Convolution.C.

to the project using ‘Projectadd files to project’ pull down menu.

Add the linker command file hello.cmd .

(Path: c:\ti\tutorial\dsk6713\hello1\hello.cmd)

Add the run time support library file rts6700.lib

(Path: c:\ti\c6000\cgtools\lib\rts6700.lib)

Compile the program using the ‘Project-compile’ pull down menu or by

clicking the shortcut icon on the left side of program window.

Build the program using the ‘Project-Build’ pull down menu or by

clicking the shortcut icon on the left side of program window.

Load the program(lconv.out) in program memory of DSP chip using the

‘File-load program’ pull down menu.

Page 48: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

48

PROGRAMMING FOR CIRCULAR CONVOLUTION IN ‘C’ LANGUAGE:

#include<stdio.h>

int m,n,x[30],h[30],y[30],i,j,temp[30],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*/

{

Page 49: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

49

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++)

x2[j]=a[j-1];

Page 50: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

50

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]);

}

RESULT:

IN PUT:

Eg: x[4]={3, 2, 1,0}

h[4]={1, 1, 0,0}

OUT PUT: y[4]={3, 5, 3,0}

Page 51: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

51

Extract Program

%Matlab program to compute linear convolution of a sequence

clc;

clear all;

close all;

x=input('enter first sequence');

y=input('enter second sequence');

n1=length(x);

n2=length(y);

temp=y;

y=fliplr(y);

x1=[zeros(1,n2-1) x];

y1=[y zeros(1,n1-1)];

for n=1:n1+n2-1

s=0;

for k=1:n1+n2-1

s=s+x1(k).*y1(k);

end;

c(n)=s;

y1=[y1(end) y1(1:end-1)];

end;

stem(c);

% a=abs(c);

% stem(a);

xlabel('time');

ylabel('magnitude');

title('linear convolution');

grid on;

Result:

enter first sequence[1,2,3]

enter second sequence[1,2,3]

Page 52: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

52

VIVA QUESTIONS

1. What is the requirement for convolution?.

2. What is the difference between convolution & correlation?

3. What is meant by impulse response?

4. Is it possible to represent any discrete time signal in terms of impulses? If yes,

represent by using example.

5. Draw the h(2n-k) & h(n-2k) for the following sequence

h(n) = { 4 3 2 1} assume (i) k= 3 (ii) k =5.

6. Write the expressions for LTI system convolution formula & causal LTI system

convolution formula.

Page 53: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

53

%matlab program to compute circular convolution of a sequence

clc;

clear all;

close all;

a=input('enter input sequences:');

b=input('enter input sequences:');

n1=length(a);

n2=length(b);

n=max(n1,n2);

n3=n1-n2;

if(n3<0)

a=[a,zeros(1,-n3)];

else

b=[b,zeros(1,n3)];

end

for x=1:n

f(x)=0;

for i=1:n

j=x-i+1;

if(j<=0)

j=n+j;

end

f(x)=f(x)+(a(i)*b(j));

end

end

display(f);

stem(f);

xlabel('n');

ylabel('magnitude');

title('plot of circular convolution');

Input:

enter input sequences: [1 2 3 4]

enter input sequences: [5 8 6 9]

Output:

f = 73 69 73 65

Expected graph:

Page 54: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

54

VIVA QUESTIONS

1. Why we need circular convolution?

2.What is the difference between circular & linear convolution?

3.What is the length of output sequence after circular convolution if the lengths of input & impulse

responses are M1 & M2 respectively?

Page 55: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

55

BUTTERWORTH IIR DIGITAL LOW PASS FILTERS:

%program for butter worth IIR digital LPF

Clc;

Close all;

Clear all;

wp=input('enter pass band cutoff frequency:');

ws=input('enter stop band cutoff frequency:');

rp=input('enter pass band ripple in db');

rs=input('enter stop band ripple in db');

fs=input('enter the sampling frequency');

w1=2*wp/fs;

w2=2*ws/fs;

[n,wn]=buttord(w1,w2,rp,rs,'s');

%[z,p,k]=butter(n,wn);

%[b,a]=zp2tf(z,p,k);

[b,a]=butter(n,wn,'s')

[b1,a1]=impinvar(b,a);

w=0:0.01:pi;

[h,om]=freqz(b1,a1,w);

m=20*log10(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

subplot(2,1,2);

plot(om/pi,an);

xlabel('normalized frequency---->');

ylabel('phase in radians---->');

Input:

enter pass band cutoff frequency:1500

enter stop band cutoff frequency:3000

enter pass band ripple in db10

enter stop band ripple in db40

enter the sampling freqency7000

Output:

b = 0 0 0 0 0 0 0.0040

a = 1.0000 1.5372 1.1815 0.5757 0.1870 0.0385 0.0040

Page 56: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

56

BUTTERWORTH IIR DIGITALHIGH PASS FILTER:

%Program for digital IIR HPF

wp=input('enter pass band edge freq');

ws=input('enter stop band edge freq');

rp=input('enter passband ripple');

rs=input('enter stopband ripple');

[N,wn]=buttord(wp,ws,rp,rs);

[b,a]=butter(N,wn,'high');

[h,omega]=freqz(b,a);

gain=20*log10(abs(h));

an=angle(h);

subplot(2,1,1);

plot(omega/pi,gain);

title('mag res of digital hpf');

xlabel('normalized freq----->');

ylabel('gain in db----->')

subplot(2,1,2);

plot(omega/pi,an);

title('phase res of digital hpf');

xlabel('normalized freq------->');

ylabel('angle---->');

Page 57: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

57

Input:

enter pass band edge freq .5

enter stop band edge freq .8

enter pass band ripple 10

enter stop band ripple 40

Output:

b =

0.0992 -0.3967 0.5950 -0.3967 0.0992

a =

1.0000 -0.0674 0.4875 -0.0141 0.0178

Page 58: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

58

BUTTERWORTH IIR DIGITAL BAND PASS FILTER :

clc;

clear all;

close all;

w1 =[.2 .7];

w2 =[.1 .8];

rp=0.3;

rs=40;

[n,wn]=buttord(w1,w2,rp,rs);

%[z,p,k]=butter(n,wn);

%[b,a]=zp2tf(z,p,k);

[b,a]=butter(n,wn);

% [b1,a1]=impinvar(b,a);

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

title('magnitude resonse');

grid on;

subplot(2,1,2);

plot(om/pi,an);

xlabel('normalized frequency---->');

ylabel('phase in radians---->');

title('phase response');

grid on;

Page 59: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

59

BUTTERWORTH IIR DIGITAL BAND STOP FILTER :

Clc;

Clear all;

Close all;

wp = [.1 .8];

ws = [.2 .7]

rp=0.3;

rs=40;

[n,wn]=buttord(w1,w2,rp,rs);

%[z,p,k]=butter(n,wn);

%[b,a]=zp2tf(z,p,k);

[b,a]=butter(n,wn,'stop');

% [b1,a1]=impinvar(b,a);

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

title('magnitude resonse');

grid on;

subplot(2,1,2);

plot(om/pi,an);

xlabel('normalized frequency---->');

ylabel('phase in radians---->');

title('phase response');grid on;

Page 60: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

60

CHEBYSHEV IIR DIGITAL LOWPASS FILTER:

w1 = .1;

w2 = .2;

rp=0.3;

rs=40;

[n,wn]=cheb1ord(w1,w2,rp,rs);

%[z,p,k]=butter(n,wn);

%[b,a]=zp2tf(z,p,k);

[b,a]=cheby1(n,rp,wn);

% [b1,a1]=impinvar(b,a);

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

title('magnitude resonse');

grid on;

subplot(2,1,2);

plot(om/pi,an);

xlabel('normalized frequency---->');

ylabel('phase in radians---->');

title('phase response');

grid on;

Page 61: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

61

CHEBYSHEV IIR DIGITAL HIGH PASS FILTERS:

w1 = .2,

w2 = .1

rp=0.3;

rs=40;

[n,wn]=cheb1ord(w1,w2,rp,rs);

%[z,p,k]=butter(n,wn);

%[b,a]=zp2tf(z,p,k);

[b,a]=cheby1(n,rp,wn,'high');

% [b1,a1]=impinvar(b,a);

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

title('magnitude resonse');

grid on;

subplot(2,1,2);

plot(om/pi,an);

xlabel('normalized frequency---->');

ylabel('phase in radians---->');

title('phase response');

grid on;

Page 62: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

62

CHEBYSHEV IIR DIGITAL BAND PASS FILTERS:

w1 = [.2 .7];

w2 = [.1 .8];

rp=0.3;

rs=40;

[n,wn]=cheb1ord(w1,w2,rp,rs);

%[z,p,k]=butter(n,wn);

%[b,a]=zp2tf(z,p,k);

[b,a]=cheby1(n,rp,wn);

% [b1,a1]=impinvar(b,a);

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

title('magnitude resonse');

grid on;

subplot(2,1,2);

plot(om/pi,an);

xlabel('normalized frequency---->');

ylabel('phase in radians---->');

title('phase response');

grid on;

Page 63: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

63

CHEBYSHEV IIR DIGITAL BAND STOP FILTER :

w1 = [.1 .8];

w2 = [.2 .7]

rp=0.3;

rs=40;

[n,wn]=cheb1ord(w1,w2,rp,rs);

%[z,p,k]=butter(n,wn);

%[b,a]=zp2tf(z,p,k);

[b,a]=cheby1(n,rp,wn,'stop');

% [b1,a1]=impinvar(b,a);

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

title('magnitude resonse');

grid on;

subplot(2,1,2);

plot(om/pi,an);

xlabel('normalized frequency---->');

ylabel('phase in radians---->');

title('phase response');

grid on;

Page 64: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

64

DESIGN FIR (LP/HP) FIR LOW PASS / HIGH PASS FILTERS

%Program for FIR LPF using blackman window

n=20;

fp=200;

fq=300;

fs=1000;

fn=2*fp/fs;

window=blackman(n+1);

b=fir1(n,fn,window);

[H W]=freqz(b,1,128);

subplot(2,1,1);

plot(W/pi,abs(H));

title('magnitude response of lpf');

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

subplot(2,1,2);

plot(W/pi,angle(H));

title('phase response of lpf');

ylabel('angle-------->');

xlabel('normalized frequency------>');

Result:

window =

-0.0000 0.0092 0.0402 0.1014 0.2008 0.3400 0.5098 0.6892 0.8492

0.9602 1.0000 0.9602 0.8492 0.6892 0.5098 0.3400 0.2008 0.1014

0.0402 0.0092 -0.0000

Page 65: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

65

b = 0.0000 -0.0003 -0.0009 0.0027 0.0101

-0.0000 -0.0386 -0.0430 0.0794 0.2906

0.3999 0.2906 0.0794 -0.0430 -0.0386

-0.0000 0.0101 0.0027 -0.0009 -0.0003

0.0000

Page 66: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

66

FIR LOW PASS FILTER DESIGN USING RECTANGLE WINDOW:

%Program for FIR LPF using rectangular window

n=20;

fp=200;

fq=300;

fs=1000;

fn=2*fp/fs;

window=rectwin(n+1);

b=fir1(n,fn,window);

[H W]=freqz(b,1,128);

subplot(2,1,1);

plot(W/pi,abs(H));

title('magnitude response of lpf');

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

subplot(2,1,2);

plot(W/pi,angle(H));

title('phase response of lpf');

ylabel('angle-------->');

xlabel('normalized frequency------>');

RESULT:-

window =

-0.0000 0.0092 0.0402 0.1014 0.2008 0.3400 0.5098 0.6892 0.8492

0.9602 1.0000 0.9602 0.8492 0.6892 0.5098 0.3400 0.2008 0.1014

0.0402 0.0092 -0.0000

b =

0.0000 -0.0003 -0.0009 0.0027 0.0101

-0.0000 -0.0386 -0.0430 0.0794 0.2906

0.3999 0.2906 0.0794 -0.0430 -0.0386

-0.0000 0.0101 0.0027 -0.0009 -0.0003

0.0000

Page 67: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

67

FIR LOW PASS FILTER DESIGN USING TRIANGLE WINDOW:

%program for FIR LPF using triangular window

n=20;

fp=200;

fq=300;

fs=1000;

fn=2*fp/fs;

window=triang(n+1);

b=fir1(n,fn,window);

[H W]=freqz(b,1,128);

subplot(2,1,1);

plot(W/pi,abs(H));

title('magnitude response of lpf');

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

subplot(2,1,2);

plot(W/pi,angle(H));

title('phase response of lpf');

ylabel('angle-------->');

xlabel('normalized frequency------>');

Page 68: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

68

RESULT:-

window =

-0.0000 0.0092 0.0402 0.1014 0.2008 0.3400 0.5098 0.6892 0.8492

0.9602 1.0000 0.9602 0.8492 0.6892 0.5098 0.3400 0.2008 0.1014

0.0402 0.0092 -0.0000

b =

0.0000 -0.0003 -0.0009 0.0027 0.0101

-0.0000 -0.0386 -0.0430 0.0794 0.2906

0.3999 0.2906 0.0794 -0.0430 -0.0386

-0.0000 0.0101 0.0027 -0.0009 -0.0003

0.0000

Page 69: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

69

FIR LOW PASS FILTER DESIGN USING HAMMING WINDOW:

%program for FIR LPF using Hamming window

n=20;

fp=200;

fq=300;

fs=1000;

fn=2*fp/fs;

window=hamming(n+1);

b=fir1(n,fn,window);

[H W]=freqz(b,1,128);

subplot(2,1,1);

plot(W/pi,abs(H));

title('magnitude response of lpf');

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

subplot(2,1,2);

plot(W/pi,angle(H));

title('phase response of lpf');

ylabel('angle-------->');

xlabel('normalized frequency------>');

RESULT:-

window =

-0.0000 0.0092 0.0402 0.1014 0.2008 0.3400 0.5098 0.6892 0.8492

0.9602 1.0000 0.9602 0.8492 0.6892 0.5098 0.3400 0.2008 0.1014

0.0402 0.0092 -0.0000

b =

0.0000 -0.0003 -0.0009 0.0027 0.0101

-0.0000 -0.0386 -0.0430 0.0794 0.2906

0.3999 0.2906 0.0794 -0.0430 -0.0386

Page 70: EXPERIMENT No. 1mist.ac.in/pdfs/LabManuals/ECE/DSPLabManual.pdf · Digital signal processing Lab Manual DEPARTMENT OF ECE 4 VIVA QUESTIONS 1.what is the difference between sin & cos

Digital signal processing Lab Manual

DEPARTMENT OF ECE

70