You are on page 1of 87

1

FLOW CHART:

AIM

EX. NO:
To generate sine wave, square wave and triangular wave. STEP 1: Get the value oft for sine wave. STEP2: Generate the function y (n) =sin (2*pi*t). STEP3: Plot x as the time period and y as amplitude of the wave form.

ALGORITHM 1. SINE WAVE

2. SQUARE WAVE

STEP 1: Get the value oft for square wave. STEP 2: Give the amplitude of the corresponding position. STEP 3: Plot x as the time period and y as amplitude of the wave form.

3. TRINGULAR WAVE

STEP 1: Get the value oft for triangular wave. STEP 2: Give the amplitude of the corresponding position. STEP 3: Plot x as the time period and y as amplitude of the wave form.

OUTPUT Sine wave Enter the length of the input sequence: 12 Enter the No of cycles: 10 Square Wave Sampling Frequency: 500 No. of Samples: 40 Frequency of Square Wave: 50
Sinusoidal Sequence 1 1

0.5 Amplitude.........> Amplitude.........> 0 20 40 60 80 Sample............> Sinusoidal Sequence Square Wav e TriangularSequence: 1 0.5 Amplitude.........> Amplitude.........> Amplitude.........> 100 120

0.5

-0.5

-0.5

-1

-1

10

nce 1

0.5 Amplitude.........> 20
5 -1.5 10 -1

0.5 0.8

0
0 0.6

-0.5 -0.50.4

-0.5

80

100

120

-1 0.2 0 -1 0
0 -2

.>

40 60 80 15 Sample............>25 20 Sample............>
-0.5 0 0.5 Sample............> TriangularSequence:

100
30 1 35 1.5

120 40
2

-1

10

nce:

0.8 Amplitude.........>

0.6

0.4

0.2

0 -2
0.5 1 1.5 2

-1.5

-1

-0.5

0 0.5 Sample............>

1.5

.>

PROGRAM %Sine Wave clc; disp('Sinewave'); N4=input('Enter the length of the input sequence:'); x4=input('Enter the No of cycles:'); n4=0:pi/N4:x4*pi; y4=sin(2*n4); subplot(2,2,1); plot(n4*N4/pi,y4); title('Sinusoidal Sequence'); xlabel('Sample............>'); ylabel('Amplitude.........>'); %Square Wave disp(''); disp('Square Wave'); Fs=input('Sampling Frequency:'); N=input('No.of Samples:'); n=1:N; F=input('Frequency of Square Wave:'); f=F/Fs; x=square(2*pi*f*n); subplot(2,2,2); stem(x); title('Square Wave'); xlabel('Sample............>'); ylabel('Amplitude.........>'); %Triangular Wave t=-2:1:2; y=[zeros(1,1),ones(1,1),zeros(1,1),ones(1,1),zeros(1,1)]; subplot(2,2,3); plot(t,y); xlabel('Sample............>'); ylabel('Amplitude.........>'); title('TriangularSequence:');

RESULT:
Thus the MATLAB program for generating the sine, square and triangular waveforms is executed and the output was verified.

FLOW CHART:

AIM

To generate unit step, unit ramp and unit impulse sequences. ALGORITHM 1. UNIT STEP STEP 1: Start the program. STEP 2: Give length of the sequence. STEP 3: Generate the sequence. STEP 4: Plot the generated sequence. STEP 5: Stop the program. 2. UNIT RAMP

EX. NO: 2

STEP 1: Start the program. STEP 2: Give length of the sequence. STEP 3: Generate the sequence. STEP 4: Plot the generated sequence. STEP 5: Stop the program. 3. UNIT IMPULSE

STEP 1: Start the program. STEP 2: Give length of the sequence. STEP 3: Generate the sequence. STEP 4: Plot the generated sequence. STEP 5: Stop the program.

OUTPUT Unit Step Enter the length of input sequence:5 Y(n)= 1 1 1 1 1 Unit Ramp Enter the length of input sequence:5 Y(n)= 0 1 2 3 4 Unit Impulse Y(n)= 0 0 1

Unit Step 1 Amplitude.........> Amplitude.........> 4 3 2 1 0

Unit Ramp

0.5

1 2 3 Time Index............> Unit Impulse

1 2 3 Time Index............>

1 Amplitude.........>

0.5

0 -2

-1 0 1 Time Index............>

10

PROGRAM %Unit Step Sequence clc; disp('Unit Step'); a=input('Enter the length of input sequence:'); n1=0:1:a-1; y=[ones(1,a)]; subplot(2,2,1); stem(n1,y); title('Unit Step'); xlabel('Time Index............>'); ylabel('Amplitude.........>'); disp('Y(n)='); disp(y); %Unit Ramp Sequence disp('Unit Ramp'); a=input('Enter the length of input sequence:'); n2=0:1:a-1; y=[ones(1,a)]; subplot(2,2,2); stem(n2,n2); title('Unit Ramp'); xlabel('Time Index............>'); ylabel('Amplitude.........>'); disp('Y(n)='); disp(n2); %Unit Impulse Sequence disp('Unit Impulse'); n=-2:1:2; y=[zeros(1,2),ones(1,1),zeros(1,2)]; subplot(2,2,3); stem(n,y); title('Unit Impulse'); xlabel('Time Index............>'); ylabel('Amplitude.........>'); disp('Y(n)='); disp(y);

11

12

RESULT Thus the MATLAB program for generating the unit step, unit ramp and unit impulse signal is executed and the output is verified.

13

FLOW CHART:

14

AIM

To write execute a MATLAB simulation program for generating linear convolution. ALGORITHM STEP 1: Start the program. STEP 2: Get the signals x(n) and h(n) in matrix form. STEP 3: Convolute using the function conv2(x,h). STEP 4: Plot the signals x(n),h(n) and y(n). STEP 5: Stop the program.

EX. NO: 3

15

OUTPUT Input: Enter the first sequence:[1 2 3 4] Enter the Second Sequence:[1 0 1 0 1] OutPut: The resultant signal is 1 2 4 6 4 6 3 4

F irs t S e q u e n c e Magnitude.........> 4 2 0 1 1 .5 2 2 .5 3 S a m p le s .. ... ... ... .> S ec ond S equenc e 3 .5 4

Magnitude.........>

4 2 0 1 1 .5 2 2 .5 3 S a m p le s .. ... ... ... .> A ft e r C o n vo lu tio n 3 .5 4

Magnitude.........>

4 2 0 1 1 .5 2 2 .5 3 S a m p le s .. ... ... ... .> 3 .5 4

16

PROGRAM %Linear Convolution clc; disp('Input:'); x=input('Enter the first sequence:'); h=input('Enter the Second Sequence:'); y=conv2(x,h); display('OutPut:'); figure; subplot(3,1,1); stem(x); xlabel('Samples............>'); ylabel('Magnitude.........>'); title('First Sequence'); subplot(3,1,2); stem(h); xlabel('Samples............>'); ylabel('Magnitude.........>'); title('Second Sequence'); subplot(3,1,3); stem(y); xlabel('Samples............>'); ylabel('Magnitude.........>'); title('After Convolution'); disp('The resultant signal is'); disp(y);

17

18

RESULT:
Thus the MATLAB simulation program for linear convolution of two samples is executed and the output is verified.

19

FLOW CHART

20

AIM

EX. NO:
To write and execute a MATLAB simulation program for generating circular convolution. STEP 1: Start the program. STEP 2: Get the signals x(n) and h(n) in matrix form. STEP 3: Convolute signals x(n) and h(n). STEP 4: Plot the signals x(n),h(n) and y(n). STEP 5: Stop the program.

ALGORITHM

21

OUTPUT: enter the first sequence[1 2 3 4] enter the second sequence[4 3 2 1] the convolved sequence 24 22 24 30

22

PROGRAM clc; clear all; close all; a=input('enter the first sequence'); x=input('enter the second sequence'); c=ifft(fft(a).*fft(x)); disp('the convolved sequence'); disp(c); l1=0:length(a)-1; subplot(1,3,1); stem(l1,a); ylabel('amp'); title('the first squence'); l2=0:length(x)-1; subplot(1,3,2); stem(l2,x); xlabel('time'); ylabel('amp'); title('the second sequence'); l3=0:length(c)-1; subplot(1,3,3); st(l3,c); xlabel('time'); ylabel('amp'); title('circular convolution');

23

24

RESULT:
Thus the MATLAB simulation program for circularconvolution of two samples is executed and the output is verified.

FLOW CHART 25

START

GET THE SIGNALS

GET F

CALCULATE 2F

SAMPLE THE INPUT SIGNAL AT 2FM>FS& FS=2FM & FS>2FM

GET THE CORRESPONDING SAMPLED OUTPUTS

STOP

26

AIM

To write and execute the MATLAB program for generating sampling for the given signals. ALGORITHM STEP 1: Start the program. STEP 2: Get the band of signals to be sampled. STEP3: Determine the highest frequency component. STEP 4: calculate twice the highest frequency component. STEP 6: Obtain the sampled signal output. STEP 7: Stop the program. STEP 5: Sample the input signal at three different rates of 2Fm>Fs2Fm.

EX. NO: 5

27

OUTPUT

28

PROGRAM: clc; clear all; t=-10:0.01:10; T=4; fm=1/T; x=cos(2*pi*fm*t); fs1=1.6*fm; fs2=2*fm; fs3=8*fm; n1=-4:1:4; xn1=cos(2*pi*n1*fm/fs1); subplot(2,2,1); plot(t,x); xlabel('time in sec'); ylabel('x(t)'); title('continious time signal'); subplot(2,2,2); stem(n1,xn1,'-r'); hold on plot(n1,xn1); xlabel('time in sec'); ylabel('x(t)'); title('Discrete time signal with fs<2fm'); n2=-5:1:5; xn2=cos(2*pi*n2*fm/fs2); subplot(2,2,3); stem(n2,xn2,'*g'); hold on plot(n2,xn2,'-r');

29

30

xlabel('n'); ylabel('x(n)'); title('Discrete time signal with fs=2fm'); n3=-20:1:20; xn3=cos(2*pi*n3*fm/fs3); subplot(2,2,4); stem(n3,xn3,'-r'); hold on plot(n3,xn3); xlabel('n'); ylabel('x(n)'); title('Discrete time signal with fs>2fm');

31

32

RESULT:
Thus the MATLAB program for generating samples of the given signal is written, executed and the output is verified.

33

FLOW CHART

34

AIM FFT. ALGORITHM

EX. NO:
To write and execute the MATLAB simulation program to find DFT of given sequence using STEP 1: Start the program. STEP 3: Display real and imaginary values. STEP 5: Plot the graph using grid values. STEP 6: Stop the program. STEP 2: Enter the value of n and the length of FFT. STEP 4: Display the magnitude and the phase angle.

35

OUTPUT Enter the Sequence:[2 4 6 8] Enter the Length of FFT:5 The FFT of the Given Sequence The Real Value of FFT is 20.0000 -8.0902 3.0902 3.0902 -8.0902 The Imaginary Value of FFT is 0 -2.6287 -4.2533 4.2533 The Magnitude of FFT is 20.0000 8.5065 5.2573 The Phase of FFT is 0 -2.8274 -0.9425
20 Amplitude... Amplitude...

2.6287 8.5065

5.2573

0.9425
Real

2.8274
Imaginary 5

10

-10

3 4 Sample... Magnitude plot

-5

3 4 Sample... Phase Angle Plot

20 Amplitude... 1 2 3 Sample... 4 5 Amplitude... 15 10 5 0

4 2 0 -2 -4

3 Sample...

36

PROGRAM % DFT USING FFT clc; x=input('Enter the Sequence:'); n=input('Enter the Length of FFT:'); y=fft(x,n); disp('The FFT of the Given Sequence'); disp(y); disp('The Real Value of FFT is'); disp(real(y)); disp('The Imaginary Value of FFT is'); disp(imag(y)); disp('The Magnitude of FFT is'); disp(abs(y)); disp('The Phase of FFT is'); disp(angle(y)); figure; subplot(2,2,1); stem(real(y)); title('Real'); xlabel('Sample...'); ylabel('Amplitude...'); subplot(2,2,2); stem(imag(y)); title('Imaginary'); xlabel('Sample...'); ylabel('Amplitude...'); subplot(2,2,3); stem(abs(y)); title('Magnitude plot'); xlabel('Sample...'); ylabel('Amplitude...'); subplot(2,2,4); stem(angle(y)); title('Phase Angle Plot'); xlabel('Sample...'); ylabel('Amplitude...'); clear;

37

38

RESULT:
Thus the MATLAB program for finding DFT using FFT algorithm is written, executed and the output is verified.

39

FLOW CHART

40

AIM

To write and execute the MATLAB simulation program to convert an analog filter to digital filter by bilinear transformation method (BLT). ALGORITHM BILINEAR TRANSFORMATION METHOD STEP 1: Start the program.

EX. NO: 7

STEP 2: Enter the values of the analog filter transfer function. STEP 3: Compute the equivalent digital filter co-efficient by using the bilinear transform. STEP 4: Display the digital filter co-efficient. STEP 5: Stop the program.

41

OUTPUT
Enter the Analog Numerator: 8 Enter the Analog Denominator: [6 4] Numerator Coefficients 0.5000 0.5000

Denominator Coefficients 1.0000 -0.5000

42

PROGRAM clc; clear all; b=input('Enter the Analog Numerator:'); a=input('Enter the Analog Denominator:'); fs=1; [bz,az]=bilinear(b,a,fs); disp('Numerator Coefficients'); disp(bz); disp('Denominator Coefficients'); disp(az);

43

44

RESULT:
Thus the MATLAB simulation program to convert an analog filter to a digital filter using bilinear transformation method is done and the output is verified.

45

FLOWCHART

46

AIM

To write and execute a MATLAB program to design a Butterworth. a) Low pass filter b) High pass filter c) Band pass filter d) Band stop filter ALGORITHM STEP 1: Start the program. frequency. STEP 3: Calculate the order of the filter. STEP 4: Compute the frequency response and plot the graph. STEP 5: Stop the program,

EX. NO: 8

STEP 2: Get the values of pass band ripple, pass and stop band frequency and sampling

47

OUTPUT 1. BUTTERWORTH LOW PASS FILTER Enter the Passband Ripple:5 Enter the Stopband Ripple:10 Enter the Passband Frequency:1000 Enter the StopbandFrequency :2000 Enter the Sampling Frequency:8000 Output Order of Sequence n= 2 3db Cutoff Frequency wn n= 2 m= 0 -21.6137 -33.6267 -40.6688 an = 0 -2.7226 -2.9361 -3.0051
Magnitude Plot 0

Gain in db

-20

-40

-60

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency Phase Angle Plot

0.7

0.8

0.9

0 Phase in Radians -1 -2 -3 -4

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency

0.7

0.8

0.9

48

PROGRAM 1. BUTTERWORTH LOW PASS FILTER clc; disp('Input'); rp=input('Enter the Passband Ripple:'); rs=input('Enter the Stopband Ripple:'); wp=input('Enter the Passband Frequency:'); ws=input('Enter the Stopband Frequency :'); fs=input('Enter the Sampling Frequency:'); w1=2*(wp/fs); w2=2*(ws/fs); disp('Output'); disp('Order of Sequence'); [n,wn]=buttord(w1,w2,rp,rs,'s');n disp('3db Cutoff Frequency'); disp('wn'); [b,a]=butter(n,wn,'low','s');n w=0:1:pi; [b,om]=freqs(b,a,w); m=20*log10(abs(b));m an=angle(b);an figure(1) subplot(2,1,1); plot(om/pi,m); xlabel('Normalised Frequency'); ylabel('Gain in db'); title('Magnitude Plot'); subplot(2,1,2); plot(om/pi,an); xlabel('Normalised Frequency'); ylabel('Phase in Radians'); title('Phase Angle Plot');

49

OUTPUT 2. BUTTERWORTH HIGH PASS FILTER Input Enter the passband ripple:5 Enter the stopband ripple:10 Enter the passband frequency:1000 Enter the stopband frequency:2000 Enter the sampling frequency:10000 Output Order of Sequence n= 2 3db Cutoff Frequency 0.2309 n= 2 n= 2 m= -Inf -0.0123 -0.0008 -0.0002 an = 0 0.3322 0.1640 0.1091
Magnitude Plot 0

Gain in dB

-0.005

-0.01

-0.015

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency Phase Angle Plot

0.7

0.8

0.9

0.4 Phase in Radians 0.3 0.2 0.1 0

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency

0.7

0.8

0.9

50

PROGRAM 2. BUTTERWORTH HIGH PASS FILTER clc; disp('Input'); rp=input('Enter the passband ripple:'); rs=input('Enter the stopband ripple:'); wp=input('Enter the passband frequency:'); ws=input('Enter the stopband frequency:'); fs=input('Enter the sampling frequency:'); w1=2*(wp/fs); w2=2*(ws/fs); disp('Output'); disp('Order of Sequence'); [n,wn]=buttord(w1,w2,rp,rs,'s');n disp('3db Cutoff Frequency'); disp(wn); disp('n='); disp(n); [b,a]=butter(n,wn,'high','s');n w=0:1:pi; [b,om]=freqs(b,a,w); m=20*log10(abs(b));m an=angle(b);an figure(2) subplot(2,1,1); plot(om/pi,m); xlabel('Normalised Frequency'); ylabel('Gain in dB'); title('Magnitude Plot'); subplot(2,1,2); plot(om/pi,an); xlabel('Normalised Frequency'); ylabel('Phase in Radians'); title('Phase Angle Plot');

51

OUTPUT 3. BUTTERWORTH BAND PASS FILTER Input Enter the Passband Ripple:5 Enter the Stopband Ripple:50 Enter the Passband Frequency:1000 Enter the Stopband Frequency:1500 Enter the Sampling Frequency:5000 Output Order of Sequence 0.3977
Magnitude Plot -150

Gain in dB

-200

-250

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency Phase Plot

0.7

0.8

0.9

4 Phase in Radians 2 0 -2 -4

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency

0.7

0.8

0.9

52

PROGRAM 3. BUTTER WORTH BAND PASS FILTER clc; disp('Input'); rp=input('Enter the Passband Ripple:'); rs=input('Enter the Stopband Ripple:'); wp=input('Enter the Passband Frequency:'); ws=input('Enter the Stopband Frequency:'); fs=input('Enter the Sampling Frequency:'); w1=2*(wp/fs); w2=2*(ws/fs); disp('Output'); disp('Order of Sequence'); [n,wn]=buttord(w1,w2,rp,rs,'s'); disp(wn); wn=[w1 w2]; [b,a]=butter(n,wn,'bandpass','s'); w=0:0.01:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h)); an=angle(h); figure(3) subplot(2,1,1); plot(om/pi,m); xlabel('Normalised Frequency'); ylabel('Gain in dB'); title('Magnitude Plot'); subplot(2,1,2); plot(om/pi,an); xlabel('Normalised Frequency'); ylabel('Phase in Radians'); title('Phase Plot');

53

OUTPUT 4. BUTTERWORTH STOP BAND FILTER Input Enter the Passband Ripple:1 Enter the Stopband Ripple:10 Enter the Passband Frequency:1000 Enter the Stopband Frequency:6000 Enter the Sampling Frequency:5000 Output Order of Sequence 0.8000
Magnitude Plot 40 20 Gain in dB 0 -20 -40

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency Phase Plot

0.7

0.8

0.9

4 Phase in Radians 3 2 1 0

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency

0.7

0.8

0.9

54

PROGRAM 4. BUTTERWORTH BAND STOP FILTER clc; disp('Input'); rp=input('Enter the Passband Ripple:'); rs=input('Enter the Stopband Ripple:'); wp=input('Enter the Passband Frequency:'); ws=input('Enter the Stopband Frequency:'); fs=input('Enter the Sampling Frequency:'); w1=2*(wp/fs); w2=2*(ws/fs); disp('Output'); disp('Order of Sequence'); [n,wn]=buttord(w1,w2,rp,rs,'s'); disp(wn); wn=[w1 w2]; [b,a]=butter(n,wn,'stop','s'); w=0:0.01:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h)); an=angle(h); figure(3) subplot(2,1,1); plot(om/pi,m); xlabel('Normalised Frequency'); ylabel('Gain in dB'); title('Magnitude Plot'); subplot(2,1,2); plot(om/pi,an); xlabel('Normalised Frequency'); ylabel('Phase in Radians'); title('Phase Plot');

55

56

RESULT:
Thus the MATLAB programs for designing Butterworth filter are executed and the output was verified.

57

FLOW CHART

58

AIM:

To write and execute a MATLAB program to design a chebychev filters 1) Low pass filter 2) High pass filter 3) Band pass filter 4) Band stop filter

EX. NO: 9

ALGOTITHM: Step1: start the program. Step3: Calculate the order of the filter. Step5: Stop the program.

Step2: Get the values of pass band, stop band, band ripple and sampling frequency. Step4: Compute the frequency response and plot the graph.

59

OUTPUT 1. CHEBYCHEV LOW PASS FILTER Input Enter the Passband Ripple:0.003 Enter the Stopband Ripple:30 Enter the Passband Frequency:1000 Enter the Stopband Frequency:4000 Enter the Sampling Frequency:12000 Output Order of Sequence n= 4 3db Cutoff Frequency 0.1667
Magnitude Plot 0

Gain in dB

-100

-200

-300

0.1

0.2

0.3

0.4 0.5 0.6 Normalized Frequency Phase Plot

0.7

0.8

0.9

4 Phase in Radians 2 0 -2 -4

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency

0.7

0.8

0.9

60

PROGRAM

1. CHEBYCHEV LOW PASS FILTER

clc; disp('Input'); rp=input('Enter the Passband Ripple:'); rs=input('Enter the Stopband Ripple:'); wp=input('Enter the Passband Frequency:'); ws=input('Enter the Stopband Frequency:'); fs=input('Enter the Sampling Frequency:'); w1=2*(wp/fs); w2=2*(ws/fs); disp('Output'); disp('Order of Sequence'); [n,wn]=cheb1ord(w1,w2,rp,rs,'s');n disp('3db Cutoff Frequency'); disp(wn); [b,a]=cheby1(n,rp,wn,'low');n w=0:0.01:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h));m an=angle(h);an figure(1); subplot(2,1,1); plot(om/pi,m); xlabel('Normalized Frequency'); ylabel('Gain in dB'); title('Magnitude Plot'); subplot(2,1,2); plot(om/pi,an); xlabel('Normalised Frequency'); ylabel('Phase in Radians'); title('Phase Plot');

61

OUTPUT 2. CHEBYCHEV HIGH PASS FILTER Input Enter the Passband Ripple:0.05 Enter the Stopband Ripple:50 Enter the Passband Frequency:1000 Enter the Stopband Frequency:6000 Enter the Sampling Frequency:10000 Output Order of Sequence n= 4 3db Cutoff Frequency 0.2000
Magnitude Plot 0

Gain in dB

-50

-100

-150

0.1

0.2

0.3

0.4 0.5 0.6 Normalized Frequency Phase Plot

0.7

0.8

0.9

4 Phase in Radians 2 0 -2 -4

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency

0.7

0.8

0.9

62

PROGRAM 2. CHEBYCHEV HIGH PASS FILTER

clc; disp('Input'); rp=input('Enter the Passband Ripple:'); rs=input('Enter the Stopband Ripple:'); wp=input('Enter the Passband Frequency:'); ws=input('Enter the Stopband Frequency:'); fs=input('Enter the Sampling Frequency:'); w1=2*(wp/fs); w2=2*(ws/fs); disp('Output'); disp('Order of Sequence'); [n,wn]=cheb1ord(w1,w2,rp,rs,'s');n disp('3db Cutoff Frequency'); disp(wn); [b,a]=cheby1(n,rp,wn,'high');n w=0:0.01:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h));m an=angle(h);an figure(2); subplot(2,1,1); plot(om/pi,m); xlabel('Normalized Frequency'); ylabel('Gain in dB'); title('Magnitude Plot'); subplot(2,1,2); plot(om/pi,an); xlabel('Normalised Frequency'); ylabel('Phase in Radians'); title('Phase Plot');

63

OUTPUT 3. CHEBYCHEV BAND PASS FILTER


Input Enter the Passband Ripple:0.05 Enter the Stopband Ripple:50 Enter the Passband Frequency:1000 Enter the Stopband Frequency:4000 Enter the Sampling Frequency:15000 Output Order of Sequence n= 5 3db Cutoff Frequency 0.1333 0.5333
Magnitude Plot 0 -100 Gain in dB -200 -300 -400

0.1

0.2

0.3

0.4 0.5 0.6 Normalized Frequency Phase Plot

0.7

0.8

0.9

4 Phase in Radians 2 0 -2 -4

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency

0.7

0.8

0.9

64

PROGRAM 3. CHEBYCHEV BAND PASS FILTER


clc; disp('Input'); rp=input('Enter the Passband Ripple:'); rs=input('Enter the Stopband Ripple:'); wp=input('Enter the Passband Frequency:'); ws=input('Enter the Stopband Frequency:'); fs=input('Enter the Sampling Frequency:'); w1=2*(wp/fs); w2=2*(ws/fs); disp('Output'); disp('Order of Sequence'); [n,wn]=cheb1ord(w1,w2,rp,rs,'s');n wn=[w1 w2]; disp('3db Cutoff Frequency'); disp(wn); [b,a]=cheby1(n,rp,wn,'bandpass');n w=0:0.01:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h));m an=angle(h);an figure(3); subplot(2,1,1); plot(om/pi,m); xlabel('Normalized Frequency'); ylabel('Gain in dB'); title('Magnitude Plot'); subplot(2,1,2); plot(om/pi,an); xlabel('Normalised Frequency'); ylabel('Phase in Radians'); title('Phase Plot');

65

OUTPUT 4. CHEBYCHEV BAND STOP FILTER Input Enter the Passband Ripple:0.05 Enter the Stopband Ripple:55 Enter the Passband Frequency:1000 Enter the Stopband Frequency:3200 Enter the Sampling Frequency:9000 Output Order of Sequence n= 6 3db Cutoff Frequency 0.2222 0.7111
Magnitude Plot 0

Gain in dB

-100

-200

-300

0.1

0.2

0.3

0.4 0.5 0.6 Normalized Frequency Phase Plot

0.7

0.8

0.9

4 Phase in Radians 2 0 -2 -4

0.1

0.2

0.3

0.4 0.5 0.6 Normalised Frequency

0.7

0.8

0.9

66

PROGRAM 4. CHEBYCHEV BAND STOP FILTER


clc; disp('Input'); rp=input('Enter the Passband Ripple:'); rs=input('Enter the Stopband Ripple:'); wp=input('Enter the Passband Frequency:'); ws=input('Enter the Stopband Frequency:'); fs=input('Enter the Sampling Frequency:'); w1=2*(wp/fs); w2=2*(ws/fs); disp('Output'); disp('Order of Sequence'); [n,wn]=cheb1ord(w1,w2,rp,rs,'s');n wn=[w1 w2]; disp('3db Cutoff Frequency'); disp(wn); wn=[w1 w2]; [b,a]=cheby1(n,rp,wn,'stop');n w=0:0.01:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h));m an=angle(h);an figure(4); subplot(2,1,1); plot(om/pi,m); xlabel('Normalized Frequency'); ylabel('Gain in dB'); title('Magnitude Plot'); subplot(2,1,2); plot(om/pi,an); xlabel('Normalised Frequency'); ylabel('Phase in Radians'); title('Phase Plot');

67

68

RESULT:
Thus the MATLAB program for designing a chebychev filter was written, executed and the output is verified.

69

FLOW CHART

70

AIM:

To wrote and execute the MATLAB simulation program for the following windowing techniques: i) Blackman technique ii) Hamming technique iii) Hanning technique. ALGORITHM: BACKMANN WINDOW Step1: Start the program Step2: Get the number of points (N). Step4: window the output. Step5: stop the program. HAMMING WINDOW Step1: Start the program Step2: Get the number of function points (N) and calculate the alpha values. Step3: Using the function hamming (N) design the window for frequency (0:0.01: pi). Step4: window the output. Step5: stop the program. HANNING WINDOW Step1: Start the program Step2: get the number of function points (N) and calculate the alpha value. Step3: Using the function Hanning (N) design the window for frequency (0:0.01: pi). Step4: window the output. Step5: stop the program.

EX. NO: 10

Step3: Using the function backmann (N) design the window for frequency (0:0.01: pi).

71

OUTPUT

B la c k m a n W in d o w 4 3 M a g n itu d e 2 1 0

0 .2

0 .4 0 .6 0 .8 N o r m a lis e d fr e q . . . H a m m in g W in d o w

1 5

1 0 M a g n itu d e

0 .2

0 .4 0 .6 0 .8 N o r m a lis e d fr e q . . . H a n n in g W in d o w

2 5 2 0 1 5 M a g n itu d e 1 0 5
72

PROGRAM
%Blackman Window clc; wi=3*pi; N=25; alpha=(N-1)/2; cps=0.001; n=0:1:N-1; hd=sin(wi*(n-alpha-cps)/(pi*(n-alpha))); wr=boxcar(N); hn=hd*wr; w=0:0.01:pi; h=freqz(hn,1,w); figure(01); subplot(3,1,1) plot(w/pi,abs(h)); hold on title('Blackman Window'); xlabel('Normalised freq...'); ylabel('Magnitude'); hold off; %Hamming Window wi=0.5*pi; N=25; alpha=(N-1)/2; cps=0.001; n=0:1:N-1; hd=sin(wi*(n-alpha-cps)/(pi*(n-alpha+cps))); wr=boxcar(N); hn=hd*wr; w=0:0.01:pi; h=freqz(hn,1,w); figure(01); subplot(3,1,2); plot(w/pi,abs(h)); hold on title('Hamming Window'); xlabel('Normalised freq...'); ylabel('Magnitude'); hold off;

73

M agnit

0 .2

0 .4 0 .6 0 .8 N o r m a lis e d fr e q . . . H a n n in g W in d o w

2 5 2 0 1 5 M agnitude 1 0 5 0

0 .2

0 .4 0 .6 0 .8 N o r m a lis e d fr e q . . .

74

%Hanning Window clc; wi=5*pi; N=25; alpha=(N-1)/2; cps=0.001; n=0:1:N-1; hd=sin(wi*(n-alpha-cps)/(pi*(n-alpha+cps))); wr=boxcar(N); hn=hd*wr; w=0:0.01:pi; h=freqz(hn,1,w); figure(01); subplot(3,1,3); plot(w/pi,abs(h)); hold on title('Hanning Window'); xlabel('Normalised freq...'); ylabel('Magnitude'); hold off;

75

76

RESULT:
Thus the program for the different windowing technique is written, executed and verified.

77

BLOCK DIAGRAM

78

DSP CHIP TMS320C50

The TMS320C50 is a 16-bit fixed point digital signal processor that combines the flexibility of a high speed controller with the numerical capability of an array processor, thereby offering an inexpensive alternative and to multichip bit-slice processor. The highly paralled architecture and efficient instruction set provide speed and flexibility capable of executing 10 MIPS. The TMS320C50 optimizes speed by implementing function in hardware that other processor implement through microcode or software. This hardware-intensive approach provides the design engineer power with processing power previously unavailable on a single chip. The TMS320C50 is the third generation digital signal processor in the TMS320C50 family. Its powerful instruction set, inherit flexibility, high speed number crunching capabilities and innovative architecture have made this high performance, cost effective processor the ideal solution to many telecommunication, computer, commercial, industrial and military applications. KEY FEATURES OF TMS320C50 The key features of digital signal processor TMS320C50 are: 35-/-50-NS single-cycle fixed-point instruction execution time(28.6/20 MIPS) Upward source-code compatible with all C1X and C2X devices. RAM-based memory operation (C50). 9K x 16-bit single-cycle on-chip program/data RAM (C50). 2K x 16-bit single-cycle on-chip boot ROM (C50). 1056 x 16-bit dual access on-chip data RAM. 224K x 16-bit maximum addressable external memory space (64K program, 64K data, 64K I/O and 32K global). 32-bit arithmetic logic unit (ALU), 32-bit accumulator (ACC) and 32-bit accumulator buffer (ACCB). 16-bit parallel logic unit (PLU). 16 x 16-bit parallel multiplier with a 32-bit product capability. =single=cycle multiply/accumulate instructions. 8 auxiliary registers with a dedicated auxiliary register arithmetic unit for indirect addressing. 11 context- switch register (shadow register) for storing strategic CPU controlled registers during an interrupt service routine,

EX. NO: 11

79

8-level hardware stack 0-to 16- bit left and right data barrel shifters and a 64-bit incremental data shifter. Two indirectly addressing circular buffer for circular addressing. Single instruction repeat and block repeat operations for program code. Block memory move instruction for better program/data management.

80

Pin Diagram:

81

Full duplex synchronous serial port for direct communication between C5Xand other serial device. Time division multiple access (TDMA) serial port Interval timer with period, control and counter registers for software stop, start and reset. 64k parallel II/O port, 16 of which are memory mapped. 16software programmable wait state generator for program, data and I/O memory spaces.

ARCITECTURE The TMS320CS0 is utilizes a modified Harvard architecture for speed and flexibility. In a strict Harvard architecture, program and data memory are in two separate spaces, permitting a full overlap of instruction fetch and execution. The TMS320 familys modification of the Harvard architecture allows transfer between program and data spaces thereby increasing flexibility of the device. This modification permits coefficients stored program memory to be read into the data RAM, eliminating instructions subroutines based on computer values. 32-bit ACCUMULATOR The TMS320C50 contains a 32-bit ALU and accumulator for support of double precision twos complement arithmetic unit that operates on 16-bit words taken from the data RAM or derived from immediate instruction. In addition to the usual arithmetic instructions ALU can performs Boolean operations, providing the manipulation ability required of a high speed controller. The accumulator stores the output from ALU. It is the 32-bit long. The accumulator id divided into high order word (bits31-16) and low order (bits IS-a). Instructions are provided for storing and loading the high and lower order accumulator words to memory. 16 x 16-BIT PARALLEL MULTIPLIER The multiplier performs a 16x16-bit 2s complement multiplication with a 32-bit resulting in a single instruction cycle. The multiplier consists of three units: T-registers, P-registers and multiplier array. The 16-bit T-register temporarily stores the multiplicand and the P-register stores the 32-bit product. Multiplier values either come from the data memory or are derived from the MPY (multiply immediate) instruction word. The fast on-chip multiplier allows the device to perform fundamental operations such as convolution, correlation and filtering. Two multiply/accumulate instructions in the instruction set fully utilizes the computational bandwidth of the multiplier, allowing both operands to be processed simultaneously. SHIFTERS

82

A 16-bit scaling shiner is available at the accumulator input; this shifter produces a left shift of 0-16-bit on the input data to accumulator. TMS320C50also contains a shifter at the accumulator output. This shifter provides a left shift of 0to 7, on the data from either the ACCH or ACCL register.

83

In addition one shifter at the output of P-register can shift the product by 1 or 4-bits left or 6-bits right, before transferring the product to accumulator. DATA AND PROGRAM MEMORY Since the TMS320C50 uses Harvard architecture, data and program memory reside in two separate spaces. Additionally TMS320C50 has one more memory space called I/O memory space. The total memory capacity of TMS320C50 is 64kw each of program, data and I/O memory. The total memory is divided into 512 pages with each page containing 128words. Only one page can be active at one time. One data page selection is done by setting data page pointer. TMS320C50 has 1056 words of dual access on chip data memory is divided as three blocks B0, B1&B2 of which B0 can be configured as program or data RAM. Out of the 64kw of the total program memory, TMS320C50 has 2k words of on chip program ROM. The TMS320C50 offers two modes of operation defined by the state of the MC/MP pin: the microprocessor mode (MC/MP=1) or the microcontroller mode (MC/MP=0). In the microprocessor mode, on chip ROM is mapped into the memory into the memory space with up to 2k words of memory are external. INTERRUPTS AND SUBROUTINES The TMS320C50 has three external maskable user interrupts available for external devices that interrupt the processor. The TMS320C50 contains an eight level hardware stack for saving the contents of the program counter during the interrupts and subroutine calls. Instructions are available for saving the devices complete context. PUSH and POP instruction permit a level of nesting restricted only by Te amount of available RAM. SERIAL PORT A full-duplex on chip serial port communication with serial devices such as codecs, serial AID converters and other serial systems. The interface signals are compatible with codecs and many other serial devices with a minimum of external hardware. INPUT AND OUTPUT The 16-bit parallel data bus can be utilized to perform 1/0 function in two cycles. The 1/0 ports are addressed by the four LSBs on the address lines, allowing 16 input and 16 output ports. In addition, a pooling input for bit test and jump operations (BIO) and three interrupt pins (INT0-INT2) have been incorporated for multitasking.

84

85

RESULT: Thus the architecture of TMS320C50 is studied.

86

87

You might also like