DSP Vtu Lab Manual
DSP Vtu Lab Manual
DSP Vtu Lab Manual
Syllabus i
List of Experiments iv
SYLLABUS
DIGITAL SIGNAL PROCESSING LABORATORY
i
Objectives:
Outcomes:
• The student will be able to carry out simulation of DSP systems.
• The student will be able to demonstrate their abilities towards DSP processor based
• The student will be able to analyze Finite word length effect on DSP systems.
• The student will be able to implement adaptive filters for various applications of DSP.
ii
Do’s and Dont’s:
• Do not handle any equipment without reading the instructions /Instruction manuals.
• Observe type of sockets of equipment power to avoid mechanical damage.
• Do not insert connectors forcefully in the Sockets.
• Strictly observe the instructions given by the Teacher/ Lab Instructor.
• It is mandatory to come to lab in a formal dress (Shirts, Trousers, ID card, and Shoes for
boys).
• Strictly no Jeans for both Girls and Boys.
• It is mandatory to come with observation book and lab record in which previous
experiment should be written in Record and the present lab‘s experiment in Observation
book.
• Observation book of the present lab experiment should be get corrected on the same day
and
• Record should be corrected on the next scheduled lab session.
• Mobile Phones should be Switched OFF in the lab session.
• Students have to come to lab in-time. Late comers are not allowed to enter the lab.
• Prepare for the viva questions. At the end of the experiment, the lab faculty will ask the
viva
• Questions and marks are allotted accordingly.
• Bring all the required stationery like graph sheets, pencil & eraser, different color pens
etc. for the lab class.
iii
List of Experiments
Sl. Page
EXPERIMENT
No. No.
1. Verification of Sampling theorem. 13
iv
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
MATLAB
TOOL BOX
Signal Processing Image Processing
Statistics Control Systems
Neural Network Communications
pass in data and/or get data back out (i.e. the list of commands is like a function in most
programming languages). Once you save a function, it becomes part of your toolbox (i.e. it
now looks to you as if it were part of the basic toolbox that you started with).
For those with computer programming backgrounds: Note that MATLAB runs as
aninterpretive language (like the old BASIC). That is, it does not need to be compiled. It
simply reads through each line of the function, executes it, and then goes on to the next line.
(In practice, a form of compilation occurs when you first run a function, so that it can run
faster the next time you run it.
MATLAB Windows:
MATLAB works with through three basic windows
Command Window : This is the main window .it is characterized by MATLAB command
prompt >> when you launch the application program MATLAB puts you in this window all
commands including those for user-written programs ,are typed in this window at the
MATLAB prompt
Graphics window: the output of all graphics commands typed in the command window are
flushed to the graphics or figure window, a separate gray window with white background
color the user can create as many windows as the system memory will allow
Edit window: This is where you write edit, create and save your own programs in filescalled
M files.
INPUT-OUTPUT:
MATLAB supports interactive computation taking the input from the screen and
flushing, the output to the screen. In addition it can read input files and write output files
Data Type: the fundamental data –type in MATLAB is the array. It encompasses several
distinct data objects- integers, real numbers, matrices, character strings, structures and
cells.There is no need to declare variables as real or complex, MATLAB automatically sets
the variable to be real.
1. T = 0: 1:10
This instruction indicates a vector T which as initial value 0 and final value 10 with
an increment of 1
Therefore T = [0 1 2 3 4 5 6 7 8 9 10]
2. F= 20: 1: 100
Therefore F = [20 21 22 23 24 ……… 100]
3. T= 0:1/pi: 1
Therefore T= [0, 0.3183, 0.6366,
The above instruction creates a vector of one row and three columns whose values are zero
Output= [0 0 0]
5. ones (5,2)
The above instruction creates a vector of five rows and two columns
Output = 11
11
11
11
11
6. zeros (2, 4)
Output = 0000
0000
7. a = [ 1 2 3] , b = [4 5 6]
8. if C= [2 2 2] and b = [4 5 6]
b.*C results in [8 10 12]
9. plot (t, x)
If x = [6 7 8 9] and t = [1 2 3 4]; This instruction will display a figure window which
indicates the plot of x versus t
11. Subplot: This function divides the figure window into rows and columns Subplot (2 2 1)
divides the figure window into 2 rows and 2 columns 1 represent number of the figure
computes the impulse response at those integer locations, starting the response computation
from 0 (and t = n or t = [0 n]).If, instead of n, you include the empty vector for the second
argument, the number of samples is computed automatically by default.
Impulse Signal
Ramp Signal
Exponential Signal
Sine wave
x(n) = Sinn
x(n) = SinȦt
Cosine wave
x(n) = Cosn
x(n) = CosȦt
PROGRAM
OUTPUT:
enter the value of N = 10
enter the value of N1 = 10
enter the length N2 = 6
enter the value of a = 3
The digital signal is same as discrete signal except that the magnitude of the signal is
quantized. The magnitude of the signal can take one of the values in a set of quantized
values. Here quantization is necessary to represent the signal in binary codes.
8. How will you classify the discrete time signals?
The discrete time signals are classified depending on their characteristics. Some ways
of classifying discrete time signals are (a) Energy signals and Power signals, (b) Periodic and
Aperiodic signals, (c) Symmetric and Anti symmetric signals.
PART-A
EXPERIMENT NO-1:-SAMPLING THEOREM
OBJECTIVE: To verify sampling theorem forNyquist rate, Under sampling and Over
sampling condition in both time and frequency domain using MATLAB.
THEORY:
Sampling: Is the process of converting a continuous time signal into a discrete time signal. It
is the first step in conversion from analog signal to digital signal.
Sampling theorem: Sampling theorem states that “Exact reconstruction of a continuous time
base-band signal from its samples is possible, if the signal is band-limited and the sampling
frequency is greater than twice the signal bandwidth”.i.e. fs> 2W, where W is the signal
bandwidth.
Nyquist Rate Sampling: The Nyquist rate is the minimum sampling rate required toavoid
aliasing, equal to the highest modulating frequency contained within the signal. In other
words, Nyquist rate is equal to two sided bandwidth of the signal (Upper and lower
sidebands) i.e., fs = 2W.To avoid aliasing, the sampling rate must exceed theNyquist rate.
i.e.fs>fN, where fN =2W.
ALGORITHM:
1. Select the frequency of analog signal f Hz
2. To generate sine wave of f Hz define a closely spaced time vector
3. Generate the sinusoid and plot the signal
4. Select the sampling frequency fs= 10f samples/sec. Generate a suitable time scale for
this sampling signal
5. Sample the analog signal at the instant specified by n.
6. Modify the time vector n used for discrete simulation
7. Reconstruct the analog signal from its discrete samples
8. Compare the analog and reconstructed signal
9. Repeat the values experiment for different values of f and verify reconstructed
and analog signal
OUTPUT:
enter the analog wave frequency = 500
fs = 2*fn; % oversampling
t = [0:1/fs:0.1]; % défine time vector
DEPT OF ECE, GCEM Page 16
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
OUTPUT:
Enter the first sine wave frequency = 1000
Enter the second sine wave frequency = 2000
OUTCOME: Sampling theorem is verified for under, Nyquist rate and over sampling using
MATLAB
5. What is DT system?
A DT system is a device or algorithm that operates on a DT signal according to some
well-defined rule, to produce another DT signal. In general a DT system can be thought as a
set of operations performed on the input signal x[n] to produce the output signal y[n].
THEORY:
A discrete time system performs an operation on an input signal based on predefined criteria
to produce a modified output signal. The input signal x(n) is the system excitation, and y(n)
is the system response. The transform operation is shown as,
x(n) y(n) =
T
If the input to the system is unit impulse i.e. x(n) = į(n) then the output of the system is
known as impulse response denoted by h(n) where,
h(n) = T[į(n)] (1)
We know that any arbitrary sequence x(n) can be represented as a weighted sum of discrete
impulses. Now the system response is given by,
y(n)= (2)
The response to the shifted impulse sequence can be denoted by h(n, k) is denoted by,
h(n, k) = T[į(n-k)] (4)
For a time-invariant system
h(n, k) = h(n-k) (5)
Using (5) in (4) we obtain,
T[į(n-k)] = h(n-k) (6)
Using (6) in (3) we get,
(7)
For a linear time-invariant system if the input sequence is x(n) and impulse response h(n) is
given, we can fine output y(n) by using eqn (7), which is known as convolution sum and can
be represented by y(n) = x(n) * h(n)
ALGORITHM:
1. For the given difference equation, rewrite the equation so that y[n] and its delayed
samples are on the LHS and x[n] and its delayed samples are on the RHS
2. Create a matrix A for the coefficients of y[n] and its delayed versions
3. Create a matrix B for the coefficients of x[n] and its delayed versions
4. Generate an impulse excitation signal delta[n].
5. Find the response h[n] of the filter defined by A and B coefficients to the input
impulse excitation using deconv, impz and filter commands
6. Display and plot the impulse response h[n]
CALCULATION:
Taking z-transformers
2
Multiply both numerator and denomination by z .
Z=0.5, A=-1
OUTPUT:
Output sequence y(n) of the system = [1 -3/4]
Input sequence x (n) of the system = [1 -3/4 1/8]
Impulse response of the system = [1 0 –0.125 -0.0937 -0.0546]
y = input('Output sequence y(n) of the system = '); % enter the coefficients of y terms
x = input('Input sequence x(n) of the system = '); % enter the coefficient of x terms
N=input('Enter the length of impulse response = % define the length of the response
'); h = impz(y,x,N); % calculate the impulse response
disp('Impulse Response of system h(n)');
disp(h); % display the values of impulse response
%graphical plot
n = 0:1:N-1; % define x axis
stem(n,h); % plot the impulse response
xlabel('n'); % label x axis
ylabel('h(n)'); % label y axis
title('Impulse Response'); % graph title
OUTPUT:
Output sequence y(n) of the system = [1 -1/3]
Input sequence x(n) of the system = [1 -3/4 -1/8]
Enter the length of impulse response =5
Impulse Response of system h(n) =1.0000 0 -0.125 -0.0937 -0.0546
OUTPUT:
Output sequence y(n) of the system = [1 -1/3]
Input sequence x(n) of the system = [1 -3/4 -1/8]
Enter the length of impulse response = 5
Impulse Response of the system is = 1.0000 0 -0.125 -0.0937 -0.0546
OUTCOME:Impulse response and the output response of the system is found and the results
are verified in MATLAB.
OBJECTIVE:
1. To find linear convolution of right sided sequence using inbuilt MATLAB function
“CONV” and its theoretical method to verify the result
2. To find linear convolution of both sided sequence using inbuilt MATLAB function
“CONV” and its theoretical method to verify the result
3. To find linear convolution of a given sequences using circular convolution.
Mathematical Formula:
The linear convolution of two continuous time signals x(t) and h(t) is defined by
Where x(n) is the input signal and h(n) is the impulse response of the system.
ALGORITHM:
1. Read the input sequence, x[n] and plot.
2. Read the impulse response of the system, h[n] and plot
3. Convolve the two sequences using conv command and plot the results.
CALCULATION:
On simplification we get,
subplot(2,2,2);% divide the display screen in four sections and choose the first second to
display
stem(x2); % plot the second sequence
xlabel('n'); % label x axis
ylabel('x2(n)'); % label y axis
title('plot of x2'); % graph title
subplot(2,1,2);% divide the display screen in four sections and choose the first second to
display
stem(y); % plot the output sequence
xlabel('n'); % label x axis
ylabel('y(n)'); % label y axis
title('convolution output'); % graph title
OUTPUT:
enter the first sequence x1(n) = [1 5 10 20]
enter the second sequence x2(n) = [5 10]
Linear convolution of x1 and x2 is = 5 35 100 200 200
Z= X1 * X2
On Simplification, we get
Z= { 2, 1, 4, 2, 6, 9, 3, 2, 15, -3, 3, 4}
PROGRAM
clc; % clear screen
clear all; % clear work space
close all; % close all figure windows
x1 = input('enter the first sequence x1(n) = '); % define first sequence
x2 = input('enter the second sequence x2(n) = '); % define second sequence
n1 = -2:2; % time axis for first sequence
n2 = -1:3; % time axis for second sequence
ybegin = n1(1)+n2(1); % calculate the first point of x axis of output
yend = n1(length(x1)) + n2(length(x2)); % calculate the end point of x axis of output
ny = [ybegin : yend]; % define x axis for output
y = conv(x1,x2); % convolute the first and second sequence
disp('Linear convolution of x1 and x2 is = ');
disp(y); % display the output
%graphical display
subplot(2,2,1);% divide the display screen in four sections and choose the first second to
display
stem(n1,x1); % plot the first sequence
xlabel('n'); % label x axis
DEPT OF ECE, GCEM Page 32
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
OUTPUT:
enter the first sequence x1(n) = [1 2 3 2 1 3 4]
enter the second sequence x2(n) = [2 -3 4 -1 0 1]
Linear convolution of x1 and x2 is =
2 1 4 2 6 9 3 2 15 -3 3 4
ylabel('(h(n)');
title('Plot of x2(n)');
subplot(2,2,3); %Graphical display of output sequence stem(y);
xlabel('n');
ylabel('y(n)');
title('Linear Convolution Output');
OUTPUT:
enter the first sequence x(n) = [1 2 3]
enter the second sequence h(n) = [4 5 2]
Linear Convolution using Circular Convolution =
4 13 24 19 6
OUTCOME:Linear convolution of the sequences is found and the results are verified in
MATLAB.
THEORY:Let x1(n) and x2(n) are finite duration sequences both of length N with DFT’s
X1(k) and X2(k). Convolution of two given sequences x1(n) and x2(n) is given by the
equation,
x3(n) = IDFT[X3(k)]where X3(k) = X1(k) X2(k)
CALCULATION:
Let’s take x1(n) = {1, 1, 2, 1} and x2(n) = {1, 2, 3,
4} x3(0) = x1(m) x2(-m)
= x1(0) x2(0) + x1(1) x2(3) + x1(2) x2(2) + x1(3) x2(1)
= 1 + 4 + 6 +2 = 13
x3(1) = x1(m) x2(1-m)
= x1(0) x2(1) + x1(1) x2(0) + x1(2) x2(3) + x1(3) x2(2)
= 2 + 1 + 8 + 3= 14
x3(2) = x1(m) x2(2-m)
= x1(0) x2(2) + x1(1) x2(1) + x1(2) x2(0) + x1(3) x2(3)
= 3 + 2 + 2+ 4= 11
x3(3) = x1(m) x2(3-m)
= x1(0) x2(3) + x1(1) x2(2) + x1(2) x2(1) + x1(3) x2(0)
= 4 + 3 + 4 + 1= 12
The convoluted signal is,
x3(n) = {13, 14, 11, 12}
ALGORITHM:
1. Read the first input sequence, x[n] and plot.
2. Read the second input sequence, h[n] and plot
3. Find the length of x[n] and y[n] , l1 and l2 respectively
4. Check if l1=l2. Proceed only if equal.
DEPT OF ECE, GCEM Page 37
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
OUTPUT:
enter the first sequence x(n) = [1 1 2 1]
enter the second sequence h(n) = [1 2 3 4]
Circular convolution in Time Domain =
13 14 11 12
OUTCOME: Circular convolution of the sequences are found and the results are verified in
MATLAB
In periodic convolution input signals are originally periodic with common value of
period. In circular convolution, if input signals are not periodic then they are assumed to be
periodic with period = N where N = max (L, M) where L is the length of first signal and M is
length of second signal.
OBJECTIVE:
1. To find Autocorrelation of the given sequence using an inbuilt MATLAB function
“XCORR” and to verify its properties.
2. To verify the results theoretically.
THEORY: Correlation: Correlation determines the degree of similarity between two signals.
If the signals are identical, then the correlation coefficient is 1; if they are totally different,
the correlation coefficient is 0, and if they are identical except that the phase is shifted by
0
exactly 180 (i.e. mirrored), then the correlation coefficient is -1.
k = 0, ±1, ±2, ±3 …
Properties of Autocorrelation:
1. Rxx(0) = Energy(x)
2. Autocorrelation function is symmetric. i.e. Rxx(m) = Rxx(-m)
ALGORITHM
1. Read the input sequence x[n]
2. Auto correlate the signal using xcorr(x,x)
3. Display the auto correlation result on a suitable axis.
4. Verify the correlation property Rxx(0)= energy(x)
5. Verify the symmetric property
CALCULATION:
X(n) ={ 3, 4, 5, 6}
Rxx = [ 18 39 62 86 62 39 18]
OUTPUT:
Enter the input signal x[n] [3 4 5 6]
Rxx = [ 18 39 62 86 62 39 18]
Rxx_0 = 30
Rxx(0) gives energy -- proved
Rxx is even
1. What is correlation?
Correlation gives a measure of similarity between two data sequences. In this process, two
signals are compared and the degree to which the two signals are similar is computed.
(i) Linear filtering i.e. to find output of digital filter for any given input sequence (ii)
Spectral Analysis i.e. to find magnitude spectrum and phase spectrum (iii) Circular
Correlation i.e., to find degree of similarity between two signals.
6. What is auto-correlation?
It is a measure of similarity of similarity of a signal/waveform with itself.
OBJECTIVE:
1. To implement Cross correlation of the given sequence using an inbuilt MATLAB
function “XCORR” and to verify its properties.
2. To find Cross correlation of the given sequences using convolution.
3. To verify the results theoretically.
THEORY: When two independent signals are compared, the procedure is known as cross
correlation. It is given by,
k = 0, ±1, ±2, ±3 …
Comparing above two equations, we find that, Rxy (k) = Ryx (-k),WhereRyx (-k) is the
folded version of Rxy (k) about k = 0.So, we can write Cross correlation of the two
sequences is given by,
k = 0, ±1, ±2, ±3 …
Rxy (k) = x(k) * y(-k) (1)
Equation (1) shows that cross correlation is the essentially the convolution of two sequences
in which one of the sequences has been reversed.
CALCULATION:
Rxy = [2 5 10 16 12 11 4]
xlabel('n')
ylabel('y(n)');
title('Plot of y(n)');
stem(k,r);
xlabel('n');
ylabel('r(n)');
title('Cross Correlation Output');
OUTPUT:
Enter the first sequence x(n) = [1 2 3 4]
Enter the second sequence y(n) = [1 2 1 2]
Cross Correlation Output=
2 5 10 16 12 11 4
y = input(‘seq2’);
Rxy = xcorr(x,y);
Ryx=xcorr(y,x);
Rxy1 = fliplr(Rxy);
if Rxy1 = Ryx
Æ
disp(‘Rxy(-k) = Ryx(k) -
proved’); else
disp(‘Not proved’);
end
2
Rxx=xcorr(x,x); %|Rxy(k)| < Rxx(-0).Ryy(0)
Ryy = xcorr(y,y);
R =abs(Rxy).^2
CIx = ceil(length(Rxx)/2);
CIy= ceil(length(Ryy)/2);
Rxx.0=Rxx(CIx);
Ryy.0=Ryy(CIy);
R1 = Rxx.0+ Ryy.0;
If R <=R1
disp(‘Property Proved’);
else
disp(‘Property not proved’);
end
OUTPUT:
Enter the first sequence x(n) = [1 5 6 7]
Enter the second sequence y(n) = [3 4 2 1]
Cross Correlation Output =
1 7 20 42 53 46 21
2. What is DTFT?
DTFT is Fourier Transform of DT signal that converts the sampled DT signal from
time domain to frequency domain. Frequency domain representation parameters are
magnitude and phase. DTFT gives frequency response that includes magnitude response and
phase response.
6. Differentiate between DTFT and DFT. Why it is advantageous to use DFT in computers
rather than DTFT?
In DTFT, frequency appears to be continuous. But, in DFT, frequency is discrete.
This property is useful for computation in computers.
OBJECTIVE:
1. To solve the given difference equation(response of the filter) by varying the input
sequences as “Impulse input, Exponential input and Sinusoidal input” with and
without initial conditions using an inbuilt MATLAB functions “FILTER and
FILTIC”
2. To verify the results theoretically.
THEORY:
th
A General N order Difference equations looks like,
y[n] + a1y[n-1] + a2y[n-2] + …+ aNy[n-N) = b0x[n] + b1x[n-1] + …. + bMx[n-M]
Here y[n] is “Most advanced” output sample and y[n-m] is “Least advanced” output sample.
The difference between these two index values is the order of the difference equation.
Here we have: n-(n-N) = N
We can rewrite the above equation as, y[n]
+ aiy[n-i] = bi x[n-i]
y[n] becomes,
y[n] = -aiy[n-i] + bi x[n-i]
Example:
y[n+2] – 1.5y[n+1] + y[n] = 2x[n]
In general we start with the “Most advanced” output sample. Here it is y [n+2].
So, here we need to subtract 2 from each sample argument. Weget
y[n] – 1.5y[n-1] + y[n-2] = 2x[n-2]
Ö
y[n] = 1.5y[n-1] - y[n-2] + 2x[n-2]
Lets assume our input x[n] = u[n] = 0 x<0
1 x0
In our example we have taken x[n] = u[n] = 0 x<0
1 0 x < 10
th
We need N past values to solve N order difference equation.
y [-2] = 1
y[-1] = 2
Compute y[n] for various values of n
y[0] = 1.5y[-1] - y[-2] + 2x[-2]
= 1.5*2 – 1 +
2*0 y[0] = 2
y[1] = 1
xlabel('n');
ylabel('h(n)');
%to find exponential response
N= input('Enter the length of response = '); % define the length of response
b = [1]; % coefficients of x(n)
a = [1 -5/6 1/6]; % coefficients of y(n)
n = 0:1:N-1; % define x axis
x = 2.^n; % define exponential input
h = filter(b,a,x); % calculate the exponential response
disp('Response of filter =');
disp(h); % display the output
subplot(2,1,1); % graphical plot of the input and output
stem(n,x);
title('Exponential input');
xlabel('n');
ylabel('x(n)');
subplot(2,1,2);
stem(n,h);
title('Exponential response');
xlabel('n');
ylabel('h(n)');
%to find steady response
N= input('Enter the length of response = '); % define the length of response
b = [5]; % coefficients of x(n)
a = [1 -0.5]; % coefficients of y(n)
n = 0:1:N-1; % define x axis
x = cos(0.5*pi*n); % define sinusoidal input
h = filter(b,a,x); % calculate the sinusoidal response
disp('Response of filter =');
disp(h); % display the output
subplot(2,1,1); % graphical plot of the input and output
stem(n,x);
DEPT OF ECE, GCEM Page 59
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
title('Steady input');
xlabel('n');
ylabel('x(n)');
subplot(2,1,2);
stem(n,h);
title('Steady response');
xlabel('n');
ylabel('h(n)');
OUTPUT:
Impulse Response:
Enter the length of response = 10
Response of filter =
-2.0000 1.7500 -0.6875 0.3906 -0.1836 0.0947 -0.0466 0.0235 -0.0117
0.0059
Step Response:
Enter the length of response = 10
Response of filter =
-1.0000 0.7500 0.8125 1.4844 1.6758 1.9756 2.1223 2.2714 2.3637 2.4427
Exponential Response:
Enter the length of response =
10 Response of filter =
1.0000 2.8333 6.1944 12.6898 25.5424 51.1704 102.3849 204.7924 409.5962
819.1981
stem(n,x);
xlabel('n');
ylabel('x(n)');
title('Input signal');
subplot(2,1,2);
stem(n,y);
xlabel('n');
ylabel('y(n)');
title('Response of filter');
OUTPUT:
Enter the length of response =
10 Response of filter =
2.8750 4.0313 4.6641 4.9941 5.1626 5.2477 5.2904 5.3119 5.3226
5.3280
OUTCOME: Solution of the difference equation is found and the output response is
calculated.
AIM: To compute n-point DFT of a given sequence and to plot magnitude and phase
spectrum.
OBJECTIVE:
1. To find the N point DFT of a given sequence using the MATLAB inbuilt function
“FFT” and to find Magnitude and Phase of DFT sequence using functions “ABS and
ANGLE”
2. To verify the result theoretically.
k = 0,1, …. N-1
EXAMPLE:
Let us assume the input sequence x[n] = [1 1 0 0]
We have,
k = 0,1, …. N-1
For k = 0,
ALGORITHM:
OUTPUT:
enter the N point = 4
enter the input sequence x(n) = [0 1 2 3]
N point DFT of x(n) is =
6.0000 -2.0000 + 2.0000i -2.0000 -2.0000 - 2.0000i
xlabel('n');
ylabel('|X(K)|');
title('Magnitude spectrum');
subplot(2,2,3); % graphical plot of angle of output signal
stem(k,angle(Xk)*180/pi);
xlabel('n');
ylabel('<X(K)');
title('Phase spectrum');
%function file
function [Xk] =
dft(xn,N) n = 0:1:N-1;
k = 0:1:N-1;
WN = exp(-
j*2*pi/N); nk = n'*k;
WNnk = WN.^nk;
Xk = xn*WNnk;
OUTPUT:
enter N point = 4
enter the input sequence x(n) = [1 4 2 7]
N point DFT of x(n) =
14.0000 -1.0000 + 3.0000i -8.0000 - 0.0000i -1.0000 - 3.0000i
OUTCOME: DFT of the given sequence is found and the results are verified using
MATLAB.
can't do any better than this then the DFT will not be very useful for the majority of practical
DSP applications. Fortunately, there are a number of different 'Fast Fourier Transform' (FFT)
algorithms that enable us to do very much better than this.
OBJECTIVE:
1. To find the Linear convolution of a given sequence using the inbuilt MATLAB
functions “FFT and IFFT” for DFT and IDFT and verify the result using the function
“CONV”
2. To verify the result theoretically.
Mathematic Formula:
The linear convolution of two continuous time signals x(t) and h(t) is defined by
Where x(n) is the input signal and h(n) is the impulse response of the system.
EXAMPLE:
x1(n) = {1, 1, 2}
x2(n) = {1, 2}
For linear convolution,
Length N = Length(x1) + Length(x2) - 1
N=3+2–1=4
k= 0, 1, 2, … , N-1
=1+1+2=4
= 1 – j – 2 = -1 - j
=1–1+2=2
= 1 + j – 2 = -1 + j
X1(k) = {4, -1 – j, 2, -1 + j}
Now,
k= 0, 1, 2, … , N-1
=1+2=3
= 1 + 2(-j) = 1 - j2
= 1 + 2(-1) = -1
= 1 + 2(j) = 1 + j2
We know that,
X3(k) = X1(k) X2(k)
X3(k) = {12, -3+j, -2, -3-j}
ALGORITHM:
1. Find the length of the first sequence x[n]
2. Find the length of second sequence h[n]
3. Define the number of points of DFT N to be taken as length(x[n])+ length(h[n])-1
4. Find the DFT of x[n] and h[n] using fft command as X(k) and H(k) respectively.
5. Find Y(k)= X(k) * H(k).
6. Find y[n] using IDFT of Y(k)
7. Verify y[n]= convolution of x(n) and h(n) using conv command
xlabel('n');
ylabel('x(n)');
title('plot of x(n)');
subplot(2,2,2); % graphical display of second sequence
stem(hn);
xlabel('n');
ylabel('h(n)');
title('plot of h(n)');
subplot(2,2,3); % graphical display of output sequence
stem(yn);
xlabel('n');
ylabel('y(n)');
title('Convolution Output');
yv =conv(xn,hn); % verification of linear convolution
disp('Convolution in time domain = ');
disp(yv);
subplot(2,2,4); % graphical display of output sequence
stem(yv);
xlabel('n');
ylabel('yv(n)');
title('Verified convolution output');
OUTPUT:
Enter the first sequence x(n) = [1 5 7 8]
Enter the second sequence h(n) = [3 1 5 6]
OUTCOME: Linear convolution of two given sequences found using DFT and IDFT
and the results are verified.
OBJECTIVE:
1. To find the Circular convolution of a given sequence using the inbuilt MATLAB
function “FFT and IFFT” for DFT and IDFT.
2. To verify the result theoretically.
THEORY:Let x1(n) and x2(n) are finite duration sequences both of length N with DFT’s
X1(k) and X2(k). Convolution of two given sequences x1(n) and x2(n) is given
by, x3(n) = IDFT[X3(k)]
x3(n) = IDFT[X1(k) X2(k)]
Where, X1(k) = DFT [x1(n)], X2(k) = DFT [x2(n)]
EXAMPLE:
Let x1(n) = {1, 1, 2, 1} and x2(n) = {1, 2, 3, 4}
k= 0, 1, 2, … , N-1
=1+1+2+1=5
= 1 – j – 2 + j = -1
=1–1+2-1=1
= 1 + j - 2 - j = -1
= 1 + 2 + 3 + 4 = 10
= 1 + 2(-j) + 3(-1) + 4(j) = -2 + j2
We know that,
X3(k) = X1(k) X2(k)
X3(k) = {50, 2 – j2, -2, 2 + j2}
n = 0, 1, 2, …. , N-1
ALGORITHM:
1. Find the length of the first sequence x[n]
2. Find the length of second sequence h[n]
3. Define the number of points of DFT N to be taken as maximum of length(x[n])
and length(h[n]).
4. Find the DFT of x[n] and h[n] using fft command as X(k) and H(k) respectively.
5. Find Y(k)= X(k) * H(k).
6. Find y[n] using IDFT of Y(k)
7. Verify y[n]= convolution of x(n) and h(n) using conv command
OUTPUT:
Enter the first sequence x(n) = [1 2 3 4]
Enter the second sequence h(n) = [4 5 6 1]
OUTCOME: Circular convolution of two given sequences found using DFT and IDFT
and the results are verified.
5. Compare the overlap add and overlap save method of sectioned convolution.
Overlap add method Overlap save method
1. Linear convolution of each section of 1. Circular convolution of each section
longersequencewith smaller of longer sequence with smaller
sequence is performed sequence is performed.
2. Zero padding is not required 2. Zero-padding is required to convert
the input sequences to the size of
output sequence.
3. Overlapping of samples of input 3. The N2-1 sample of an input section
sections are not required of longer sequence is overlapped with
next input section.
4. The overlapped samples in the output 4. Depending on the method of
of sectioned convolutions are added overlapping the input samples, either
to get the overall output. the last N2-1 samples or the first N2-1
samples of the output sequence of
each sectioned convolution are
discarded.
AIM: Design and implementation of FIR filter to meet given specifications (low pass filter
using hamming window).
OBJECTIVE:
1. To design the FIR filter by Hamming window using the inbuilt MATLAB function
“FIR1 and HAMMING”.
2. To verify the result by theoretical calculations.
THEORY: The FIR filters are of non-recursive type, whereby the present output sample is
depending on the present input sample and previous input samples. The transfer function of a
FIR causal filter is given by,
z-n
Where h(n) is the impulse response of the filter.
In the design of FIR filters most commonly used approach is using windows.The desired
jw
frequency response Hd(e ) of a filter is periodic in frequency and can be expanded in
Fourier series. The resultant series is given by,
hd(n)
This is known as Fourier series coefficients having infinite length. One possible way of
obtaining FIR filter is to truncate the infinite Fourier series at n = ± [(N-1)/2]Where N is the
length of the desired sequence.
The Fourier coefficients of the filter are modified by multiplying the infinite
impulse response with a finite weighing sequence w(n) called a window.
Where w(n)= w(-n) 0 for |n| [(N-1)/2]
=0 for |n| > [(N-1)/2]
After multiplying w(n)with hd(n), we get a finite duration sequence h(n) that satisfies the
desired magnitude response,
h(n)= hd(n) w(n) for |n| [(N-1)/2]
DEPT OF ECE, GCEM Page 85
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
jw jw jw
H(e ) = Hd(e ) * W(e )
ALGORITHM:
1. Get the sampling frequency
2. Get the pass band frequency
3. Get the stop band frequency
4. Get the pass band ripple and stop band attenuation
5. Select the window suitable for stop band attenuation
6. Calculate the order N based on transition width
7. Find the N window coefficients
8. Find the impulse response of h[n]
9. Verify the frequency response of h[n]
EXAMPLE:
Here we design a lowpass filter using hamming window. Hamming window function is
given by,
wH(n) = 0.54 + 0.46 cos ((2ʌn)/(N-1)) ;–(N-1)/2 n (N-1)/2
=0 ; otherwise
The frequency response of Hamming window is,
jw
WH(e ) = 0.54[(sin(wN/2))/(sin(w/2)) + 0.23[sin (wN/2 – ʌN/N – 1)/sin (w/2 – ʌ/N -1)]+
0.23[sin (wN/2 + ʌN/N – 1)/sin (w/2 + ʌ/N – 1)]
Wc1 = wp + wt/2 ;
Wc = Wc1/pi; % calculate the cutoff frequency
Disp(‘ cut off frequency = ‘);
Disp(Wc);
h = fir1(N-1,Wc, wn); % calculate the response of the filter
disp('Impulse Response of FIR filter=');
disp(h);
fiqure(1);
freqz(h); % plot the frequency response
figure(2);
n = 0:1:N-1;
stem(n,h); % plot the impulse response
xlabel(‘n’);
ylabel(‘h(n)’);
title(‘Impulse Response of Filter’);
OUTPUT:
enter the Pass band edge in radians = 0.375*pi
enter the stop band edge in radians = 0.5*pi
order of the FIR filter N = 65
Impulse response of FIR filter =
-0.0000 -0.0008 -0.0007 0.0004 0.0013 0.0006 -0.0014 -0.0022 0.0000
0.0032 0.0029 -0.0019 -0.0058 -0.0026 0.0056 0.0086 -0.0000 -0.0115 -
0.0101 0.0063 0.0190 0.0084 -0.0179 -0.0272 0.0000 0.0377 0.0346 -0.0231
-0.0769 -0.0398 0.1117 0.2938 0.3754 0.2938 0.1117 -0.0398 -0.0769 -0.0231
0.0346 0.0377 0.0000 -0.0272 -0.0179 0.0084 0.0190 0.0063 -0.0101 -0.0115
-0.0000 0.0086 0.0056 -0.0026 -0.0058 -0.0019 0.0029 0.0032 0.0000 -0.0022
-0.0014 0.0006 0.0013 0.0004 -0.0007 -0.0008 -0.0000
OUTCOME: Design and implementation of FIR filter for the given specifications is done
and the desired frequency response is obtained
10. How to find output of FIR filter for real time input signal?
In real time application entire input is not available and input signal has to be
processed online. Length of input signal depends on application. It can be long sequence
also. In FIR filter length of h[n] is finite. Output of the filter is always Linear Convolution of
impulse response with the input of the signal. To find output of digital FIR filter, Overlap
Add Method using FFT or Overlap Save Method using FFT is used.
OBJECTIVE:
1. To design the BUTTERWORTH filter to meet the given specification using the
MATLAB functions BUTTORD and BUTTER
2. Bilinear transformation for analog-to-digital filter conversion using function
“BILINEAR”
3. To design the CHEBYSHEV filter to meet the given specification using the
MATLAB function cheb1ord and cheby1
4. Bilinear transformation for analog-to-digital filter conversion using function “BILINEAR
5. To verify the result by theoretical calculations.
ALGORITHM:
1. Get the order of the filter
2. Find the filter coefficients
3. Plot the magnitude response
EXAMPLE:
Let’s design an analog Butterworth lowpass filter.
Steps to design an analog Butterworth lowpass filter.
1. Get the pass band and stop band edge frequencies
2. Get the pass band and stop band ripples
3. Get the sampling frequency
4. From the given specifications find the order of the filter N.
5. Round off it to the next higher integer.
6. Find the transfer function H(s) for ȍc = 1rad/sec for the value of N.
DEPT OF ECE, GCEM Page 91
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
Step 2: T=1
Step 5: poles
Therefore
PROGRAM:
clc; % clear screen
clear all; % clear screen
close all; % close all figure windows
fp = input(‘Enter the Pass band frequency in Hz = ' ); % input specifications
fs = input('Enter the Stop band frequency in Hz = ');
Fs = input(‘Enter the Sampling frequency in Hz = ‘);
Ap = input(' Enter the Pass band ripple in db:');
As = input('Enter theStop band ripple in db:');
wp=2*pi*Fp/ws; % Analog frequency
ws=2*pi*Fs/ws;
Up = 2*tan(wp/2);% Prewrapped frequency
Us = 2*tan(ws/2);
[n,wn]= buttord (Up,Us,Ap,As,'s'); %Calculate order and cutoff freq
Disp(‘order of the filter N =’);
disp(N);
disp(‘Normalized cut off frequency = ‘);
DEPT OF ECE, GCEM Page 93
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
disp(wn);
[num, den] = butter(n,wc,'s'); % analog filter transfer
[b,a] = bilinear(num, den,1); % conversion of analog filter to digital filter
Freqz(b,a,512,Fs); % frequency response of the filter
Printsys(b,a,’z’); % print the H(z) equation obtained on screen
OUTPUT:
enter the Pass band edge frequency in Hz = 500
enter the stop band frequency in Hz = 750
enter the sampling frequency in Hz = 2000
enter the pass band ripple n db = 3.01
enter the stop band attenuation in db =
15 order of the filter N = 2
Normalised cutoff frequency = 2.052
step 1:
rad
Step 2: T=1
Step 5: poles
Therefore
PROGRAM:
clc; % clear screen
clear all; % clear work space
close all; % close all figure windows
fp = input(‘Enter the Pass band frequency in Hz = ' ); % input specifications
fs = input('Enter the Stop band frequency in Hz = ');
Fs = input(‘Enter the Sampling frequency in Hz = ‘);
Ap = input(' Enter the Pass band ripple in db:');
As = input('Enter the Stop band ripple in db:');
wp=2*pi*Fp/ws; % Analog frequency
ws=2*pi*Fs/ws;
Up = 2*tan(wp/2); % Prewrapped frequency
Us = 2*tan(ws/2);
[N,wn]= cheb1ord (Up,Us,Ap,As,'s'); %Calculate order and cutoff freq
Disp(‘order of the filter N =’);
disp(N);
OUTPUT:
enter the Pass band edge frequency in Hz = 100
enter the stop band frequency in Hz = 500
enter the sampling frequency in Hz = 4000
enter the pass band ripple n db = 2
enter the stop band attenuation in db =
20 order of the filter N = 2
Normalised cutoff frequency = 0.1574
OUTCOME:IIR filter for the given specifications is designed and the magnitude and phase
plots are seen and verified
2) How to find output of IIR filter for real time input signal?
In real time application entire input is not available and input signal has to be
processed online. Length of input signal depends on application. It can be long sequence
also. In IIR filter length of h[n] is infinite. Output of the filter is always Linear Convolution
of impulse response with the input of the signal. To find output of digital IIR filter, Overlap
Add Method using FFT or Overlap Save Method using FFT cannot be used. Output of digital
IIR filter is calculated using difference equation recursively.
4) Explain how to find output of digital IIR filter in real time application.
In real time applications, output of IIR filter can be obtained by evaluating difference
equation.
6) Explain how to find output of digital IIR filter in real time application.
In real time applications, output of IIR filter can be obtained byevaluating difference
equation.
IIR filters can achieve a given filtering characteristic using less memory and
calculations than a similar FIR filter.
PART-B
INTRODUCTION TO DSP PROCESSORS (TMS320C6713DSK)
The C6713™ DSK builds on TI's industry-leading line of low cost, easy-to-use DSP Starter
Kit (DSK) development boards. The high-performance board features the TMS320C6713
floating-point DSP. Capable of performing 1350 million floating-point operations per second
(MFLOPS), the C6713 DSP makes the C6713 DSK the most powerful DSK development
board. The DSK is USB port interfaced platform that allows efficiently developing and
testing applications for the C6713. The DSK consists of a C6713-based printed circuit board
that will serve as a hardware reference design for TI’s customers’ products. With extensive
host PC and target DSP software support, including bundled TI tools, the DSK provides ease-
of-use and capabilities that areattractive to DSP engineers.
The C6713 DSK has a TMS320C6713 DSP onboard that allows full-speed verification of
code with Code Composer Studio. The C6713 DSK provides:
• A USB Interface
• SDRAM and ROM
• An analog interface circuit for Data conversion (AIC)
• An I/O port
• Embedded JTAG emulation support
Connectors on the C6713 DSK provide DSP external memory interface (EMIF) and
peripheral signals that enable its functionality to be expanded with custom or third party
daughter boards. The DSK provides a C6713 hardware reference design that can assist you in
the development of your own C6713-based products. In addition to providing a reference for
interfacing the DSP to various types of memories and peripherals, the design also addresses
power, clock, JTAG, and parallel peripheral interfaces.
The C6713 DSK includes a stereo codec. This analog interface circuit (AIC) has the
following characteristics:
• High-Performance Stereo Codec
¾
90-dB SNR Multibit Sigma-Delta ADC (A-weighted at 48 kHz)
¾
100-dB SNR Multibit Sigma-Delta DAC (A-weighted at 48 kHz)
¾
1.42 V – 3.6 V Core Digital Supply: Compatible With TI C54x DSP
• Core Voltages
¾
2.7 V – 3.6 V Buffer and Analog Supply: Compatible Both TI C54x
• DSP Buffer Voltages
¾
8-kHz – 96-kHz Sampling-Frequency Support
• Software Control Via TI McBSP-Compatible Multiprotocol Serial Port
¾
I 2 C-Compatible and SPI-Compatible Serial-Port Protocols
¾
Glueless Interface to TI McBSPs
The 6713 DSK is a low-cost standalone development platform that enables customers
to evaluate and develop applications for the TI C67XX DSP family. The DSK also serves as
a hardware reference design for the TMS320C6713 DSP. Schematics, logic equations and
application notes are available to ease hardware development and reduce time to market. The
DSK uses the 32-bit EMIF for the SDRAM (CE0) and daughter card expansion interface
(CE2 and CE3). The Flash is attached to CE1 of the EMIF in 8-bit mode.
An on-board AIC23 codec allows the DSP to transmit and receive analog signals.
McBSP0 is used for the codec control interface and McBSP1 is used for data. Analog audio
I/O is done through four 3.5mm audio jacks that correspond to microphone input, line input,
line output and headphone output. The codec can select the microphone or the line input as
the active input. The analog output is driven to both the line out (fixed gain) and headphone
(adjustable gain) connectors. McBSP1 can be re-routed to the expansion connectors in
software.
A programmable logic device called a CPLD is used to implement glue logic that ties
the board components together. The CPLD has a register based user interface that lets the
user configure the board by reading and writing to the CPLD registers. The registers reside at
the midpoint of CE1.The DSK includes 4 LEDs and 4 DIP switches as a simple way to
provide the user with interactive feedback. Both are accessed by reading and writing to the
CPLD registers.
An included 5V external power supply is used to power the board. On-board voltage
regulators provide the 1.26V DSP core voltage, 3.3V digital and 3.3V analog voltages. A
voltage supervisor monitors the internally generated voltage, and will hold the boards in reset
until the supplies are within operating specifications and the reset button is released. If
desired, JP1 and
JP2 can be used as power test points for the core and I/O power supplies. Code
Composer communicates with the DSK through an embedded JTAG emulator with a USB
host interface. The DSK can also be used with an external emulator through the external
JTAG connector.
• Right Click on libraries and select add files to Project and choose
C:\CCStudio_v3.3\C6000\cgtools\lib\rts6700.lib and click open
• Go to Project to Compile. Build, Rebuild All
• Go to file and load program and load “.out”file into the board.
• Go to Debug and click on run to run the program.
• Observe the output in output window.
• To see the Graph go to View and select time/frequency in the Graph, and give the correct
Start address provided in the program, Display data can be taken as per user.
OBJECTIVE: After completing this lab, student will be able to find the linear convolution
of two given sequences by implementing the C-code on the TMS320C6713 DSP processor.
THEORY: The linear convolution of two continuous time signals x(t) and h(t) is defined by
Where x(n) is the input signal and h(n) is the impulse response of the system.
In linear convolution length of output sequence is,Length (y(n)) = length(x(n)) + length(h(n))
–1
inrn,k;
OUTPUT:
1.000000 4.000000 10.000000 20.000000 25.000000 24.000000 16.000000
GRAPH:
OUTCOME: Linear convolution of the sequence is found and the code is implemented on
the DSP processor to verify the results.
DEPT OF ECE, GCEM Page 108
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
THEORY:Let x1(n) and x2(n) are finite duration sequences both of length N with DFT’s
X1(k) andX2(k). Convolution of two given sequences x1(n) and x2(n) is given by the
equation,
x3(n) = IDFT[X3(k)]
X3(k) = X1(k) X2(k)
OUTPUT:
10.000000 10.000000 10.000000 10.000000
GRAPH:
OUTCOME: Circular convolution of the sequence is found and the code is implemented on
the DSP processor to verify the results.
3. Differentiate between General purpose MPU(Micro Processor Unit) and DSP Processor
MPU DSP
1. General purpose 1. Arithmetic
2. Fixed internal format 2. Varying internal format
3. Single memory access 3. Multiple memory access
4. General addressing mode 4. Special addressing mode
5. Very large external memory 5. Very large internal memory
OBJECTIVE: To find the N point DFT of the sequence using TMS320C6713 DSP
processor.
GRAPH:
OUTCOME: DFT of the sequence is found and the code is implemented on the DSP
processor to verify the results.
AIM:To find Impulse response of a first order and second order system.
OBJECTIVE:To find the impulse response for the system using TMS320C6713 DSP
processor.
THEORY:
A discrete time system performs an operation on an input signal based on predefined criteria
to produce a modified output signal. The input signal x(n) is the system excitation, and y(n)
is the system response. The transform operation is shown as,
OUTPUT:
GRAPH:
OUTCOME: Impulse response and the output response of the first order and second order
system is found using TMS320C6713 DSK.
The factors that influence the choice of realization structure are computational
complexity, memory requirements, finite word length effects, parallel processing and
pipelining of computations
3. List the different types of structures for realizing FIR systems?
The different types of structures for realizing FIR systems are i) Direct form
realization, ii) Cascade realization, iii)Linear phase realization.
4. What is Recursive system?
If the output y(n) at time of a system depends on past output values then the system
is called Recursive system. The recursive systems are functions of past outputs, present and
past inputs.
5. What is Non-recursive system?
If the output y(n) at time of a system does not depends on past output values then
the system is called Recursive system. The recursive systems are functions of present and
past inputs.
AIM: Realization of fir filter (any type) to meet given specifications. The input can be a
signal from function generator/speech signal
OBJECTIVE: To design and realize FIR filter using CODEC and TMS3206713 DSP
processor.
THEORY:The FIR filters are of non-recursive type, whereby the present output sample is
depending on the present input sample and previous input samples. The transfer function of a
FIR causal filter is given by,
z-n
Where h(n) is the impulse response of the filter.
In the design of FIR filters most commonly used approach is using windows.The desired
jw
frequency response Hd(e ) of a filter is periodic in frequency and can be expanded in
Fourier series. The resultant series is given by,
hd(n)
This is known as Fourier series coefficients having infinite length. One possible way of
obtaining FIR filter is to truncate the infinite Fourier series at n = ± [(N-1)/2]Where N is the
length of the desired sequence.
The Fourier coefficients of the filter are modified by multiplying the infinite
impulse response with a finite weighing sequence w(n) called a window.
Where w(n)= w(-n) 0 for |n| [(N-1)/2]
=0 for |n| > [(N-1)/2]
After multiplying w(n)with hd(n), we get a finite duration sequence h(n) that satisfies the
desired magnitude response,
h(n) = hd(n) w(n) for |n| [(N-1)/2]
=0 for |n| > [(N-1)/2]
jw jw
The frequency response H(e ) of the filter can be obtained by convolution of Hd(e ) and
jw
W(e ) is given by,
jw
H(e )
jw jw jw
H(e ) = Hd(e ) * W(e )
{ static int cc = 1;
LED = cc;
if (cc == 0x03) cc = 0x05; // To Shift Pattern
else if (cc == 0x05) cc = 0x06;
else if (cc == 0x06) cc = 0x03;
else cc = 0x03; }
setpll200M(){
}
void read(){
int i = 0;
if (InChannel ==0){
InChannel =1;
LData=MCBSP_read(DSK6713_AIC23_DATAHANDLE); // Process Left Channel
for( i = 0; i <= FilLen-2; i++) LPrBuf[i] = LPrBuf[i+1];
LPrBuf[FilLen-1] = (float) LData;
FilOut = 0.0;
for( i = 0 ; i <= FilLen-1; i++ ) FilOut += (FilCo[i] * LPrBuf[i]);
LData = (int) (FilOut/16);
LDataArr[LWP++] = LData;
if (LWP >= 128) LWP =0;
}
else{
InChannel =0;
RData=MCBSP_read(DSK6713_AIC23_DATAHANDLE); // Process Right Channel
RDataArr[RWP++] = RData;
if (RWP >= 128) RWP =0;
}
}
void write(){
if (OtChannel == 1){
MCBSP_write(DSK6713_AIC23_DATAHANDLE,LDataArr[LRP++]); if
(LRP >= 128) LRP = 0;
DEPT OF ECE, GCEM Page 122
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
OtChannel = 0;
}
Else
{
MCBSP_write(DSK6713_AIC23_DATAHANDLE,RDataArr[RRP++]);
if (RRP >= 128) RRP = 0;
OtChannel = 1;
}
}
OUTCOME: Thus FIR filter is realized for given specification and the output is verified
through CRO for a given input signal.
transmission, speech processing etc. phase distortion cannot be tolerated and here linear
phase characteristic of FIR filter is useful.
4. What is the role of window in the design of FIR filter? Name the few types of windows.
FIR filter is designed by truncating infinite samples of hd[n] by using window function.
Examples of window function include, Hamming window,Bartlet Window, Hanning
window, Blackman window etc.
6. Explain how to find output of digital FIR filter in real time application.
In real time applications, output of FIR filter is obtained using overlap add method /
overlap save method.
OBJECTIVE:After completing this lab, student will be able to learn the technique for the
removal of nose from the mixed signals.
THEORY:In the real time systems every signal will get corrupted by the noise. To analyze
the noise we need to add the noise, a noise will be generated and added to the signal. A noise
of 3KHz is added to a tone of 400KHz then the noise is removed by using an high pass filter.
0.0814,0.2239,0.3074,0.4196,0.2065,0.0613,0.0321,0.2495,0.3044,0.2513,0.1193,0.3635,
0.2031,0.3801,0.0303,0.0733,0.3001,0.3507,0.2985,0.1186,0.0656,0.3612,0.3397,0.1294,
0.1102,0.1194,0.3025,0.2892,0.1845,0.1956,0.1073,0.2981,0.3682,0.2311,0.2244,0.2099,
0.0990,0.2220,0.2894,0.2813,0.2316,0.0653,0.2872,0.1048,0.1335,0.1639,0.1335,0.2752,
0.0262,0.2958,0.2226,0.2916,0.1142,0.2017,0.3252,0.2093,0.1280,0.4335,0.0627,0.1850,
0.4388,0.1821,0.1451,0.0544,0.3462,0.0154,0.0822,0.3031,0.1478,0.2130,0.2230,0.2897,
0.0397,0.2436,0.0428,0.3551,0.1458,0.3382,0.0957,0.2303,0.3804,0.0262,0.0356,0.0130,
0.2607,0.2102,0.0020,0.2581,0.1933,0.0047,0.0244,0.0922,0.3805,0.1092,0.1670,0.1447,
0.0477,0.3077,0.2124,0.2124,0.1879,0.1623,0.1219,0.2904,0.0953,0.1132,0.0502,0.4002,
0.3765,0.0096,0.1440,0.2291,0.1027,0.3114,0.2580,0.2089,0.1434,0.3168,0.3503,0.2551,
0.1064,0.3127,0.0588,0.1926,0.3867,0.1418,0.1538,0.4241,0.0659,0.1438,0.2286,0.0508,
0.2072,0.2740,0.1688,0.2416,0.0827,0.2314,0.3496,0.1934,0.3886,0.0894,0.0704,0.1493,
0.1843,0.1859,0.1252,0.2559,0.0035,0.1217,0.0717,0.0912,0.0251,0.2405,0.1436,0.1074,
0.0493,0.1552,0.2456,0.3565,0.0167,0.3025,0.0187,0.2772,0.2816,0.3582,0.0750,0.2422,
0.2169,0.1210,0.2634,0.2424,0.0600,0.1631,0.3293,0.1383,0.2371,0.1551,0.0338,0.1593,
0.3720,0.1812,0.0607,0.1999,0.1206,0.2411,0.1635,0.2727,0.2958,0.0758,0.0701,0.3565,
0.2880,0.0363,0.3726,0.2002,0.2003,0.2127,0.2768,0.3146,0.1400,0.0291,0.2936,0.1341,
0.3375,0.1544,0.3321,0.0716,0.0532,0.3473,0.0176,0.2671,0.2772,0.1617,0.1264,0.3688,
0.1475,0.1768,0.0764,0.1556,0.1539,0.3684,0.0979,0.1012,0.1261,0.2401,0.0153,0.3234,
0.0373,0.2052,0.0465,0.3405,0.3056,0.0901,0.2585,0.1746,0.2905,0.1795,0.3366,0.1744,
0.1618,0.2372,0.1421,0.3937,0.1927,0.0760,0.1248,0.2367,0.1159,0.0431,0.3350,0.2452,
0.1800,0.1234,0.1133,0.2164,0.1742,0.2783,0.0053,0.3180,0.2518,0.0386,0.3270,0.0609,
0.2273,0.2060,0.0477,0.0029,0.3182,0.3218,0.1980,0.0483,0.2532,0.0704,0.2688,0.1805,
0.0634,0.3304,0.2816,0.3470,0.0396,0.0822,0.3077,0.2812,0.2906,0.1659,0.1466,0.2278,
0.3560,0.3095,0.2671,0.1798,0.3339,0.1612,0.1967,0.2755,0.2225,0.2483,0.3013,0.2941,
0.0201,0.0807,0.1395,0.2114,0.0911,0.2137,0.1130,0.1435,0.2817,0.0310,0.0678,0.3107,
0.1429,0.0814,0.2429,0.3712,0.1587,0.2622,0.2169,0.1503,0.1834,0.3897,0.0846,0.1703,
0.2341,0.2631,0.3412,0.1344,0.0903,0.1993,0.0939,0.2847,0.1697,0.2312,0.2761,0.1753,
0.1190,0.0868,0.3864,0.0813,0.3023,0.2145,0.2764,0.3148,0.0086,0.1329,0.3952,0.2684,
0.3843,0.2181,0.0226,0.2681,0.1080,0.2249,0.2832,0.2395,0.2193,0.1590,0.0663,0.1474,
0.0163,0.2260,0.3727,0.0303,0.0235,0.3627,0.1062,0.0084,0.3246,0.0568,0.3485,0.0407,
0.1353,0.2338,0.2315,0.2545,0.2482,0.1510,0.0363,0.2882,0.0925,0.2603,0.3444,0.0445,
DEPT OF ECE, GCEM Page 126
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
0.4034,0.0162,0.3319,0.3212,0.0066,0.2010,0.3604,0.1120,0.3155,0.2390,0.3231,0.3301,
0.0269,0.1138,0.2520,0.1875,0.3778,0.2939,0.2133,0.1170,0.0977,0.3524,0.1664,0.3211,
0.0252,0.3361,0.0023,0.3513,0.3686,0.2151,0.0581,0.0777,0.1664,0.3211,0.0252,0.3361,
0.0023,0.3513,0.3686,0.2151};
floatRemNoise[47]={ -2.181030629062908e-002,8.917428211564256e-
003,1.182863130963947e-002,1.428453375748106e-002,1.403350814552515e-
002,1.039856067649067e-002,5.093274200275827e-003,1.421581262318843e-
003,2.515430936577368e-003,9.363053213111126e-003,1.949152112446623e-002,
2.722897698684972e-002,2.579943237700517e-002,1.050645191333675e-002,-
1.832163998604397e-002,-5.406194181033640e-002,-8.514869723584616e-002,-
9.887618777194764e-002,-8.633153232820758e-002,-4.651515024517261e-
002,1.217011610629542e-002,7.394838432088444e-002,1.206802616409422e-001,
1.380624377729094e-001,1.206802616409422e-001,7.394838432088444e-002,
1.217011610629542e-002,-4.651515024517261e-002,-8.633153232820758e-002,-
9.887618777194764e-002,-8.514869723584616e-002,-5.406194181033640e-002,-
1.832163998604397e-002,1.050645191333675e-002,2.579943237700517e-002,
2.722897698684972e-002,1.949152112446623e-002,9.363053213111126e-003,
2.515430936577368e-003,1.421581262318843e-003,5.093274200275827e-
003,1.039856067649067e-002,1.403350814552515e-002,1.428453375748106e-002,
1.182863130963947e-002,8.917428211564256e-003,-2.181030629062908e-002};
DSK6713_AIC23_Config config = { \
0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume */ \
0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume */\
main(){
int i;
LED=0x0;
for( i = 0 ; i < 100; i++ ) in_buffer[i]=0.0;
hCodec = DSK6713_AIC23_openCodec(0,
&config); IRQ_globalEnable();
IRQ_enable(IRQ_EVT_RINT1);
IRQ_enable(IRQ_EVT_XINT1);
}
void led(){
staticint cc = 1;
LED = cc;
if (cc == 0x03) cc = 0x05; else
if (cc == 0x05) cc = 0x06; else
if (cc == 0x06) cc = 0x03; else
cc = 0x03;
}
setpll200M(){
}
DEPT OF ECE, GCEM Page 128
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
void read(){
int i = 0;
float result;
floatInData;
floatInNoise;
floatInCorrup;
staticintNoiseIndex=0;
data=MCBSP_read(DSK6713_AIC23_DATAHANDLE);
if(data>=32768) data= data|0xffff0000;
InData = (Int32) (data)/16;
InData=data;
InNoise = PrNoise[NoiseIndex++]*4096 - 1024;
if (NoiseIndex == 600)
NoiseIndex = 0;
InCorrup = InData + InNoise;
for( i = 0; i <= (FiltLen-2); i++) in_buffer[i] = in_buffer[i+1];
in_buffer[FiltLen-1]=InCorrup;
result = 0;
for( i = 0 ; i <= (FiltLen-1); i++ ) result += RemNoise[i] *
in_buffer[i]; data = (Int32)(result*512);
InSigBuffer[LogIndex]= InData;
NoiseBuffer[LogIndex]= InNoise ;
CorrSigBuffer[LogIndex]= InCorrup;
RecovSigBuffer[LogIndex] = (float)data;
LogIndex++;
if (LogIndex ==
600) LogIndex =0;
}
void write(){
if (InitWait<1000){
InitWait++;
MCBSP_write(DSK6713_AIC23_DATAHANDLE, 0);
DEPT OF ECE, GCEM Page 129
DIGITAL SIGNAL PROCESSING LAB [10ECL57]
MCBSP_write(DSK6713_AIC23_DATAHANDLE, 0);
}
else{
MCBSP_write(DSK6713_AIC23_DATAHANDLE, data);
MCBSP_write(DSK6713_AIC23_DATAHANDLE, data);
}
OUTPUT:
Recovered signal can be seen as shown below
OUTCOME: Additive noise is removed from the corrupted signal using TMS320C6713
DSK.
VIVA QUESTIONS WITH ANSWER
1. What are the desirable characteristics of window Function?
(i) . The Fourier Transform of the window function W(ejw) should have a small
width of the linear Phase characteristic is important when the phase distortion is not
tolerable. FIR Filter can be designed with linear phase characteristic. In application like data
transmission, speech processing etc. phase distortion cannot be tolerated and here linear
phase characteristic of FIR filter is useful
5. Explain how to find output of digital FIR filter in real time application.
In real time applications, output of FIR filter is obtained using overlap add method /
overlap save method.