Dsplabmanual-By 22
Dsplabmanual-By 22
Syllabus
PCEC7304 Digital Signal Processing Laboratory
List of Experiments
1. Familiarization with the architecture of a standard DSP kit (Preferably TMS
320C6XXX DSP kit of Texas Instruments).
2. Generation of various types of waveforms (sine, cosine, square, triangular etc)
using MATLAB and DSP kit.
3. Linear convolution of sequences (without using the inbuilt conv. function in
MATLAB) and verification of linear convolution using DSP kit.
4. Circular convolution of two sequences and comparison of the result with the
result obtained from linear convolution using MATLAB and DSP kit.
5. i) Computation of autocorrelation of a sequence, cross correlation of two
sequences using MATLAB.
ii)Computation of the power spectral density of a sequence MATLAB also
implementing the same in a DSP kit.
6. Finding the convolution of a periodic sequence using DFT and IDFT in MATLAB.
7. i) Implementation of FFT algorithm by decimation in time and decimation in
frequency using MATLAB.
ii) Finding the FFT of a given 1 – D signal using DSP kit and plotting the same.
8. Design the implementation of FIR (low pass and high pass) Filters using windows
technique (rectangular window, triangular window and Kaiser Window) in
MATLAB and DSP kit.
9. Design the implementation of IIR (low pass and high pass) Filters (Butterworth
and Chebyshev) in MATLAB and DSP kit.
10. i) Convolution of long duration sequences using overlap add, overlap XXXXX
using MATLAB.
ii) Implementation of noise cancellation using adaptive filers on a DSP kit.
INDEX
MARKS/ TEACHER’S
EXPT. PAGE
DATE NAME OF THE EXPERIMENTS GRADES SIGNATURE
NO. NO.
AWARDED
Familiarization with the architecture of a
1. standard DSP kit (Preferably TMS 320C6XXX -
DSP kit of Texas Instruments).
Generation of various types of waveforms (sine,
-
2. cosine, square, triangular etc) using MATLAB
and DSP kit.
Linear convolution of sequences (without using
3. the inbuilt conv. function in MATLAB) and -
verification of linear convolution using DSP kit.
Circular convolution of two sequences and
comparison of the result with the result
4. -
obtained from linear convolution using
MATLAB and DSP kit.
i) Computation of autocorrelation of a
sequence, cross correlation of two sequences
using MATLAB.
5. -
ii)Computation of the power spectral density of
a sequence MATLAB also implementing the
same in a DSP kit.
Finding the convolution of a periodic sequence
6. -
using DFT and IDFT in MATLAB.
i) Implementation of FFT algorithm by
decimation in time and decimation in
-
7. frequency using MATLAB.
ii) Finding the FFT of a given 1 – D signal using
DSP kit and plotting the same.
Design the implementation of FIR (low pass and
high pass) Filters using windows technique
8. -
(rectangular window, triangular window and
Kaiser Window) in MATLAB and DSP kit.
Design the implementation of IIR (low pass and
9. high pass) Filters (Butterworth and Chebyshev) -
in MATLAB and DSP kit.
i) Convolution of long duration sequences using
overlap add, overlap XXXXX using MATLAB.
10. -
ii) Implementation of noise cancellation using
adaptive filers on a DSP kit.
INTRODUCTION TO MATLAB
Graphics: How to plot data, annotate graphs, and work with images.
Programming: How to use MATLAB to create scripts and functions, how to and
manipulate data structures.
Creating Graphical User Interfaces: Introduces GUIDE, the MATLAB graphical user
interface development environment.
Desktop Tools and Development Environment: Information about tools and the
MATLAB desktop.
MATLAB is an interactive system whose basic data element is an array that does not
require dimensioning. This allows you to solve many technical computing problems,
especially those with matrix and vector formulations, in a fraction of the time it would
take to write a program in a scalar noninteractive language such as C or Fortran.
The name MATLAB stands for matrix laboratory. MATLAB was originally written to
provide easy access to matrix software developed by the LINPACK and EISPACK
projects. Today, MATLAB engines incorporate the LAPACK and BLAS libraries,
embedding the state of the art in software for matrix computation.
MATLAB has evolved over a period of years with input from many users. In university
environments, it is the standard instructional tool for introductory and advanced courses
in mathematics, engineering, and science. In industry, MATLAB is the tool of choice for
high-productivity research, development, and analysis.
Development Environment. This is the set of tools and facilities that help you use
MATLAB functions and files. Many of these tools are graphical user interfaces. It
includes the MATLAB desktop and Command Window, a command history, an editor
and debugger, and browsers for viewing help, the workspace, files, and the search path.
The MATLAB Language. This is a high-level matrix/array language with control flow
statements, functions, data structures, input/output, and object-oriented programming
features. It allows both "programming in the small" to rapidly create quick and dirty
throw-away programs, and "programming in the large" to create large and complex
application programs.
Graphics.
MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well
as annotating and printing these graphs. It includes high-level functions for two-
dimensional and three-dimensional data visualization, image processing, animation, and
presentation graphics. It also includes low-level functions that allow you to fully
customize the appearance of graphics as well as to build complete graphical user
interfaces on your MATLAB applications.
The MATLAB Application Program Interface (API). This is a library that allows
you to write C and Fortran programs that interact with MATLAB. It includes facilities for
calling routines from MATLAB (dynamic linking), calling MATLAB as a computational
engine, and for reading and writing MAT-files.
MATLAB Desktop:
When you start MATLAB, the MATLAB desktop appears, containing tools (graphical
user interfaces) for managing files, variables, and applications associated with MATLAB.
The following illustration shows the default desktop. You can customize the arrangement
of tools and documents to suit your needs.
1. Aerospace Blockset*
2. Bioinformatics Toolbox*
3. CDMA Reference Blockset
4. Communications Blockset*
5. Communications Toolbox*
6. Control System Toolbox*
7. Curve Fitting Toolbox
8. Data Acquisition Toolbox*
9. Database Toolbox
10. Datafeed Toolbox*
11. Distributed Computing Toolbox*
12. Embedded Target for Infineon®
13. C166 Microcontrollers Embedded Target for Motorola® HC12
14. Embedded Target for Motorola® MPC555*
15. Embedded Target for OSEK/VDX®
16. Embedded Target for TI C2000TM DSP*
17. Embedded Target for TI C6000TM DSP*
18. Excel Link Filter Design HDL Coder*
19. Filter Design Toolbox*
20. Financial Derivatives Toolbox
21. Financial Time Series Toolbox
22. Financial Toolbox*
23. Fixed-Income Toolbox
24. Fixed-Point Toolbox*
25. Fuzzy Logic Toolbox
26. GARCH Toolbox*
27. Gauges Blockset*
28. Genetic Algorithm and Direct Search Toolbox
29. Image Acquisition Toolbox*
30. Image Processing Toolbox*
31. Instrument Control Toolbox*
32. Link for Code Composer StudioTM Development Tools*
33. Link for ModelSim®*
34. Mapping Toolbox*
35. MATLAB® Builder for COM (now part of MATLAB® Builder for .NET)
MATLAB® Builder for Excel MATLAB®
36. Builder for .NET (new product)
37. MATLAB® Compiler*
38. MATLAB® Distributed Computing Engine*
39. MATLAB® Report Generator
40. MATLAB® Web Server
41. Model-Based Calibration Toolbox*
42. Model Predictive Control Toolbox
43. Neural Network Toolbox*
Matrices and Magic Squares: Enter matrices, perform matrix operations, and
access matrix elements.
Expressions: Work with variables, numbers, operators, functions,
and expressions.
Working with Matrices: Generate matrices, load matrices, create matrices
from M-files and concatenation, and delete matrix
rows and columns.
More About Matrices and Arrays: Use matrices for linear algebra, work with
arrays, multivariate data, scalar expansion, and
logical subscripting, and use the find function.
Controlling Command Window Input and Output :Change output format,
suppress output, enter long lines, and edit at the
command line
Entering Matrices
The best way for you to get started with MATLAB is to learn how to handle matrices.
Start MATLAB and follow along with each example.
You can enter matrices into MATLAB in several different ways: Enter an explicit list
of elements. Load matrices from external data files. Generate matrices using built-in
functions. Create matrices with your own functions in M-files.
Start by entering Dürer's matrix as a list of its elements. You only have to follow a
few basic conventions: Separate the elements of a row with blanks or commas. Use a
semicolon, ; , to indicate the end of each row. Surround the entire list of elements
with square brackets, [ ].
Subscripts
The element in row i and column j of A is denoted by A(i,j). For example, A(4,2) is
the number in the fourth row and second column.
For our magic square, A(4,2) is 15. So to compute
the sum of the elements in the fourth column of A,
type
A(1,4) + A(2,4) + A(3,4) + A(4,4)
This produces
ans =
34
It is also possible to refer to the elements of a matrix with a single subscript, A(k).
This is the usual way of referencing row and
column vectors. But it can also apply to a fully two-
dimensional matrix, in which case the array is
regarded as one long column vector formed from
the columns of the original matrix. So, for our
magic square, A(8) is another way of referring to
the value 15 stored in A(4,2).
If you try to use the value of an element outside of the matrix, it is an error:
t = A(4,5)
Index exceeds matrix dimensions.
On the other hand, if you store a value in an element outside of the matrix, the size
increases to accommodate the newcomer:
X = A;
X(4,5) = 17
X=
16 3 2 13 0
5 10 11 8 0
9 6 7 12 0
4 15 14 1 17
The colon, :, is one of the most important MATLAB operators. It occurs in several
different forms. The expression
1:10
computes the sum of the fourth column. But there is a better way. The colon by itself
refers to all the elements in a row or column of a
matrix and the keyword end refers to the last row or
column. So
sum(A(:,end))
Why is the magic sum for a 4-by-4 square equal to 34? If the integers from 1 to 16 are
sorted into four groups with equal sums, that sum
must be
sum(1:16)/4
which, of course, is
ans =
34
Variables
MATLAB does not require any type declarations or dimension statements. When
MATLAB encounters a new variable name, it automatically creates the variable and
allocates the appropriate amount of storage. If the variable already exists, MATLAB
changes its contents and, if necessary, allocates new storage. For example,
num_students = 25
creates a 1-by-1 matrix named num_students and stores the value 25 in its single
element. To view the matrix assigned to any variable, simply enter the variable name.
Although variable names can be of any length, MATLAB uses only the first N
characters of the name, (where N is the number returned by the function
namelengthmax), and ignores the rest. Hence, it is important to make each variable
name unique in the first N characters to enable MATLAB to distinguish variables.
N = namelengthmax
N=
63
The genvarname function can be useful in creating variable names that are both valid
and unique.
Numbers
MATLAB uses conventional decimal notation, with an optional decimal point and
leading plus or minus sign, for numbers. Scientific notation uses the letter e to specify
a power-of-ten scale factor. Imaginary numbers use either i or j as a suffix. Some
examples of legal numbers are
3 -99 0.0001
9.6397238 1.60210e-20 6.02252e23
1i -3.14159j 3e5i
All numbers are stored internally using the long format specified by the IEEE
floating-point standard. Floating-point numbers have a finite precision of roughly 16
significant decimal digits and a finite range of roughly 10-308 to 10+308.
Functions
Some of the functions, like sqrt and sin, are built in. Built-in functions are part of the
MATLAB core so they are very efficient, but the computational details are not readily
accessible. Other functions, like gamma and sinh, are implemented in M-files.
There are some differences between built-in functions and other functions. For
example, for built-in functions, you cannot see the code. For other functions, you can
see the code and even modify it if you want.
The function names are not reserved. It is possible to overwrite any of them with a
new variable, such as
eps = 1.e-6
and then use that value in subsequent calculations. The original function can be
restored with
clear eps
Examples of Expressions
You have already seen several examples of MATLAB expressions. Here are a few
more examples, and the resulting values:
rho = (1+sqrt(5))/2
rho = 1.6180
a = abs(3+4i)
a= 5
z = sqrt(besselk(4/3,rho-i))
z = 0.3730+ 0.3214i
huge = exp(log(realmax))
huge = 1.7977e+308
toobig = pi*huge
toobig = Inf
EXPERIMENT No: 01
THEORY:
PROGRAMME: 1
(A)Unit Step Sequence
1. N=21;
2. n=0:1:N-1;
3. x=ones(1,N);
4. plot(x) % for continuous signal
5. stem(x) % for Discrete signal
1. N=21;
2.n=0:1:N-1;
3.x=0:N-1
4. plot(x) % for continuous signal
5.stem(x) % for Discrete signal
(C )Sinusoidal Signal
1. N=21;
2. n=0:1:N-1;
3. x=sin(0.1*pi*n);
4. plot(x) % for continuous signal
5. stem(x) % for Discrete signal
1. N=21;
2. n=0:1:N-1;
3. x= sin(0.1*pi*n) + cos(0.1*pi*n);
4. plot(x) % for continuous signal
5. stem(x) % for Discrete signal
1. N=21;
2. n=0:1:N-1;
3. x=exp(n);
4. plot(x) % for Continuous signal
5. stem(x) % for Discrete signal
Conclusion:
From the above experiment we have studied how different types of signal is generated
by the help of mat lab and the output graph is successfully plotted.
EXPERIMENT No: 02
THEORY: CONVOLUTION
Basic concept of the DSP is the input signal decomposed into simple additive
components, each of these components passed through a linear system and the resulting
output components are added. When impulse decomposition is used, the procedure can be
described by a mathematical operation called convolution.
BASIC DIAGRAM:
LINEAR
x[n]--------------→ SYSTEM ------------------→ y[n]
h[n]
Linear systems relates input, impulse and output signal. An input signal, x[n] enters a
linear system and reacts with an impulse signal h[n] resulting an output y[n]. Convolution
can also be represented by the following equation
N-1
It can also be defined as y[n] = ∑ x[k] h[n-k]
K=0
SMRUTI RANJAN NAYAK CENTURIAN INSTITUTE OF TECHNOLOGY
21
CONCLUSION:
From the above experiment it is clear that to find out the response of a signal
when a impulse is present.
EXPERIMENT No: 03
PROGRAMME :
CONCLUSION:
From the above experiment, it is quit clear that the result obtained from the linear
convolution and circular convolution is different and the circular convolution is not only
used for the aperiodic signal as well as periodic signal. And the output graph also plotted
successfully.
EXPERIMENT No: 04
Consider two data sequences, x[n],y[n] taken from the two corresponding waveforms
might be compared. If the two waveform varied similarly point to point, then the measure
of correlation is the sum of the products of the corresponding pairs of points.
N-1
rxy = ∑ x[n] y[n]
n=0
THEORY:
The power spectral density (PSD) is intended for continuous spectra. The integral
of the PSD over a given frequency band computes the average power in the signal over
that frequency band. In contrast to the mean-squared spectrum, the peaks in this spectra
do not reflect the power at a given frequency.
PROGRAMME :
1. Fs = 1000; t = 0:1/Fs:.296;
2. x = exp(i*2*pi*200*t)+randn(size(t));
3. h = spectrum.periodogram; % Instantiate a periodogram object.
4. psd(h,x,'Fs',Fs); % Plots the two-sided PSD by default.
CONCLUSION:
From the above experiment, the characteristic of cross & auto correlation is studied
successfully and the power over a band of frequency is calculated . the output graph also
plotted successfully.
EXPERIMENT No: 05
THEORY:
The discrete Fourier transform, or DFT, is the primary tool of digital signal processing.
The foundation of the Signal Processing Toolbox is the fast Fourier transform (FFT), a
method for computing the DFT with reduced execution time. Many of the toolbox
functions (including z-domain frequency response, spectrum and cepstrum analysis, and
some filter design and implementation functions) incorporate the FFT.
MATLAB provides the functions fft and ifft to compute the discrete Fourier transform
and its inverse, respectively. For the input sequence x and its transformed version X (the
discrete-time Fourier transform at equally spaced frequencies around the unit circle), the
two functions implement the relationships
In these equations, the series subscripts begin with 1 instead of 0 because of the
MATLAB vector indexing scheme, and
PROGRAMME :
1. clear
2. m = input('please Enter the size of x1(n) and x2(n):')
3. for i = 1:m
4. x1(i) = input('Please enter the values of x1:');
5. end
6. for i = 1:m
7. x2(i) = input('Please enter the values of x2:');
8. end
9. for k = 1:m
10. y1(k) = 0.0;
11. y2(k) = 0.0;
12. for n = 1:m
13. y1(k) = y1(k) + x1(n)*exp(-i*2*pi*(k-1)*(n-1)/m); % DFT
14. y2(k) = y2(k) + x2(n)*exp(-i*2*pi*(k-1)*(n-1)/m);
15. end
16. end
17. sprintf('X1(k) is:')
18. disp(y1)
19. sprintf('X2(k) is:')
20. disp(y2)
21. for k = 1:m
22. y(k) = y1(k)*y2(k);
23. end
24. sprintf('X(k) = X1(k)*X2(k) is:')
25. disp(y)
26. for n = 1:m
27. x3(n) = 0.0;
28. for k = 1:m
29. x3(n) = x3(n) + y(k)*exp(i*2*pi*(k-1)*(n-1)/m); % IDFT
30. end
31. end
32. for n = 1:m
33. x(n) = x3(n)/m;
34. end
35. sprintf('x(n) is:')
36. disp(x)
37. stem(x)
%5.(b)N-point IDFT
% Creating N-point IDFT function (Save as idft.m)
function xn=idft(Xk,N)
for k=0:1:N-1
for n=0:1:N-1
p=exp(i*2*pi*n*k/N);
x2(k+1,n+1)=p;
end
end
xn=(Xk*x2)./N;
%******************************************************
EXPERIMENT No: 06
THEORY: FFT
Compute fast Fourier transform (FFT) of input
The FFT block computes the fast Fourier transform (FFT) of each channel of an M-by-N
or length-M input, u, where M must be a power of two. To work with other input sizes,
use the Zero Pad block to pad or truncate the length-M dimension to a power-of-two
length.
The output of the FFT block is equivalent to the MATLAB fft function:
y = fft(u) % Equivalent MATLAB code
Thekth entry of the lth output channel, y(k, l), is equal to the kth point of the M-point
discrete Fourier transform (DFT) of the lth input channel:
This block supports real and complex floating-point and fixed-point inputs.
1. Butterfly operation
2. Double-signal algorithm
3. Half-length algorithm
The diagrams below show the data types used within the FFT block for fixed-point
signals. You can set the sine table, accumulator, product output, and output data types
displayed in the diagrams in the FFT block dialog as discussed in Dialog Box.
Inputs to the FFT block are first cast to the output data type and stored in the output
buffer. Each butterfly stage then processes signals in the accumulator data type, with the
final output of the butterfly being cast back into the output data type. A twiddle factor is
multiplied in before each butterfly stage in a decimation-in-time FFT, and after each
butterfly stage in a decimation-in-frequency FFT.
Select the optimization of the table of sine and cosine values for Speed or Memory. This
parameter is only available when the Twiddle factor computation parameter is set to
Table lookup. This parameter must be set to Speed for fixed-point signals.
Output in bit-reversed order.
Designate the order of the output channel elements relative to the ordering of the input
elements. When selected, the output channel elements are in bit-reversed order relative to
the input ordering. Otherwise, the output column elements are linearly ordered relative to
the input ordering.
SMRUTI RANJAN NAYAK CENTURIAN INSTITUTE OF TECHNOLOGY
36
Linearly ordering the output requires extra data sorting manipulation, so in some
situations it might be better to output in bit-reversed order.
Rounding mode
Select the rounding mode for fixed-point operations. The sine table values do not obey
this parameter; they always round to Nearest.
Overflow mode
Select the overflow mode for fixed-point operations. The sine table values do not obey
this parameter; they are always saturated.
Skip divide-by-two on butterfly outputs for fixed-point signals
When you select this parameter, no scaling occurs. When you do not select this
parameter, the output of each butterfly of the FFT is divided by two for fixed-point
signals.
Sine table
Choose how you will specify the word length of the values of the sine table. The
fraction length of the sine table values is always equal to the word length minus one:
When you select Same word length as input, the word length of the sine table values will
match that of the input to the block.
When you select Specify word length, you are able to enter the word length of the sine
table values, in bits.
The sine table values do not obey the Rounding mode and Overflow mode parameters;
they are always saturated and rounded to Nearest.
Product output
Use this parameter to specify how you would like to designate the product output word
and fraction lengths. Refer to Fixed-Point Data Types and Multiplication Data Types for
illustrations depicting the use of the product output data type in this block:
When you select Inherit via internal rule, the product output word length and fraction
length are automatically set according to the following equations:
When you select Same as input, these characteristics will match those of the input to the
block.
When you select Binary point scaling, you are able to enter the word length and the
fraction length of the product output, in bits.
When you select Slope and bias scaling, you are able to enter the word length, in bits, and
the slope of the product output. This block requires power-of-two slope and a bias of
zero.
Accumulator
Use this parameter to specify how you would like to designate the accumulator word and
fraction lengths. Refer to Fixed-Point Data Types and Multiplication Data Types for
illustrations depicting the use of the accumulator data type in this block:
When you select Inherit via internal rule, the accumulator word length and fraction length
are automatically set according to the following equations:
When you select Same as product output, these characteristics will match those of the
product output.
When you select Same as input, these characteristics will match those of the input to the
block.
When you select Binary point scaling, you are able to enter the word length and the
fraction length of the accumulator, in bits.
When you select Slope and bias scaling, you are able to enter the word length, in bits, and
the slope of the accumulator. This block requires power-of-two slope and a bias of zero.
Output
Choose how you will specify the output word length and fraction length:
When you select Inherit via internal rule, the output word length and fraction length are
automatically set according to the following equations:
When you select Same as input, these characteristics will match those of the input to the
block.
When you select Binary point scaling, you are able to enter the word length and the
fraction length of the output, in bits.
When you select Slope and bias scaling, you are able to enter the word length, in bits, and
the slope of the output. This block requires power-of-two slope and a bias of zero.
EXPERIMENT No: 07
AIM OF THE EXPERIMENT: Design of Filter ( Low pass, High pass, Band pass
using Hamming, Hanning,Rectangular, Kaiser
Window)
APPARATUS REQUIRED : 1. Computer System
2. Matlab Software
The Image Processing Toolbox supports one class of linear filter, the two-dimensional
finite impulse response (FIR) filter. FIR filters have several characteristics that make
them ideal for image processing in the MATLAB environment: FIR filters are easy to
represent as matrices of coefficients. Two-dimensional FIR filters are natural extensions
of one-dimensional FIR filters. There are several well-known, reliable methods for FIR
filter design. FIR filters are easy to implement. FIR filters can be designed to have linear
phase, which helps prevent distortion. Another class of filter, the infinite impulse
response (IIR) filter, is not as suitable for image processing applications. It lacks the
inherent stability and ease of design and implementation of the FIR filter.
Digital filters with finite-duration impulse response (all-zero, or FIR filters) have both
advantages and disadvantages compared to infinite-duration impulse response (IIR)
filters. FIR filters have the following primary advantages: They can have exactly linear
phase. They are always stable. The design methods are generally linear. They can be
realized efficiently in hardware. The filter startup transients have finite duration. The
primary disadvantage of FIR filters is that they often require a much higher filter order
than IIR filters to achieve a given level of performance. Correspondingly, the delay of
these filters is often much greater than for an equal performance IIR filter.
PROCESS:
Designing a Digital Filter
In this topic, you use a Digital Filter Design block to create low frequency noise, which
models the wind noise inside the cockpit:
If the model you created in Modifying Your Model is not open on your desktop, you can
open an equivalent model by typing
doc_gstut3
at the MATLAB command prompt. This model contains a Time Scope block that
displays the original sine wave and the sine wave with white noise added.
Open the Signal Processing Blockset library by typing dsplib at the MATLAB command
prompt.
Convert white noise to low frequency noise by introducing a Digital Filter Design block
into your model. This noise is modeled by the Random Source block. This noise contains
only certain frequencies and is more difficult to eliminate. In this example, you model the
low frequency noise using a Digital Filter Design block. This block uses the functionality
of the Filter Design and Analysis Tool (FDATool) to design a filter. Double-click the
Filtering library, and then double-click the Filter Designs library. Click-and-drag the
Digital Filter Design block into your model.
Set the Digital Filter Design block parameters to design a lowpass filter and create low
frequency noise. Open the Digital Filter Design dialog box by double-clicking the block.
Set the block parameters as follows:
Response Type = Lowpass
Units = Normalized (0 to 1)
wc = 0.5
Based on these parameters, the Digital Filter Design block designs a lowpass FIR filter
with 32 coefficients and a cutoff frequency of 0.5. The block multiplies the time-domain
response of your filter by a 32 sample Hamming window.
View the magnitude response of your filter in the Magnitude Response window by
clicking Design Filter at the bottom center of the dialog. The Digital Filter Design dialog
box should now look similar to the following figure.
You have now designed a digital lowpass filter using the Digital Filter Design block. In
the next topic, Adding a Digital Filter to Your Model, you integrate your filter into your
model.
In this topic, you add the lowpass filter you designed in Designing a Digital Filter to your
block diagram. If the model you created in Designing a Digital Filter is not open on your
desktop, you can open an equivalent model by typing
doc_gstut4 at the MATLAB command prompt.
Incorporate the Digital Filter Design block into your block diagram. Click-and-drag the
Digital Filter Design block, and place it between the Random Source block and the Sum
block.
Run your model and view the results in the Time Scope window. This window shows the
original input signal and the signal with low frequency noise added to it
Now digital filter is created and can be used to model the presence of colored noise in
signal.
EXPERIMENT No: 08
THEORY:
IIR Filter Design
The primary advantage of IIR filters over FIR filters is that they typically meet a given
set of specifications with a much lower filter order than a corresponding FIR filter.
Although IIR filters have nonlinear phase, data processing within MATLAB is
commonly performed "off-line," that is, the entire data sequence is available prior to
filtering. This allows for a noncausal, zero-phase filtering approach (via the filtfilt
function), which eliminates the nonlinear phase distortion of an IIR filter. The classical
IIR filters, Butterworth, Chebyshev Types I and II, elliptic, and Bessel, all approximate
the ideal "brick wall" filter in different ways. This toolbox provides functions to create all
these types of classical IIR filters in both the analog and digital domains (except Bessel,
for which only the analog case is supported), and in lowpass, highpass, bandpass, and
bandstop configurations. For most filter types, you can also find the lowest filter order
that fits a given filter specification in terms of passband and stopband attenuation, and
transition width(s). The direct filter design function yulewalk finds a filter with
magnitude response approximating a desired function. This is one way to create a
multiband bandpass filter. You can also use the parametric modeling or system
identification functions to design IIR filters. These functions are discussed in Parametric
Modeling. The generalized Butterworth design function maxflat is discussed in the
section Generalized Butterworth Filter Design.
PROGRAMME:
EXPERIMENT No: 09
THEORY:
PROGRAMME:
1. clear
2. ls = input('Please enter the size of the vector x(n)::::::')
3. m = input(' Please enter the size of the vector h(n)::::::')
4. for i = 1:ls
5. x(i) = input('Please enter the values of x:::');
6. end
7. for i = 1:m
8. h(i) = input('Please enter the values of h:');
9. end
10. lb = input('Please enter the size required for each block of tre vector x(n):::')
11. n = ceil(ls/lb);
12. sprintf('The number of block is "n" =')
13. disp(n)
14. for i = 1:n*lb
15. if i>ls
16. x(i) = 0.0;
17. end
18. end
19. for i = 1:lb+m-1
20. if i<=m
21. h1(i) = h(i);
22. else
23. h1(i) = 0.0;
24. end
25. end
26. disp(h1)
27. for s=1:n
28. for i = 1:lb+m-1
29. if i<=lb
30. y(s,i) = x(lb*(s-1) + i);
31. else
SMRUTI RANJAN NAYAK CENTURIAN INSTITUTE OF TECHNOLOGY
52
Input:
X=[ 1 2 -1 2 3 -2 -3 -1 1 1 2 -1]
H=[ 1 2 1 1]
Output:
Y= [1 4 4 3 8 5 -2 -6 -6 – 4 5 1 1 -1]
EXPERIMENT No: 10
THEORY:
PROCEDURE:
PROCEDURE FOR MICRO-5416 PROCESSOR
This is the software where we can convert our ASM( assembly file) to ASC (ascii
code). Ten it will downloaded to the 5416 Kit. These are the steps to be followed.
2. When ever it open, it shows one massage like “ VI hardware found in COM-1’.
It means your kit and PC are communicating with each other properly.
3. If it is not showing, click on serial menu→ port setting→ Auto detect, before
4. In the project menu click on the New Project for creating a new project. Give
5. Then go to the file menu click on new file , in that click on asm file.
6. Then editor window will appear, in which we can type our asm file.
7. The alternative method is to copy your asm file to this location which is stored in
another location.
8. After typing the asm file save the file by clicking save option in file menu with
9. Then add the file to the project by clicking on the project menu then on add file
to project.
10. Do the same procedure to add the cmd file to project i.e Micro5416.cmd file.
11. Then select build from project menu. It is for building your asc file. If any error
occurs it shows in the error massage box below the asm file.
12. After successful built , it shows confirmation massage. Now your asc file is
14. After downloading the asc file go to serial menu click on communication
window.
15. In communication window substitute your input at a location given in asm file
16. you can enter multiple value one by one by pressing enter key.
17. To come out of it press dot(.) mark after the desired last location.
19. Then Reset your Kit, go to your output location by typing SD <output
This software is used to convert the “C” code file to *.out file which will later
converted to asc file for downloading. After installing the CCS complier you will find
two icons in the desktop. (i) CCS 5000 (ii) Setup for CCS 5000
1. First click on Setup for CCS5000 icon , it will open a window in that select
Platform as 54×× and type as Simulator. Then select the 5416 device simulator
and click Import. Now the 5416 device simulator was added to your system.
2. Then Select save &quit. It will ask for start of CCS compiler click ok. Then the
code composer studio will open automatically.
3. For creating a new project click the Project menu and select the new project, then
give the project name with the extension (*.pjt) click finish. The default directory
is c:\ ti\ myprojects.
4. For creating a new file click the file menu and click new and select the source file.
5. Type your c file in the editor window and save it by clicking save from file menu.
6. Then give the file name as *.c file and click save option.
7. Go to project menu select add file to the project and add your *.c file to the
project.
8. Do the same steps to add the cmd file to the project( MICRO5416.cmd).
9. After adding the *.c & *.cmd file , go to project menu click on the build option
for compile the project.
10. after successful compilation the *.out file is created in the default directory i.e
c:\ ti\ myprojects\*.pjt \debug\*.out.
11. Then open the 5416 debugger, in that click on tool → convert *.out to *.asc
option.
12. Then click on browse, select your *.out file and convert . Then *.asc file is also
created in the same directory.
13. Then click on serial menu and select load program, browse for the *.asc file click
ok.
14. After downloading click on serial menu → communication window for execution.
CIRCULAR CONVOLUTION
main()
{
unsigned int xval[255], hval[255], outval[255], n1, n2, i, j;
unsigned int *outvaladdr;
outvaladdr = (unsigned int *) 0x9200; // Starting Address of Input and outvalput
n1 = 4; // Fixed
n2 = 4;
for(i=0;i<n1;i++)
{
xval[i] = *(outvaladdr + i);
hval[i] = *(outvaladdr + i + n1);
outval[i] = 0;
}
i = xval[3]; // To swap the sequence
xval[3] = xval[1];
xval[1] = i;
outval[0] = (xval[0] * hval[0]) + (xval[1] * hval[1]) + (xval[2] * hval[2]) + (xval[3] *
hval[3]);
outval[1] = (xval[0] * hval[3]) + (xval[1] * hval[0]) + (xval[2] * hval[1]) + (xval[3] *
hval[2]);
outval[2] = (xval[0] * hval[2]) + (xval[1] * hval[3]) + (xval[2] * hval[0]) + (xval[3] *
hval[1]);
outval[3] = (xval[0] * hval[1]) + (xval[1] * hval[2]) + (xval[2] * hval[3]) + (xval[3] *
hval[0]);
for(i=0;i<n1;i++)
*(outvaladdr + n1 + n2 + i) = outval[i];
while(1);
}
Double-click the Sine Wave block. The Block Parameters: Sine Wave dialog box opens.
Set the block parameters as follows:
Amplitude = 1
Frequency = [15 40]
Phase offset =0
Sample time = 0.001
Samples per frame = 128
Based on these parameters, the Sine Wave block outputs two, frame-based sinusoidal
signals with identical amplitudes, phases, and sample times. One sinusoid oscillates at 15
Hz and the other at 40 Hz.
Save these parameters and close the dialog box by clicking OK.
Double-click the Matrix Sum block. The Block Parameters: Matrix Sum dialog box opens.
Set the Sum along parameter to Rows, and then click OK.
Since each column represents a different signal, you need to sum along the individual rows
in order to add the values of the sinusoids at each time step.
Double-click the Complex to Magnitude-Angle block. The Block Parameters: Complex to
Magnitude-Angle dialog box opens.
Set the Output parameter to Magnitude, and then click OK.
This block takes the complex output of the FFT block and converts this output to
magnitude.
Double-click the Vector Scope block.
Set the block parameters as follows, and then click OK:
Click the Scope Properties tab.
Input domain = Frequency
Click the Axis Properties tab.
Frequency units = Hertz (This corresponds to the units of the input signals.)
Frequency range = [0...Fs/2]
Select the Inherit sample time from input check box.
Amplitude scaling = Magnitude
Run the model.
The scope shows the two peaks at 0.015 and 0.04 kHz, as expected
Double-click the Sine Wave block. The Block Parameters: Sine Wave dialog box
opens.
Set the block parameters as follows:
Amplitude = 1
Frequency = [15 40]
Phase offset = 0
Sample time = 0.001
Samples per frame = 128
Based on these parameters, the Sine Wave block outputs two, frame-based
sinusoidal signals with identical amplitudes, phases, and sample times. One sinusoid
oscillates at 15 Hz and the other at 40 Hz.
Save these parameters and close the dialog box by clicking OK
Double-click the Matrix Sum block. The Block Parameters: Matrix Sum dialog box
opens.
Set the Sum along parameter to Rows, and then click OK.
Since each column represents a different signal, you need to sum along the
individual rows in order to add the values of the sinusoids at each time step.
Double-click the FFT block. The Block Parameters: FFT dialog box opens.
Select the Output in bit-reversed order check box., and then click OK.
Double-click the IFFT block. The Block Parameters: IFFT dialog box opens.
Set the block parameters as follows, and then click OK:
Select the Input is in bit-reversed order check box.
Select the Input is conjugate symmetric check box.
Because the original sinusoidal signal is real valued, the output of the FFT block is
conjugate symmetric. By conveying this information to the IFFT block, you
optimize its operation.
Note that the Sum block subtracts the original signal from the output of the IIFT
block, which is the estimation of the original signal.
Double-click the Vector Scope block.
Set the block parameters as follows, and then click OK:
Click the Scope Properties tab.
Input domain = Time
Run the model.