Académique Documents
Professionnel Documents
Culture Documents
AIM:
I. To generate the following signals a) Unit Impulse signal b) Unit Step Signal c)
Ramp signal d) Exponential signal e) Sinusoidal signal f) Cosine signal g) Square signal
h) Triangular signal.
II. To generate the following probability distribution functions a) Uniform
distribution b) Normal distribution c) Rayleigh distribution d) Random distribution
THEORY:
1. Real Exponential
x ( t )= A e at , a R
u ( t ) =1,t >0
0, t<0
undefined at t=0
( t )= , t=0
0, t 0
( t ) dt=1
r ( t ) =t , t> 0
0, t<0
1
PROGRAM:
2
subplot(4,2,4)
stem(x,y)
xlabel('time')
ylabel('amplitude')
title('exponential signal')
% Generate sinusoidal signal
x=[-pi:0.01:pi]
y=sin(x)
subplot(4,2,5)
plot(x,y)
xlabel('time')
ylabel('amplitude')
title('sinusoidal signal')
3
% Generate triangular signal
n1= input('Enter the value of n1')
s=[-(n+2):(n+2)]
z=1-(abs(s)/(n+2))
subplot(4,2,8)
stem(s,z)
xlabel('time')
ylabel('amplitude')
title('triangular signal')
% uniform distriburion
pdfuniform=rand(1,10000)
figure(2)
subplot(2,2,1)
hist(pdfuniform)
title('uniform disrtibution,histogram')
4
title('Rayleigh distribution')
% Random distriburion
b= input('Enter the value of b=')
a= input('Enter the value of a=')
r = a + (b-a).*rand(100,1);
figure(2)
subplot(2,2,4)
plot(r,'g')
title('random distribution')
RESULT: Generated and plotted the basic signals and the probability density functions.
5
EXPERIMENT NO: 2
DATE:
LINEAR CONVOLUTION
AIM: To generate linear convolution of two sequences using inbuilt function and without
using inbuilt function in Matlab
THEORY:
Convolution is an integral concatenation of two signals. It has many applications in
numerous area of signal processing.The most popular application is the determination of
the output signal of a linear time-invariant system by convolving the input signal with the
impulse response of the system.
Linear Convolution
The linear convolution of two continuous time signals x(n) & h(n) is defined by
Graphical Interpretation:
Reflection of h(k) resulting in h(-k)
Shifting of h(-k) resulting in h(n-k)
Element wise multiplication of the sequences x(k) and h(n-k)
Summation of the product sequence x(k)h(n-k) resulting in the convolution value
for y(n)
PROGRAM:
6
h=conv(x,y)
subplot(3,1,1)
stem(x,'r')
title('first sequence')
subplot(3,1,2)
stem(y,'g')
title('second sequence')
subplot(3,1,3)
stem(h,'m')
title('convolved sequence')
7
xlabel('N')
end
end
RESULT: Linear convolution using inbuilt and without using inbuilt function were
EXPERIMENT NO: 3
implemented.
DATE:
CIRCULAR CONVOLUTION
AIM: To generate circular convolution of two sequences using inbuilt function and
without using inbuilt function in Matlab
THEORY:
Convolution is an integral concatenation of two signals. It has many applications in
numerous area of signal processing. The most popular application is the determination of
the output signal of a linear time-invariant system by convolving the input signal with the
impulse response of the system.
Circular convolution of two finite duration sequences of same length N is given by
PROGRAM:
% Using inbuilt function
x=input('Enter the first sequence=')
y=input('Enter the second sequence=')
p=length(x)
q=length(y)
n=max(p,q)
8
h=cconv(x,y,n)
figure(1)
subplot(3,1,1)
stem(x,'r')
title('first sequence')
figure(1)
subplot(3,1,2)
stem(y,'g')
title('second sequence')
figure(1)
subplot(3,1,3)
stem(h,'m')
title('convolved sequence')
9
for i=0:N-1
j=mod(n-i,N)
y(n+1)=y(n+1) + x(i+1)*h(j+1)
end
end
disp(y)
figure(2)
subplot(3,1,3)
stem(y)
title('Output Sequence')
ylabel('y(n)')
xlabel('N')
RESULT: Circular convolution of two sequences were executed in Matlab with and
without using inbuilt function.
10
EXPERIMENT NO: 4
DATE:
AIM: To generate circular convolution of two sequences using inbuilt function and
without using inbuilt function in Matlab
THEORY:
Convolution is an integral concatenation of two signals. It has many applications in
numerous area of signal processing. The most popular application is the determination of
the output signal of a linear time-invariant system by convolving the input signal with the
impulse response of the system.
To compute linear convolution of two sequences x(n) and h(n) of lengths N1,N2
respectively the following procedure is used.
Increase the length of x(n) and h(n) to (N1+N2-1) by padding (N2-1) zeros to x(n)
and (N1-1) zeros to h(n)
Find (N1+N2-1) point circular convolution of padded sequences which is
identical to linear convolution of x(n) & h(n).
PROGRAM:
x=input('Enter the first sequence')
h=input('Enter the second sequence')
N=length(x)+length(h)-1
if size(x,2)>1
x=x'
end
if size(h,2)>1
h=h'
end
11
if N>length(x)
x=[x;zeros(N-length(x),1)]
end
if N>length(h)
h=[h;zeros(N-length(h),1)]
end
y=x*h'
y1=fliplr(y)
disp('output sequence')
c=zeros(1,N)
c(N)=sum(diag(y1,0))
for x1=1:N
c(x1)=sum(diag(y1,N-x1))+sum(diag(y1,-x1))
disp(c(x1))
end
subplot(3,1,1)
stem(x)
title('first sequence')
ylabel('X[n]')
xlabel('n')
subplot(3,1,2)
stem(h)
title('second sequence')
ylabel('h[n]')
xlabel('n')
n=0:1:N-1
subplot(3,1,3)
stem(n,c)
title('convolved sequence')
ylabel('c[x]')
xlabel('n')
12
EXPERIMENT NO: 5
DATE:
AIM: To generate DFT of a given sequence using inbuilt function and without using
inbuilt function in Matlab.
THEORY:
The spectrum of an aperiodic discrete time signal is continuous and periodic with
period 2, which can be computed using Discrete Time Fourier Transform. The frequency
analysis of Discrete time signals are usually performed on a DSP processor which can be
either a general purpose computer or specially designed digital hardware. Since DTFT is
continuous, it is not a convenient frequency domain representation for processing by a
DSP processor. Therefore the DFT is sampled at N discrete frequencies say
the DTFS of its periodic extension. The N point DFT of an N-point sequence is given by
N1
X ( K )= x (n) e
jk 2 n / N
k =0 ,1 , 2 , . N 1
n=0
PROGRAM:
% Using inbuilt function
clc;
clear all;
close all;
x=input('ENTER THE INPUT SEQUENCE');
N=input ('ENTER THE LENGTH OF DFT');
n=length(x);
13
X=fft(x,N);
t=[0:1:n-1]
figure(1)
subplot(221);
stem(t,x);
xlabel('TIME');
ylabel('AMPLITUDE');
title('ORIGINAL INPUT SEQUENCE');
K=[0:1:N-1]
figure(1)
subplot(222);
stem(K,X);
xlabel('FREQUENCY');
ylabel('AMPLITUDE');
title('DFT RESPONSE');
figure(1)
subplot(223);
stem(K,abs(X));
xlabel('FREQUENCY');
ylabel('MAGNITUDE');
title('MAGNITUDE RESPONSE');
figure(1)
subplot(224);
stem(K,angle(X));
xlabel('FREQUENCY');
ylabel('PHASE');
title('PHASE RESPONSE');
14
mag=abs(y)
ang=angle(y)
subplot(221);
stem(k,x);
xlabel('TIME');
ylabel('AMPLITUDE');
title('ORIGINAL INPUT SEQUENCE');
figure(2)
subplot(222);
stem(k,y);
xlabel('FREQUENCY');
ylabel('AMPLITUDE');
title('DFT RESPONSE');
figure(2)
subplot(223);
stem(k,mag);
xlabel('FREQUENCY');
ylabel('MAGNITUDE');
title('MAGNITUDE RESPONSE');
figure(2)
subplot(224);
stem(k,ang);
xlabel('FREQUENCY');
ylabel('PHASE');
title('PHASE RESPONSE');
15
nk=n'*k
W=w.^nk
X=rect*W
figure(3)
subplot(2,2,1)
stem(k,abs(X))
title('Magnitude plot')
xlabel('Discrete Frequency')
ylabel('Amplitude')
figure(3)
subplot(2,2,2)
stem(k,angle(X))
title('Phase plot')
xlabel('Discrete Frequency')
ylabel('Phase Angle')
% unfolding spectrum
y=X(floor(N/2)+1:N)
Y=[y X(1:floor(N/2))]
figure(3)
subplot(2,2,3)
stem(k,abs(Y))
title('Magnitude plot of unfolded spectrum')
xlabel('Discrete Frequency')
ylabel('Amplitude')
figure(3)
subplot(2,2,4)
stem(k,angle(Y))
title('Phase plot of unfolded spectrum')
xlabel('Discrete Frequency')
ylabel('Phase Angle')
RESULT: DFT implementation of the sequence was carried using inbuilt function and
without using inbuilt function in Matlab and also unfolding of the spectrum was
implemented.
16
EXPERIMENT NO: 6
DATE:
AIM: To generate IDFT of a given sequence using inbuilt function and without using
inbuilt function in Matlab.
THEORY:
The spectrum of an aperiodic discrete time signal is continuous and periodic with
period 2,which can be computed using Discrete Time Fourier Transform.The frequency
analysis of Discrete time signals are usually performed on a DSP processor which can be
either a general purpose computer or specially designed digital hardware.Since DTFT is
continuous ,it is not a convenient frequency domain representation for processing by a
DSP processor.Therefore the DFT is sampled at N discrete frequencies say w= 2*
*k/N,where k=0,1,2N-1.
The N point IDFT of the N point sequence is given by
PROGRAM:
% using inbuilt function
clc;
clear all;
close all;
x=input('ENTER THE INPUT SEQUENCE');
N=input ('ENTER THE LENGTH OF DFT');
n=length(x);
17
X=ifft(x,N);
t=[0:1:n-1]
figure(1)
subplot(221);
stem(t,x);
xlabel('TIME');
ylabel('AMPLITUDE');
title('ORIGINAL INPUT SEQUENCE');
K=[0:1:N-1]
figure(1)
subplot(222);
stem(K,X);
xlabel('FREQUENCY');
ylabel('AMPLITUDE');
title('IDFT RESPONSE');
figure(1)
subplot(223);
stem(K,abs(X));
xlabel('FREQUENCY');
ylabel('MAGNITUDE');
title('MAGNITUDE RESPONSE');
figure(1)
subplot(224);
stem(K,angle(X));
xlabel('FREQUENCY');
ylabel('PHASE');
title('PHASE RESPONSE');
18
end
end
k=[0:1:N-1]
mag=abs(y)
ang=angle(y)
figure(2)
subplot(221);
stem(k,x);
xlabel('TIME');
ylabel('AMPLITUDE');
title('ORIGINAL INPUT SEQUENCE');
figure(2)
subplot(222);
stem(k,y);
xlabel('FREQUENCY');
ylabel('AMPLITUDE');
title('DFT RESPONSE');
figure(2)
subplot(223);
stem(k,mag);
xlabel('FREQUENCY');
ylabel('MAGNITUDE');
title('MAGNITUDE RESPONSE');
figure(2)
subplot(224);
stem(k,ang);
xlabel('FREQUENCY');
ylabel('PHASE');
title('PHASE RESPONSE');
RESULT: IDFT implementation of the sequence was carried out using inbuilt function
and without using inbuilt function in Matlab.
19
EXPERIMENT NO: 7
DATE:
LINEAR CONVOLUTION USING DFT
THEORY:
PROGRAM:
20
RESULT: The Program is executed and plotted the output of linear convolution using
DFT.
EXPERIMENT NO: 9
DATE:
IIR BUTTERWORTH FILTERS
AIM: To write Matlab Program for implementing following Butterworth filters and plot
their magnitude and phase response.
i)Butterworth Low pass filter ii) Butterworth High pass filter
iii)Butterworth Bandpass filter iv) Butterworth Bandstop filter
THEORY:
IIR filters have infinite duration impulse response.Hence they are analogous to
analog filters which generally have long impulse response.The basic technique of IIR
filter design involves transforming analog filters into digitial filters using complex
mappings.The butterworth filter is characterized by the property that its magnitude
response is flat in both passband and stopband. The magnitude squared response of an
Nth order low pass filter is given by
2 1
Ha ( j) =
2N
1+
c
Where N is the order of the filter and c is the cut-off frequency in rad/sec.
PROGRAM:
% Butterworth Low Pass Filter
clc
close all
21
clear all
wp=input('Enter the passband frequency=')
ws=input('Enter the stopband frequency=')
rp=input('Enter the passband ripple=')
rs=input('Enter the stopband ripple=')
fs=input('Enter the sampling frequency=')
w1=2*wp/fs
w2=2*ws/fs
[N,wn]= buttord(w1,w2,rp,rs)
[b,a]=butter(N,wn)
w=0:0.01:pi
[h,omega]=freqz(b,a,w)
gain= 20*log10(abs(h))
subplot(2,1,1)
plot(omega/pi,gain)
grid
xlabel('\omega/pi,gain')
ylabel('Gain in dB')
title('IIR Butterworth LPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radians')
title('IIR Butterworth LPF:Phase')
disp('Order of the filter is:');N
22
w2=2*ws/fs
[N,wn]= buttord(w1,w2,rp,rs)
[b,a]=butter(N,wn,'high')
w=0:0.01:pi
[h,omega]=freqz(b,a,w)
gain= 20*log10(abs(h))
subplot(2,1,1)
plot(omega/pi,gain)
grid
xlabel('\omega/pi,gain')
ylabel('Gain in dB')
title('IIR Butterworth HPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radians')
title('IIR Butterworth HPF:Phase')
disp('Order of the filter is:');N
23
plot(omega/pi,gain)
grid
xlabel('\omega/pi,gain')
ylabel('Gain in dB')
title('IIR Butterworth BPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radians')
title('IIR Butterworth BPF:Phase')
disp('Order of the filter is:');N
24
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radians')
title('IIR Butterworth BSF:Phase')
disp('Order of the filter is:');N
RESULT: Executed the Low pass, High pass, Band pass, Band reject Butterworth filters
and plotted their magnitude and phase response. EXPERIMENT NO:
10
THEORY:
IIR filters have infinite duration impulse response. Hence they are analogous to
analog filters which generally have long impulse response. The basic technique of IIR
filter design involves transforming analog filters into digital filters using complex
mappings. The Butterworth filter is characterized by the property that its magnitude
response is flat in both pass band and stop band. There are two types of chebyshev filters.
The chebyshev I filters have equiripple response in the passband,while the chebyshev
II filters have equiripple response in the stopband.The magnitude squared response of
Chebyshev-I filter is given by
2 1
Ha ( j) =
2 2
1+ T (N )
c
Where N is the order of the filter, is the passband ripple factor, which is
25
Cosh (cos-1 (x) ) 1 x
PROGRAM:
%Chebyshev Type I L.P.F filter
clc
close all
clear all
wp=input('Enter the passband frequency=')
ws=input('Enter the stopband frequency=')
rp=input('Enter the passband ripple=')
rs=input('Enter the stopband ripple=')
fs=input('Enter the sampling frequency=')
w1=2*wp/fs
w2=2*ws/fs
[N,wn]= cheb1ord(w1,w2,rp,rs)
[b,a]=cheby1(N,rp,wn)
w=0:0.01:pi
[h,omega]=freqz(b,a,w)
gain= 20*log10(abs(h))
subplot(2,1,1)
plot(omega/pi,gain)
grid
xlabel('\omega/pi,gain')
ylabel('Gain in dB')
title('IIR Chebyshev-I LPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radian')
title('IIR Chebyshev-I LPF:Phase')
disp('Order of the filter is:');N
26
close all
clear all
wp=input('Enter the passband frequency=')
ws=input('Enter the stopband frequency=')
rp=input('Enter the passband ripple=')
rs=input('Enter the stopband ripple=')
fs=input('Enter the sampling frequency=')
w1=2*wp/fs
w2=2*ws/fs
[N,wn]= cheb2ord(w1,w2,rp,rs)
[b,a]=cheby2(N,rp,wn)
w=0:0.01:pi
[h,omega]=freqz(b,a,w)
gain= 20*log10(abs(h))
subplot(2,1,1)
plot(omega/pi,gain)
grid
xlabel('\omega/pi,gain')
ylabel('Gain in dB')
title('IIR Chebyshev-I LPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radian')
title('IIR Chebyshev-I LPF:Phase')
disp('Order of the filter is:');N
27
fs=input('Enter the sampling frequency=')
w1=2*wp/fs
w2=2*ws/fs
[N,wn]= cheb1ord(w1,w2,rp,rs)
[b,a]=cheby1(N,rp,wn,'high')
w=0:0.01:pi
[h,omega]=freqz(b,a,w)
gain= 20*log10(abs(h))
subplot(2,1,1)
plot(omega/pi,gain)
grid
xlabel('\omega/pi,gain')
ylabel('Gain in dB')
title('IIR Chebyshev-I HPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radian')
title('IIR Chebyshev-I HPF:Phase')
disp('Order of the filter is:');N
28
gain= 20*log10(abs(h))
subplot(2,1,1)
plot(omega/pi,gain)
grid
xlabel('\omega/pi,gain')
ylabel('Gain in dB')
title('IIR Chebyshev-I HPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radian')
title('IIR Chebyshev-I HPF:Phase')
disp('Order of the filter is:');N
29
title('IIR Chebyshev-I BPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radian')
title('IIR Chebyshev-I BPF:Phase')
disp('Order of the filter is:');N
clc
close all
clear all
wp=input('Enter the passband frequency=')
ws=input('Enter the stopband frequency=')
rp=input('Enter the passband ripple=')
rs=input('Enter the stopband ripple=')
fs=input('Enter the sampling frequency=')
w1=2*wp/fs
w2=2*ws/fs
[N]= cheb2ord(w1,w2,rp,rs)
[wn]=[w1,w2]
[b,a]=cheby2(N,rp,wn)
w=0:0.01:pi
[h,omega]=freqz(b,a,w)
gain= 20*log10(abs(h))
subplot(2,1,1)
plot(omega/pi,gain)
grid
xlabel('\omega/pi,gain')
ylabel('Gain in dB')
title('IIR Chebyshev-I BPF:Gain')
an=angle(h)
subplot(2,1,2)
30
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radian')
title('IIR Chebyshev-I BPF:Phase')
disp('Order of the filter is:');N
clc
close all
clear all
wp=input('Enter the passband frequency=')
ws=input('Enter the stopband frequency=')
rp=input('Enter the passband ripple=')
rs=input('Enter the stopband ripple=')
fs=input('Enter the sampling frequency=')
w1=2*wp/fs
w2=2*ws/fs
[N]= cheb1ord(w1,w2,rp,rs)
[wn]=[w1,w2]
[b,a]=cheby1(N,rp,wn,'stop')
w=0:0.01:pi
[h,omega]=freqz(b,a,w)
gain= 20*log10(abs(h))
subplot(2,1,1)
plot(omega/pi,gain)
grid
xlabel('\omega/pi,gain')
ylabel('Gain in dB')
title('IIR Chebyshev-I BSF:Gain')
an=angle(h)
31
subplot(2,1,2)
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radian')
title('IIR Chebyshev-I BSF:Phase')
disp('Order of the filter is:');N
32
plot(omega/pi,an)
grid
xlabel('\omega/pi,gain')
ylabel('Phase in radian')
title('IIR Chebyshev-I BSF:Phase')
disp('Order of the filter is:');N
RESULT: Executed the Low pass, High pass, Band pass, Band reject Chebyshev type I
and type II filters and plotted their magnitude and phase response.
EXPERIMENT NO:
12
THEORY: In digital signal processing there are mainly two types of systems. The
first type of system performs filtering in the time domain and is called digital filters. The
second type of system provides signal representation in frequency domain and is called
spectrum analyzers. The design of a digital filter is carried out in three steps.
Specifications
We need specifications for designing the filter. The specifications vary with
applications.
Approximations
Once the specifications are available, we make use of mathematical tools to come
up with a filter that approximates the given set of specifications.
Implementation
The previous step yields a filter response of the form h(n), H(Z) etc. We need to
implement this filter in hardware or through software.
33
A linear phase FIR filter is characterized by the impulse response,
Accordingly depending on whether N is odd or even we have four types of FIR filters.
34
_ Memory requirement and execution time are very high
Design methods for FIR filters are based on the direct approximation of the required
digital specification such as magnitude and phase response.
It is found that the impulse response of ideal filters is non causal, doubly infinite in length
and not absolutely summable. Since impulse response begins at -, no finite delay can
make the impulse response causal. So ideal filters are not realizable in real and non- real
time.
One way of possibly making the impulse response causal is to truncate the ideal impulse
response at n= - (N-1)/2 & n= (N-1)/2 , and resulting truncated impulse response is
delayed by (N-1)/2 , to obtain a causal impulse response. This can be achieved by
multiplying the impulse response by a window function. The truncation can lead to
undesired oscillations and overshoots produced in the pass band and stop band. The
undesired overshoots and oscillations can be minimized by using a set of time domain
functions named windows. Windowing introduces
transition band, and ripples in pass band and stop band. The spectral characteristics of
commonly used window functions are given below:
Window Transition Width minimum band attenuation
1. Select a window function, w(n) that meets the required stop band Attenuation.
2. Find the value of N, order of the filter using relation between filter order and transition
width of selected window.
3. Find the ideal impulse response, hd(n) of the filter using parameters like wc, group
delay etc
4. Find impulse response of actual filter, h(n) as hd(n)*w(n)
5. Realize the filter using appropriate structure.
35
PROGRAM:
%FIR FILTER BLACKMAN WINDOW (LPF)
Clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y=blackman(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)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('Blackman Window-LPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
title('Bartlett Window-LPF:Phase')
36
%FIR FILTER BLACKMAN WINDOW(HPF)
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y=blackman(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)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('Blackman Window-HPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
title('Bartlett Window-HPF:Phase')
37
%FIR FILTER BLACKMAN WINDOW(BPF)
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y=blackman(n1)
wn=[wp ws]
b=fir1(n,wn,y)
[h,om]=freqz(b,1,256)
m=20*log10(abs(h))
subplot(2,1,1)
plot(om/pi,m)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('Blackman Window-BPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
38
title('Bartlett Window-BPF:Phase')
39
title('Blacknam Window-BSF:Phase')
40
%FIR FILTER BARTLETT WINDOW(HPF)
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y=bartlett(n1)
b=fir1(n,wp,highy)
[h,om]=freqz(b,1,256)
m=20*log10(abs(h))
subplot(2,1,1)
plot(om/pi,m)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('Bartlett Window-HPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
title('Bartlett Window-HPF:Phase')
41
%FIR FILTER BARTLETT WINDOW(BPF)
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y=bartlett(n1)
wn=[wp ws]
b=fir1(n,wn,y)
[h,om]=freqz(b,1,256)
m=20*log10(abs(h))
subplot(2,1,1)
plot(om/pi,m)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('Bartlett Window-BPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
42
title('Bartlett Window-BPF:Phase')
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y=bartlett(n1)
wn=[wp ws]
b=fir1(n,wn,'stop',y)
[h,om]=freqz(b,1,256)
m=20*log10(abs(h))
subplot(2,1,1)
plot(om/pi,m)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('Bartlett Window-BSF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
43
title('Bartlett Window-BSF:Phase')
%FIR FILTER HAMMING WINDOW(LPF)
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y=hamming(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)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('Hamming Window-LPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
title('Hamming Window-LPF:Phase')
44
%FIR FILTER HAMMING WINDOW(HPF)
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y= hamming (n1)
b=fir1(n,wp,highy)
[h,om]=freqz(b,1,256)
m=20*log10(abs(h))
subplot(2,1,1)
plot(om/pi,m)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('Hamming Window-HPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
title('Hamming Window-HPF:Phase')
45
%FIR FILTER HAMMING WINDOW(BPF)
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y= hamming (n1)
wn=[wp ws]
b=fir1(n,wn,y)
[h,om]=freqz(b,1,256)
m=20*log10(abs(h))
subplot(2,1,1)
plot(om/pi,m)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('Hamming Window-BPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
title('Hamming Window-BPF:Phase')
46
%FIR FILTER HAMMING WINDOW(BSF)
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y= hamming (n1)
wn=[wp ws]
b=fir1(n,wn,'stop',y)
[h,om]=freqz(b,1,256)
m=20*log10(abs(h))
subplot(2,1,1)
plot(om/pi,m)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title(' Hamming Window-BSF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
title('Hamming Window-BSF:Phase')
47
clc
% FIR FILTER KAISER WINDOW(LPF)
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
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)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('kaiser Window-LPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
title('kaiser Window-LPF:Phase')
48
%FIR FILTER KAISER WINDOW(HPF)
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y= kaiser(n1)
b=fir1(n,wp,highy)
[h,om]=freqz(b,1,256)
m=20*log10(abs(h))
subplot(2,1,1)
plot(om/pi,m)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('Kaiser Window-HPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
title('Kaiser Window-HPF:Phase')
49
%FIR FILTER KAISER WINDOW(BPF)
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y= kaiser(n1)
wn=[wp ws]
b=fir1(n,wn,y)
[h,om]=freqz(b,1,256)
m=20*log10(abs(h))
subplot(2,1,1)
plot(om/pi,m)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title('kaiser Window-BPF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
title('kaiser Window-BPF:Phase')
50
%FIR FILTER KAISER WINDOW(BSF)
clc
clear all
close all
rp=input('Enter the passband ripple =')
rs=input('Enter the stopband ripple=')
fp=input('Enter the passband frequency=')
fs=input('Enter the stopbandfrequency=')
f=input('Enter the sampling frequency=')
wp=2*fp/f
ws=2*fs/f
neu=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(neu/den)
n1=n+1
if(rem(n,2)~=0)
n1=n
n=n-1
end
disp('the order is');n
y= kaiser(n1)
wn=[wp ws]
b=fir1(n,wn,'stop',y)
[h,om]=freqz(b,1,256)
m=20*log10(abs(h))
subplot(2,1,1)
plot(om/pi,m)
ylabel('Gain in dB')
xlabel('Frequency in rad/sec')
title(' Kaiser Window-BSF:Gain')
an=angle(h)
subplot(2,1,2)
plot(om/pi,an)
ylabel('Phase in radians')
xlabel('\omega/pi,gain')
title('Kaiser Window-BSF:Phase')
51
EXPERIMENT NO:
RESULT: Implemented FIR filter using window method and plotted the responses.
13
THEORY:
A linear phase FIR filter is characterized by the impulse response,
Design methods for FIR filters are based on the direct approximation of the required
digital specification such as magnitude and phase response.
It is found that the impulse response of ideal filters is non causal, doubly infinite in length
and not absolutely summable. Since impulse response begins at -, no finite delay can
make the impulse response causal. So ideal filters are not realizable in real and non- real
time.
fir2 designs frequency sampling-based digital FIR filters with arbitrarily shaped
frequency response. b = fir2(n,f,m) returns row vector b containing the n+1 coefficients
of an order n FIR filter. The frequency-magnitude characteristics of this filter match those
given by vectors f and m:
52
b = fir2(n,f,m,window) uses the window specified in the column vector window.
The vector window must be n+1 elements long. If no window is specified, fir2
uses a Hamming window of length n+1.
PROGRAM:
clc
clear all
close all
n=15
m=[ 1 1 1 0.557 1 0.0841 0 0]
f=[0 1/7 2/7 3/7 4/7 5/7 6/7 1]
window=[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
b=fir2(n,f,m,window)
disp('The coefficients are=')
disp(b)
[h,w]=freqz(b,1,128)
plot(f,m,w/pi,abs(h))
title('Desired and actual response')
RESULT: FIR filter design using frequency sampling method was implemented.
53
EXPERIMENT NO:
14
AIM: To execute the matlab program of an optimal equiripple design of FIR filter
THEORY:
b = firpm(n,f,a) returns row vector b containing the n+1 coefficients of the order n
FIR filter whose frequency-amplitude characteristics match those given by vectors f and
a.
PROGRAM:
clc
clear all
close all
edgepoints=input('Enter edge frequency of each band=')
Fs=input('Sampling frequency in Hz=')
bandmag=input('Enter magnitude values for each passband and stopband=')
54
dev=input('Enter desired ripple in each band=')
wt=input('Type in values for relative weights in each band=')
[N,fpoints,magpoints,wt]=firpmord(edgepoints,bandmag,dev,Fs)
disp('order of FIR filter is=')
disp(N)
b=firpm(N,fpoints,magpoints,wt)
[h,w]=freqz(b,1,256)
H=abs(h)
Hdb=20*log10(H)
plot(w/pi,Hdb)
grid
title('Magnitude response of equiripple,linear phase filter')
xlabel('Normalized frequency')
ylabel('Magnitude in db')
55
EXPERIMENT NO:
15
THEORY:
Amplitude Modulation
having low frequency.Let the modulating frequency be e ( t )=E t
m m sin m .
E
+E t
e ( t )= c m sin m t sin c .
E
E t ,where
c c +msin m t sin c
Em
m=
Ec is known as modulating index.
Emax and Emin are the maximum and minimum amplitudes of a AM signal in the positive
side.
Frequency Modulation
56
In the Frequency Modulation(FM),the frequency of a carrier signal having high
frequency is varied by the instantaneous amplitude of a modulating voltage having low
frequency. Let the modulating frequency be e ( t )=E t Then the
m m sin m .
E
+E t
e ( t )= c m sin m t sin c .
E
E t ,where
c c +msin m t sin c
Em
m=
Ec is known as modulating index.
Emax and Emin are the maximum and minimum amplitudes of a AM signal in the positive
side.
PWM does the modulation of the duty cycle of the pulse.In addition of use in
communication systems, PWM is also used in voltage regulators such as Switched Mode
Power Supplies(SMPS) to control the power delivered to load.PWM can be generated
using a comparator to which the modulating signal and a reference ramp(sawtooth)
waveform are fed.
PROGRAM
57
Fm=input('ENTER FREQUENCY OF MODULATING SIGNAL');
fc=input('ENTER FREQUENCY OF CARRIER SIGNAL FOR AM');
m1=input('ENTER MODULATION INDEX OF AM');
Fc2=input('ENTER FREQUENCY OF CARRIER SIGNAL FOR FM');
m2=input('ENTER MODULATION INDEX OF FM');
x=sin(2*pi*fc*t);
subplot(2,2,1);
plot(x);
title('CARRIER WAVE');
ylabel('AMPLITUDE');
xlabel('TIME');
y=sin(2*pi*Fm*t);
subplot(2,2,2);
plot(y);
title('MODULATING WAVE');
ylabel('AMPLITUDE');
xlabel('TIME');
z=(1+m1*y).*x;
subplot(2,2,3);
plot(z);
title('AM SIGNAL');
ylabel('AMPLITUDE');
xlabel('TIME');
Z=cos((2*pi*Fc2*t)+(m2.*y));
subplot(2,2,4);
plot(Z);
title('FM SIGNAL');
ylabel('AMPLITUDE');
xlabel('TIME');
58
for i=1:n
if(m(i)>=s(i))
pwm(i)=1
elseif (m(i)<=s(i))
pwm(i)=0
end
end
plot(t,pwm,'k',t,m,'--r',t,s,'--b')
title('PWM wave')
axis([0 1 -1.5 1.5])
RESULT: Generated and plotted the AM signal, FM signal and PWM signal
EXPERIMENT NO:
15
STUDY OF SAMPLING
THEORY:
PROGRAM:
59
xlabel('Time');
ylabel('Amplitude');
title('Original Signal');
%when Fs<2Fm
fs1=input('Enter the frequency for fs<2fm');
ts1=1/fs1;
tx1=0:ts1:0.1;
y1=cos(2*pi*Fm*tx1);
subplot(2,2,2);
stem(tx1,y1);
xlabel('Time');
ylabel('amplitude');
title('Fs<2Fm');
%When Fs=2Fm
fs2=input('Enter the frequency for fs=2fm');
ts2=1/fs2;
tx2=0:ts2:0.1;
y2=cos(2*pi*Fm*tx2);
subplot(2,2,3);
stem(tx2,y2);
xlabel('Time');
ylabel('amplitude');
title('Fs=2Fm');
%When Fs>2Fm
fs3=input('Enter the frequency for fs>2fm');
ts3=1/fs3;
tx3=0:ts3:0.1;
y3=cos(2*pi*Fm*tx3);
subplot(2,2,4);
stem(tx3,y3);
xlabel('Time');
ylabel('amplitude');
title('Fs>2Fm');
RESULT: Sampling of a given signal at three different frequencies were executed and
plotted.
60
EXPERIMENT NO:
16
Z-TRANSFORM
AIM: To plot the poles and zeros for a given transfer function
THEORY:
zplane(z,p) plots the zeros specified in column vector z and the poles specified in
column vector p in the current figure window. The symbol 'o' represents a zero and the
symbol 'x' represents a pole. The plot includes the unit circle for reference. If z and p are
arrays, zplane plots the poles and zeros in the columns of z and p in different colors.
PROGRAM:
61
clc
clear all
close all
num=input('Enter the numerator coefficients')
den=input('Enter the denominator coefficients')
N=input('Enter the length of the sequence')
[b,a]=freqz(num,den,N)
zplane(b,a)
RESULT:Program is executed and plotted the poles and zeros of a given transfer
function
62
INTRODUCTION TO TMS320C 6713 DSK
63
DSP processors can be broadly classified into general purpose and special purpose DSP
processors. There are two types of special purpose hardware:
Algortihm Specific Digital signal processor, which is used for execution of
efficient DSP algorithms.
Application Specific Digital Signal Processor, which is used for
specific applications like telecommunications, control etc.
Over the past few years it is seen that general purpose computers are capable of
performing two major tasks.
(1) Data Manipulation, and
(2) Mathematical Calculations
All the microprocessors are capable of doing these tasks but it is difficult to make a
device which can perform both the functions optimally, because of the involved technical
trade offs like the size of the instruction set, how interrupts are handled etc. As a broad
generalization these factors have made traditional microprocessors such as Pentium
Series, primarily directed at data manipulation. Similarly DSPs are designed to perform
the mathematical calculations needed in Digital Signal Processing, Data manipulation
involves storing and sorting of information. For instance, a word processing program
does a basic task of storing, organizing and retrieving of the information. This is
achieved by moving data from one location to another and testing for inequalities (A=B,
A<B etc.). While mathematics is occasionally used in this type of application, it is
infrequent and does not significantly affect the overall execution speed. In comparison to
this, the execution speed of most of the DSP algorithms is limited almost completely by
the number of multiplications and additions required.
In addition to performing mathematical calculations very rapidly, DSPs must also have a
predictable execution time.Most DSPs are used in applications where the processing is
continuous, not having a defined start or end. The cost, power consumption, design
difficulty etc increase along with the execution speed, which makes an accurate
knowledge of the execution time, critical for selecting proper device, as well as
64
algorithms that can be applied. DSPs can also perform the tasks in parallel instead of
serial in case of traditional microprocessors.
DSP processors can include fixed point devices as well as floating point devices. DSP's
are concerned with Real time signal processing. The signal input is usually analog in
nature. While analog devices based on discrete components are sensitive to temperature
etc. DSP prosessor based systems are less susceptible to environmental condiions. They
are easy to use, flexible and economical.
The Texas Instruments TMS320C6713 Digital Signal Processing Starter Kit (DSK) is a
low cost development platform for real - time digital signal processing applications. The
TMS320C6x are the first processors to use velociTI architecture, having implemented the
VLIW architecture. The TMS320C62x is a 16-bit fixed point processor and the 67x is a
floating point processor, with 32-bit integer support.
65
Block diagram of TMS320C 6713 DSK
Features:
The DSK comes with a full compliment of on-board devices that suit a wide variety of
application environments. Key features include:
A Texas Instruments TMS320C6713 DSP operating at 225 MHz.
An AIC23 stereo codec
16 Mbytes of synchronous DRAM
512 Kbytes of non-volatile Flash memory (256 Kbytes usable in default
configuration)
4 user accessible LEDs and DIP switches
Software board configuration through registers implemented in CPLD
Configurable boot options
Standard expansion connectors for daughter card use
66
JTAG emulation through on-board JTAG emulator with USB host
interface or external emulator
Single voltage power supply (+5V)
Functional Overview
67
with a USB host interface. The DSK can also be used with an external
emulator
Introduction
68
Use DSK diagnostic utility to test DSK functionality
69
appropriate files to the project. Compiler/linker options can readily be
specified. A number of debugging features are available, including
setting breakpoints and watching variables; viewing memory, registers,
and mixed C and assembly code; graphing results; and monitoring
execution time. One can step through a program in different ways
(step into, over, or out). Real-time analysis can be performed using
real-time data exchange (RTDX). RTDX allows for data exchange
between the host PC and the target DSK, as well as analysis in real
time without stopping the target. Key statistics and performance can
be monitored in real time. Through the joint team action group (JTAG),
communication with on-chip emulation support occurs to control and
monitor program execution. The C6713 DSK board includes a JTAG
interface through the USB port.
70
Right click 'source' and select 'Add files to project'
Add "c6713dskinit.c"
Similarly add "vectors intr.asm" or "vectors poll.asm" depending whether data
samples are taken on interrupt basis or using polling method
Also add "C6713dsk.cmd"
71
Select Project Build options Linker
Output file name should be default to \ Debug\ sine8 LED.out and Autoinit Model
should default to Run - Time Autoinitialization. Set Library Search Path to c:
n\CCStudio v3.1 n C6000 \ dsk6713 \ lib and set Include Libraries to rts6700.lib;
dsk6713bsl.lib;csl6713.lib .
Check that the symbol in the bottom left - hand corner of the CCS window
indicates connection to the DSK.
EXPERIMENT NO: 1
DATE:
1. SINE WAVE GENERATION
EQUIPMENTS:
72
Operating System Windows XP
Constructor - Simulator
Software - CCStudio 3.1
THEORY:
A Sine wave can be generated using a data table, using DIP switches using LEDs etc in
TMS3206713 DSP processor. Here sinewave is generated using a sine function and a
data table sine.dat. The c program uses a probe point to collect data points and a gain
factor is added to the signal. The sinewave project is created and all the necessary files
like the source files, the data files the library files are added to the project. The project is
then buid and loaded to the processor. In the build options change the processor type from
debug to FILEIO. In the C program add probe point to data IO. In the FILEIO add the
data file and give its starting address as currentBuffer.input, click on wrap around and add
the probe point. In the add probepoint select the Point and connect it to the data point and
say replace and apply. The probe point is now added. Now go to view and select graph
and give the starting address as currentBuffer.input to the input graph. Similarly go to
view and select graph and give the address as currentBuffer.out to the output. Debug and
run the program. A sinewave graph can be seen on the CCs plot.
PROGRAM:
#include <stdio.h>
#include "sine.h"
int gain = INITIALGAIN;
BufferContents currentBuffer;
73
}
}
static void processing()
{
int size = BUFFSIZE;
while(size--)
{
currentBuffer.output[size] = currentBuffer.input[size] * gain;
}
}
static void dataIO()
{
return;
}
74
75
EXPERIMENT NO: 2
DATE:
2. DISCRETE FOURIER TRANSFORM
EQUIPMENTS:
Operating System Windows XP
Constructor - Simulator
Software - CCStudio 3.1
THEORY:
The input to the DFT is a finite sequence of real or complex numbers making the DFT
ideal for processing information stored in computers.In particular, the DFT is widely
employed in signal processing and related fields to analyze the frequencies contained in a
sampled signal, to solve partial differential equations and to perform other operations
such as convolutions or multiplying large integers. A key enabling factor for these
applications is the fact that the DFT can be computed efficiently in practice using a fast
fourier transform (FFT) algorithm.
76
Create the project DFT and add all the necessary files. Build the project and then load it
into the processor. Debug and run the project. In the view options select graph and give
the address as samples and change the data plot style to bar. Also select the FFT
magnitude and phase plot. Debug and run the program. The DFT of a sequence of real
numbers with the output in CCS Graphical Display is plotted.
PROGRAM:
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979
#define N 100
typedef struct
float real;
float imag;
} COMPLEX;
COMPLEX samples[N];
77
COMPLEX result[N];
int k,n;
result[k].real=0.0;
result[k].imag = 0.0;
x[k] = result[k];
void main()
78
int n;
samples[n].real = cos(2*PI*TESTFREQ*n/SAMPLING_FREQ);
samples[n].imag = 0.0;
printf("done!\n");
RESULT: N point DFT of a sequence of real numbers read from a look up table is
generated and plotted.
79
80
EXPERIMENT NO: 3
DATE:
3 .FINITE IMPULSE RESPONSE FILTERS
EQUIPMENTS:
Operating System Windows XP
Constructor - Simulator
Software - CCStudio 3.1
THEORY:
A Finite Impulse Response (FIR) filter is a discrete linear time-invariant systemwhose
output is based on the weighted summation of a finite number of past inputs.An FIR
transversal filter structure can be obtained directly from the equation fordiscrete-time
convolution.In this equation, x(k) and y(n) represent the input to and output from the
filter at timen. h(n-k) is the transversal filter coefficients at time n. These coefficients
aregenerated by using FDS (Filter Design Software or Digital filter design package).FIR
filter is a finite impulse response filter. Order of the filter should be specified.Infinite
response is truncated to get finite impulse response. Placing a window offinite length
does this. Types of windows available are Rectangular, Barlett,Hamming, Hanning,
Blackmann window etc. This FIR filter is an all zero filter.
Create the project and add all the necessary files. Build and load the program in to the
processor.Debug and run the program .Enter the no.of samples as 64 and choice of the
window function as either 1 or 2.View the rectangular window by giving the starting
address as wr and buffer size as 64,similarly view the triangular window by giving the
starting address as wt.
PROGRAM:
#include<stdio.h>
#include<math.h>
#define pi 3.1415
81
intn,N,c;
floatwr[64],wt[64];
void main()
{
printf("\n enter no. of samples,N= :");
scanf("%d",&N);
printf("\n enter choice of window function\n 1.rect \n 2. triang \n c= :");
scanf("%d",&c);
printf("\n elements of window function are:");
switch(c)
{
case 1:
for(n=0;n<=N-1;n++)
{
wr[n]=1;
printf(" \n wr[%d]=%f",n,wr[n]);
}
break;
case 2:
for(n=0;n<=N-1;n++)
{
wt[n]=1-(2*(float)n/(N-1));
printf("\n wt[%d]=%f",n,wt[n]);
}
break;
}}
82
83
84
85
EXPERIMENT NO: 4
DATE:
4. INFINITE IMPULSE RESPONSE FILTERS
EQUIPMENTS:
Operating System Windows XP
Constructor - Simulator
Software - CCStudio 3.1
THEORY:
The IIR filter can realize both the poles and zeroes of a system because it has arational
transfer function, described by polynomials in z in both the numerator andthe
denominator:
M and N are order of the two polynomials,bk and ak are the filter coefficients. These
filter coefficients are generated using FDS (Filter Design software or Digital Filter design
package). IIR filters can be expanded as infinite impulse response filters. In designing IIR
filters, cutoff frequencies of the filters should be mentioned. The order of the filtercan be
86
estimated using butter worth polynomial. Thats why the filters are named asbutter worth
filters. Filter coefficients can be found and the response can be plotted.
The IIR project is build and all the necessary files are added. The project is build and
loaded into the processor. The view graph is selected and the starting address is given as
H, with a logarithmic scale to view the graph.
PROGRAM:
//iirfilters
#include<stdio.h>
#include<math.h>
inti,w,wc,c,N;
float H[100];
floatmul(float, int);
void main()
{
printf("\n enter order of filter ");
scanf("%d",&N);
printf("\n enter the cutoff freq ");
scanf("%d",&wc);
printf("\n enter the choice for IIR filter 1. LPF 2.HPF ");
scanf("%d",&c);
switch(c)
{
case 1:
for(w=0;w<100;w++)
{
H[w]=1/sqrt(1+mul((w/(float)wc),2*N));
printf("H[%d]=%f\n",w,H[w]);
}
break;
case 2:
87
for(w=0;w<=100;w++)
{
H[w]=1/sqrt(1+mul((float)wc/w,2*N));
printf("H[%d]=%f\n",w,H[w]);
}
break;
}}
floatmul(float a,int x)
{
for(i=0;i<x-1;i++)
a*=a;
return(a);
}
88
89
90