Sei sulla pagina 1di 27

Lab Manual EEE324 Digital Signal Processing

Experiment No.1 INTRODUCTION TO DSP STARTER KIT


TMS320C6713 DSK & OVERVIEW OF DT SIGNALS &
SYSTEMS USING MATLAB
1.1 Objectives
In this lab students will learn about basics of DSP kit and MATLAB usage for discrete time signal
and systems.
1.2 Equipment Required
✓ MATLAB® R2015b or above
✓ Operating System - Windows XP
✓ CC STUDIO 3
✓ DSK 6713 DSP Trainer kit.
✓ USB Cable
✓ Power supply
1.3 Pre-Lab
A discrete-time system has discrete-time inputs and outputs, and components of the system are
also in discrete-time. Example: A summer.
1.3.1 Discrete Time Basic Signals
The discrete-time unit step function is defined as
0 𝑛<0
𝑢(𝑛) = {
1 𝑛≥0
It differs from the continuous time version in that it is 1 even at 𝑛 = 0, whereas the continuous-
time version is undefined. It is not defined in MATLAB, but it can be easily defined in MATLAB
with a one-line command:
>> unitStep = @(n) double(n >= 0);
The discrete-time equivalent of the unit impulse function is known as the unit pulse function or
the Kronecker Delta function. It is defined as
1 𝑛=0
𝛿(𝑛) = {
0 𝑛≠0
It is implemented in MATLAB as kroneckerDelta(n).
1.3.2 Discrete Time Systems
The function of a discrete time system is to process a given input sequence to generate an output
sequence. In most applications, the discrete time system used is SISO system. Mathematically, a
discrete time system is described as an operator T{.} that takes a sequence 𝑥(𝑛) and transforms it
into another sequence 𝑦(𝑛). That is
𝑦(𝑛) = 𝑇{𝑥(𝑛)}
1.3.3 Transformation of Time Variable
Possible transformation operations of time variable are:
• Time Reversal

Department of Electrical and Computer Engineering 1


Lab Manual EEE324 Digital Signal Processing
• Time Scaling
• Time Shifting
If you have multiple transformations in a single function, you will apply time shifts first, then time
scaling or reversal. For example, to get 𝑔(𝑛) = 𝑓(−3𝑛 + 5), you would follow these steps:
𝑓1 (𝑛) = 𝑓(𝑛 + 5)
𝑓2 (𝑛) = 𝑓1 (3𝑛) = 𝑓(3𝑛 + 5)
𝑔(𝑛) = 𝑓2 (−𝑛) = 𝑓(−3𝑛 + 5)
You can switch the last two steps, but the time shift must come first.
>> f = @(n) sin(20*n) .* exp(-n);
>> n = -10:10;
>> figure(1); stem(n, f(n))
>> figure(2); stem(n, f(-n))
>> figure(3); stem(n, f(2 * n))
>> figure(4); stem(n, f(n / 2))
>> figure(5); stem(n, f(n – 2))
>> figure(2); stem(n, f(n + 2))
1.3.4 Classes of Signals
1.3.4.1 Periodic Signals
A discrete-time signal 𝑥(𝑛) is periodic if there is a positive integer 𝑁 such that
𝑥(𝑛) = 𝑥(𝑛 + 𝑁) ∀𝑁 ∈ ℤ
2𝜋𝑀
A discrete-time signal 𝑥(𝑛) = cos(𝜔𝑛 + 𝜙) is only periodic for 𝜔 = for some 𝑀, 𝑁 ∈ ℤ.
𝑁

1.3.4.2 Causal Signals


A signal 𝑥(𝑛) is called causal if 𝑥(𝑛) = 0 ∀𝑛 < 0. A signal that holds nonzero values for both
positive and negative arguments is called non-causal. Finally, a signal satisfying 𝑥(𝑛) = 0 ∀𝑛 >
0 is called anti-causal.
1.3.4.3 Even and Odd Signals
A signal 𝑥(𝑛) is called even if 𝑥(−𝑛) = 𝑥(𝑛) ∀𝑛 and odd if 𝑥(−𝑛) = −𝑥(𝑛) ∀𝑛. If a signal is
neither even nor odd, it can be split into even and odd parts:
𝑥(𝑛) + 𝑥(−𝑛)
𝑥𝑒 (𝑛) =
2
𝑥(𝑛) − 𝑥(−𝑛)
𝑥𝑜 (𝑛) =
2
Clearly, 𝑥(𝑛) = 𝑥𝑒 (𝑛) + 𝑥𝑜 (𝑛).
1.3.4.4 Energy and Power Signals
For a discrete-time signal, the energy & power of a signal 𝑥(𝑛) is defined by:
∞ 𝑁
1
𝐸𝑥 = ∑ |𝑥(𝑛)|2 , 𝑃𝑥 = lim ∑ |𝑥(𝑛)|2
𝑁→∞ 2𝑁 + 1
𝑛=−∞ 𝑛=−𝑁

For a periodic discrete-time signal 𝑥(𝑛) with a period 𝑁,

Department of Electrical and Computer Engineering 2


Lab Manual EEE324 Digital Signal Processing
𝑛0 +𝑁−1
1
𝑃𝑥 = ∑ |𝑥(𝑛)|2
𝑁
𝑛=𝑛0

where 𝑛0 ∈ ℤ. A signal 𝑥(𝑛) is called an energy signal if 𝐸𝑥 is finite and a power signal if 𝑃𝑥 is
finite and 𝑃𝑥 ≠ 0.
1.3.4.5 Deterministic and Stochastic Signals
A function is called deterministic if, every time it is realized, it has the same output. For example,
the unit step function 𝑢(𝑛) will always be the same. In contrast, a random signal has different
values every time it is realized.
1.3.5 Properties of Systems
1.3.5.1 Causal and Non-Causal Systems.
A system is deemed causal if, at any point in time, its output does not depend on future values of
inputs. For example,
>> y = @(x, n) x(n) + x(n - 1);
is a causal system, because at any given time 𝑛0 , the value of its output only depends on values
of 𝑛 such that 𝑛 ≤ 𝑛0 . However,
>> y = @(x, n) x(n) + x(n + 1);
is non-causal, because its output depends on future values of the input signal.
1.3.5.2 Static (Memory-less) and Dynamic (with Memory) Systems
A static system is one that has no memory. Its output at any time depends only on the current value
of the input. For example:
𝑆{𝑥(𝑛)} = 𝑥(𝑛)2
A dynamic system is a system where the output can depend not only on the current value of the
input but may also past and future values. For example,
1
𝑆{𝑥(𝑛)} = (𝑥(𝑛 − 1) + 2𝑥(𝑛) + 𝑥(𝑛 + 1))
2
1.3.5.3 Linear Systems
Additive System: An additive system is one for which the following property holds:
𝑆{𝑥1 (𝑛) + 𝑥2 (𝑛)} = 𝑆{𝑥1 (𝑛)} + 𝑆{𝑥2 (𝑛)} ∀𝑥1 , 𝑥2 , 𝑛
Homogenous System: A homogenous system is one for which the following property holds:
𝑆{𝑎𝑥(𝑛)} = 𝑎𝑆{𝑥(𝑛)} ∀𝑥, 𝑎, 𝑛
Linearity of a System: A system is called linear if it satisfies both the additivity property and the
homogeneity property. If either additivity or homogeneity fails, then system is nonlinear system.
1.3.5.4 Shift-Variant and Shift-Invariant Systems
A system is called a shift-invariant if a shift in the input results in the same amount of shift in the
output. Concretely, if 𝑆{𝑥(𝑛)} = 𝑦(𝑛), then a system is called shift invariant if and only if
𝑆{𝑥(𝑛 − 𝑛0 )} = 𝑦(𝑛 − 𝑛0 ) ∀𝑥, 𝑛0

Department of Electrical and Computer Engineering 3


Lab Manual EEE324 Digital Signal Processing
If the independent variable of the system is time, then the system is also called time invariant. A
system that is not shift-invariant or time-invariant is called shift-variant or time-variant. For an
LTI system the liner operator and shift operators are reversible.
1.3.5.5 Stable and Unstable Systems
A system is called stable if the following principle holds:
|𝑆{𝑥(𝑛)}| ≤ 𝑏 ∀𝑛, 𝑥
for 𝑏 ∈ ℝ+ given that |𝑥(𝑛)| ≤ 𝑎 ∀𝑛 and 𝑎 ∈ ℝ+ . A BIBO LTI system is stable if its impulse
response decays to zero as n approaches to infinity.
1.4 In-Lab
1.4.1 Introduction to DSP Starter Kit TMS320C6713 DSK
The high-performance board features the TMS320C6713 floating-point DSP. Capable of
performing 1350 million floating point operations per second, the C6713 DSK the most powerful
DSK development board. The DSK is USB port interfaced platform that allows to efficiently
develop and test applications for the C6713. With extensive host PC and target DSP software
support, the DSK provides ease-of-use and capabilities that are attractive to DSP engineers. The
6713 DSP Starter Kit (DSK) is a low-cost platform which lets its customers to evaluate and develop
applications for the Texas Instruments C67X DSP family. The primary features of the DSK are:
• 225 MHz TMS320C6713 Floating Point DSP
• AIC23 Stereo Codec
• Four Position User DIP Switch and Four User LEDs
• On-board Flash and SDRAM
TI‟s Code Composer Studio development tools are bundled with the 6713DSK providing the user
with an industrial-strength integrated development environment for C and assembly programming.
Code Composer Studio communicates with the DSP using an on-board JTAG emulator through a
USB interface. On- chip peripherals include a 32-bit external memory interface (EMIF) with
integrated SDRAM controller, two multi-channels buffered serial ports (McBSPs), two on-board
timers and an enhanced DMA controller (EDMA).
External accesses are done through the EMIF which can connect to both synchronous and
asynchronous memories. The EMIF signals are also brought out to standard TI expansion bus
connectors so additional functionality can be added on daughter card modules. DSPs are frequently
used in audio processing applications so the DSK includes an on-board codec called the AIC23.
The job of the AIC23 is to code analog input samples into a digital format for the DSP to process,
then decode the data coming out of the DSP to generate the processed analog output. Digital data
is sent to and from the codec on McBSP1.
The DSK has 4 LEDs and 4 DIP switches that allow users to interact with programs through simple
LED displays and user input on the switches. The DSK implements the logic necessary to tie board
components together in a programmable logic device called a CPLD. In addition to random glue
logic, the CPLD implements a set of 4 software programmable registers that can be used to access
the on-board LEDs and DIP switches as well as to control the daughter card interface.

Department of Electrical and Computer Engineering 4


Lab Manual EEE324 Digital Signal Processing

Figure 1-1: TMS320C6713 DSK Overview Block Diagram

Figure 1-2: TMS320C6713 DSK Board


1.4.1.1 DSK hardware installation:
• Power off the PC
• Connect the supplied USB port cable to the board
• Connect the other end of the cable to the USB port of PC

Department of Electrical and Computer Engineering 5


Lab Manual EEE324 Digital Signal Processing
• Plug the other end of the power cable into a power outlet
• Plug the power cable into the board
• The user LEDs should flash several times to indicate board is operational. When you
connect your DSK through USB for the first time on a Windows loaded PC the new
hardware found wizard will come up. So, install the required drivers.
• Install the CCS software for C6713 DSK as it contains the required drivers for C6713 DSK.
1.4.1.2 Troubleshooting DSK Connectivity
If Code Composer Studio IDE fails to configure your port correctly, perform the following steps:
• Test the USB port by running DSK Port test from the start menu
• Use Start → Programs → Texas Instruments → Code Composer Studio → Code Composer
Studio
• C6713 DSK Tools → C6713 DSK Diagnostic Utilities. The Diagnostics window will
appear

Figure 1-3: C6713 DSK Diagnostic


• Select Start Option so that Utility Program can test the board
• After testing Diagnostic Status, you will get a PASS
If the board still fails to detect go to CMOS setup, enable the USB Port Option (The required
device drivers will load along with CCS Installation)
1.4.1.3 CCS Software Installation
You must install the hardware before you install the software on your system. For installation run
setup.exe and choose the option to install Code Composer Studio. If you already have C6000 CC
Studio IDE installed on your PC, do not install DSK software. CC Studio IDE full tools supports
the DSK platform. If not, then respond to the dialog boxes as the installation program runs. The
Installation program automatically configures CC Studio IDE for operation with your DSK and
creates a CC Studio IDE DSK icon on your desktop.
1.4.1.4 Introduction to Code Composer Studio (CSS)
Code Composer is fully integrated development environment (IDE) with DSP-specific
functionality. With a familiar environment like MS-based C++, Code Composer lets you edit,

Department of Electrical and Computer Engineering 6


Lab Manual EEE324 Digital Signal Processing
build, debug, profile and manage projects from a single unified environment. Other unique features
include graphical signal analysis, injection/extraction of data signals via file I/O, multi-processor
debugging, automated testing and customization via C interpretive scripting language and much
more. Code composer features include:
• IDE & Debug IDE
• Advanced watch windows
• Integrated editor
• File I/O, probe points, and graphical algorithm scope probes
• Advanced graphical signal analysis
• Interactive profiling
• Automated testing and customization via scripting
• Visual project management system
• Compile in the background while editing and debugging
• Multi-processor debugging
• Help on the target DSP
1.4.1.5 Useful Files
You will be working with several files with different extensions. They include:
• file.pjt: to create and build a project named file.
• file.c: C source program.
• file.asm: assembly source program created by the user, by the C compiler or by the linear
optimizer.
• file.sa: linear assembly source program. The linear optimizer uses file.sa as input to
produce an assembly program file.asm.
• file.h: header support file.
• file.lib: library file, such as the run-time support library file rts6701.
• lib.file.cmd: linker command file that maps sections to memory.
• file.obj: object file created by the assembler.
• file.out: executable file created by the linker to be loaded and run on the processor.
1.4.1.6 Getting Started with Code Composer Studio Project
1. Click on CC Studio on the desktop
2. To create project, Project → New
3. Give project name and click on finish.

Figure 1-4: Project Creation

Department of Electrical and Computer Engineering 7


Lab Manual EEE324 Digital Signal Processing
4. Click on File → New →Source File to write the source code. Enter the source code and
save the file with “.C” extension.
5. Add the c program to the project as: Project → Add files to project→ <source file>

Figure 1-5: Add Files to Project


6. Add rts6700.lib to the project as: Project → Add files to project → rts6700.lib. The path
is: C:\CCstudio\ c6000\ lib\ rts6700.lib. Select object & library files (*.o, *.l).

Figure 1-6: Add Library Files to Project


7. Add hello.cmd to the project as: Project → Add files to project → hello.cmd. The path is:
C:\CCstudio \ tutorial\dsk6713\ hello1 \ hello.cmd. Select linker command file (*.cmd).

Figure 1-7: Add .cmd File to Project


8. Compile the project as: Project → Compile file (or hit ctrl+F7)

Department of Electrical and Computer Engineering 8


Lab Manual EEE324 Digital Signal Processing
9. Build or link the project as: Project→ build (or hit F7), which will create a .out file in
project folder
10. Load the program as: File → Load Program → <select the .out file in debug folder in
project folder>. This will load our program into the board.
11. Run the program as: Debug → Run
12. Observe the output in output window
13. To see the graph: View → select time/frequency in the Graph. Give the correct start address
which is provided in the program
1.4.1.7 Quick Tests of the DSK
1. On power on, a power on self-test (POST) program, stored by default in the on-board
flash memory, uses a routine from the board support library (BSL) to test the DSK. The
source file for this program, post.c, is stored in folder:
c:\CCStudio_v3.1\examples\dsk6713\bsl\post.
It tests the internal, external, flash memory, two multichannel buffered serial ports
(McBSP), DMA, on-board codec and LEDs. If all tests are successful, all four LEDs will
blink three times and stop simultaneously. During the testing of the codec, a 1-KHz tone
is generated for 1 sec.
2. Launch CC Studio from the icon on the desktop. A USB enumeration process will take
place and the Code Composer Studio window will open. Click Debug →Connect and you
should see the message “The target is now connected” appearing for a few seconds in the
bottom left corner of the CCS window.
3. Click on GEL→Check DSK →Quick Test. The Quick Test can be used for confirmation
of correct operation and installation. A message of the following form should then be
displayed in a new window within CCS: Switches: 15, Board Revision: 2, CPLD
Revision: 2.
The values being displayed following the label Switches, reflects the state of the four DIP
switches on the edge of the DSK circuit board. A value of 15 corresponds to all four
switches in the up position. Programs running on the DSK can check/test the state of the
DIP switches and react accordingly. The values displayed following the labels Board
Revision and CPLD Revision depend on the type and revision of the DSK circuit board.
1.5 In-Lab Tasks
1. Plot the function: 𝑥[𝑛] = 0.9−𝑛 where −10 ≤ 𝑛 ≤ 10
a) 𝑥1 [𝑛] = 𝑥[−𝑛]
b) 𝑥2 [𝑛] = 𝑥[𝑛 − 9]
c) 𝑥3 [𝑛] = 𝑥[𝑛 + 9]
d) 𝑥4 [𝑛] = 𝑥[3𝑛]
𝑛
e) 𝑥5 [𝑛] = 𝑥 [ ]
3
2. Plot the even and odd parts of 𝑥[𝑛] = cos[𝑛] + sin[𝑛].
3. For the system defined below describe if the system is Causal/Non-Causal, Linear/Non-
Linear, Static/Dynamic, Shift-invariant/Shift-variant and Stable/Unstable.
𝑦[𝑛] = 𝑥[𝑛] + 𝑛𝑥[𝑛 + 1], 𝑥1 [𝑛] = 𝑒𝑥𝑝[−𝑛] and 𝑥2 [𝑛] = sin[𝑛]
1.6 Post-Lab
1. Plot the function: 𝑥[𝑛] = {⋯ 0 − 1 − 0.5 0.5 1 1↑ 1 1 0.5 0 0 ⋯ }
a) 𝑥1 [𝑛] = 𝑥[3 − 𝑛]
b) 𝑥2 [𝑛] = 𝑥[𝑛 − 4]

Department of Electrical and Computer Engineering 9


Lab Manual EEE324 Digital Signal Processing
c) 𝑥3 [𝑛] = 𝑥[3𝑛 + 1]
1 1
d) 𝑥4 [𝑛] = 2 𝑥[𝑛] + 2 (−1)2 𝑥[𝑛]
e) 𝑥5 [𝑛] = 𝑥[(𝑛 − 1)2 ]
2. For the system defined below describe if the system is Causal/Non-Causal, Linear/Non-
Linear, Static/Dynamic, Shift-invariant/Shift-variant and Stable/Unstable.
𝑦[𝑛] = 𝑛2 𝑥[𝑛 − 1] Take 𝑥1 [𝑛] = 𝑢[𝑛] & 𝑥2 [𝑛] = 𝛿[𝑛]

Department of Electrical and Computer Engineering 10


Lab Manual EEE324 Digital Signal Processing
Experiment No.2 GENERATION OF SINE AND SQUARE
WAVE USING TMS320C6713 DSK
2.1 Objectives
Objective of this lab is to enable students to define and analyse basic signals using DSK.
2.2 Equipment Required
✓ Operating System - Windows XP
✓ CC STUDIO 3
✓ DSK 6713 DSP Trainer kit
✓ USB Cable
✓ Power supply
2.3 Pre-Lab
Basic knowledge of DSK kit is required.
2.4 In-Lab
2.4.1 Procedure
1. Open Code Composer Setup and select C6713 simulator, click save and quit.
2. Start a new project using “Project → New” pull down menu, save it in a separate directory
(C: \My projects) with file name “sine wave.pjt/square wave.pit”.
3. Create a new source file using File → New → Source file menu and save it in the project
folder (sinewave.c/squarewave.c).
4. Add the source file (sinewave.c/squarewave.c) to the project. Project → Add files to
Project → Select sinewave.c/squarewave.c.
5. Add the linker command file hello.cmd. Project → Add files to Project
(path:C:\CCstudio\tutorial\dsk6713\hello\hello.cmd).
6. Add the run time support library file rts6700.lib. Project → Add files to Project
(path:C\CCStudio\cgtools\lib\rts6700.lib).
7. Compile the program using “Project → Compile” or by Ctrl+F7.
8. Build the program using “project → Build” or by F7.
9. Load the sinewave.out file (from project folder lcconv\Debug) using File → Load
Program.
10. Run the program using “Debug → Run” or F5.
11. To view the output graphically, select View → Graph → Time and Frequency.
12. Repeat the steps 2 to 11 for square wave.
2.4.2 Program
2.4.2.1 Sine Wave
#include <stdio.h>
#include <math.h>
float a[500];
void main()
{
int i=0;
for(i=0;i<500;i++)
{

Department of Electrical and Computer Engineering 11


Lab Manual EEE324 Digital Signal Processing
a[i]=sin(2*3.14*10000*i);
}
}

Figure 2-1: Graph Property Dialog for Sine Wave

Figure 2-2: Output Sine Wave


2.4.2.2 Square Wave
#include <stdio.h>
#include <math.h>
int a[1000];
void main()
{
int i,j=0;
int b=5;
for(i=0;i<10;i++)
{

Department of Electrical and Computer Engineering 12


Lab Manual EEE324 Digital Signal Processing
for (j=0;j<=50;j++)
{
a[(50*i)+j]=b;
}
b=b*(- 1) ;
}
}

Figure 2-3: Graph Property Dialog for Square Wave

Figure 2-4: Output Square Wave


2.5 Post-Lab
You are required to write a MATLAB code to generate the graph shown in Figure 2-5 and then
generate the same graph using TMS320C6713 DSK. You Must Submit MATLAB code,
MATLAB graph, C-code and output graph of DSK.

Department of Electrical and Computer Engineering 13


Lab Manual EEE324 Digital Signal Processing
1.5

0.5

-0.5

-1

-1.5
0 1000 2000 3000 4000 5000 6000 7000 8000

Figure 2-5: Required Lab Task Graph

Department of Electrical and Computer Engineering 14


Lab Manual EEE324 Digital Signal Processing
Experiment No.3 GENERATION OF REAL TIME SOUND
WAVE USING TMS320C6713 DSK & ANALYSIS OF DT
SYSTEM USING RECURSIVE AND NON-RECURSIVE
DIFFERENCE EQUATIONS USING MATLAB
3.1 Objective
To generate a real time sound wave using TMS320C6713 DSK and analyzing difference equations
using MATLAB
3.2 Equipment Required
✓ MATLAB® R2015b or above
✓ Operating System - Windows XP
✓ CC STUDIO 3
✓ DSK 6713 DSP Trainer kit.
✓ USB Cable
✓ Power supply
✓ Speaker
3.3 Pre-Lab
Basic Knowledge of TMS320C6713 DSK is required.
3.3.1 Recursive and Non-Recursive Difference Equation
If a systems’ output depends upon the past values of output and present value of input, systems
us called recursive. Whereas if a systems’ output depends upon present and past values of input,
the system is called non-recursive system.

Figure 3-1: Recursive and Non-recursive Systems


An example of a recursive system be 𝑦(𝑛) = 𝑎𝑦(𝑛 − 1) + 𝑥(𝑛) and 𝑦(−1) = 0 and for a non-
recursive system be 𝑦(𝑛) = 𝑎𝑥(𝑛 − 1) + 𝑥(𝑛), 𝑥(−1) = 0.
3.4 In-Lab
3.4.1 Procedure for Real Time Sound Wave
1. Connect a Signal Generator/audio input to the LINE IN Socket or connect a microphone
to the MIC IN Socket. To use microphone input, change the analog audio path control
register value (Register no. 4) in Codec Configuration settings of the Source file (Codec.c)
from 0x0011 to 0x0015.

Department of Electrical and Computer Engineering 15


Lab Manual EEE324 Digital Signal Processing
2. Connect CRO/Desktop Speakers to the Socket Provided for LINE OUT or connect a
headphone to the Headphone out Socket.
3. Now Switch on the DSK and Bring Up Code Composer Studio on the PC.
4. Use the Debug → Connect menu option to open a debug connection to the DSK Board.
5. Create a new project with name codec.pjt.
6. Open the File → new → DSP/BIOS Configuration → select “dsk6713.cdb” and save it as
“xyz.cdb”.
7. Add “xyz.cdb” to the current project. Project → Add files to project →xyz.cdb.
8. Automatically three files are added in the Gene rated file folder in project pane.
xyzcfg.cmd → Command and linking file
xyzcfg.s62 → optimized assembly code for configuration
xyzcfg_c.c→ Chip support initialization
9. Open the File Menu → new → Source file.
10. Type the code in editor window. Save the file in project folder. (e.g. Codec.c). Save your
source code with preferred language extension. For ASM codes save the file as code(.asm)
& for C, C++, code(*.c,*.cpp) respectively.
11. Add the saved “Codec.c” file to the current project which has the main function and calls
all the other necessary routines. Project → Add files to Project →Codec.c.
12. Add the library file “dsk6713bsl.lib” to the current project.
Path:“C:\CCStudio_v3.1\C6000\dsk6713\lib\dsk6713bsl.lib”
Files of type: Object and library files (*.o*, *.l*)
13. Copy header files “dsk6713.h” and “dsk6713_aic23.h” from and paste it in current project
folder. Path:C:\ CCStudio_v3.1\ C6000\ dsk6713\include.
14. Add the header file generated within xyzcfg_c.ctocodec.c. Double click on xyzcfg_c.c.
Copy the first line header (e.g. #include “xyzcfg.h”) and paste that in source file (e.g.
codec.c).
15. Compile the program using the “Project compile” pull down menu or by clicking the
shortcut icon on the left side of program window.
16. Build the program using the “Project-Build” pull down menu or by clicking the shortcut
icon on the left side of program window.
17. Load the program (Codec. Out) in program memory of DSP chip using the “File → Load
Program” pull down menu.
18. Debug → Run.
19. You can notice the input signal of 500 Hz appearing on the CRO verifying the codec
configuration.
20. You can also pass an audio input and hear the output signal through the speakers.
21. You can also vary the sampling frequency using the DSK6713_AIC23_set Freq Function
in the “codec.c” file and repeat the above steps.
3.4.2 Procedure for Generation of Real Time Sine Wave
1. Connect Speaker to the LINE OUT socket.
2. Now switch ON the DSK and bring up Code Composer Studio on PC.
3. Create a new project with name sinewave.pjt.
4. From File menu→New→DSP/BIOS Configuration→Select dsk6713.cdb and save it as
“xyz.cdb”.
5. Add xyz.cdb to the current project.
6. Create a new source file and save it as sinewave.c.
7. Add the source file sinewave.c to the project.

Department of Electrical and Computer Engineering 16


Lab Manual EEE324 Digital Signal Processing
8. Add the library file “dsk6713bsl.lib” to the project.
Path:C:\CCStudio\C6000\dsk6713\lib\dsk6713bsl.lib.
9. Copy files “dsk6713.h” and “dsk6713_aic23.h” to the Project folder.
10. Build (F7) and load the program to the DSP Chip ( File→Load Program).
11. Run the program (F5).
12. Give an audio input from the PC and notice the output in the speaker.

Figure 3-2: Configuration Settings for Mic Input


Code: Sinewave.c
#include "xyzcfg.h"
#include "dsk6713.h"
#include "dsk6713_aic23.h"
#include <stdio.h>
#include <math.h>
float a[500],b;
DSK6713_AIC23_Config config=DSK6713_AIC23_DEFAULTCONFIG;
void main()
{
int i=0;
DSK6713_AIC23_CodecHandle hCodec;
Int l_output,r_output;
DSK6713_init();
hCodec=DSK6713_AIC23_openCodec(0,&config);
DSK6713_AIC23_setFreq(hCodec,DSK6713_AIC23_FREQ_48KHZ);
for(i=0;i<500;i++)
{
a[i]=sin(2*3.14*10000*i);
}

Department of Electrical and Computer Engineering 17


Lab Manual EEE324 Digital Signal Processing
while(1)
{
for(i=0;i<500;i++)
{
b=400*a[i];
while(!DSK6713_AIC23_write(hCodec,b));
}
}
DSK6713_AIC23_closeCodec(hCodec);
}
3.4.3 Analysis of Recursive and Non-Recursive Difference Equation
A recursive system is given by:
𝑦(𝑛) = 𝑎𝑦(𝑛 − 1) + 𝑥(𝑛), 𝑦(−1) = 0
Plot the response of the system for 𝑎 = 0.5, −0.5,1.5, −1.5 where 0 ≤ 𝑛 ≤ 25 and 𝑥(𝑛) = 𝑢(𝑛).
Solution for 𝑎 = 0.5 is given for reference, repeat for rest values of a and observe the system’s
response.
n = 0:25;
a = 0.5;
U = double(n>=0);
y = [1 U(1,1)];
fori = 1:25
y(i+1) = a*y(i) + U(i+1);
end
stem(n,y)
A non-recursive system is given by:
𝑦(𝑛) = 𝑎𝑥(𝑛 − 1) + 𝑥(𝑛), 𝑥(−1) = 0
Plot the response of the system for 𝑎 = 0.5, −0.5,1.5, −1.5 where 0 ≤ 𝑛 ≤ 25 and 𝑥(𝑛) = 𝑒 −𝑛 .
Solution for 𝑎 = 0.5 is given for reference, repeat for rest values of a and observe the system’s
response.
n = 0:25;
a = 0.5;
U = exp(-n);
y = [1];
for i = 1:25
y(i+1) = a*U(1,i) + U(1,i+1);
end
stem(n,y)
Compare the results obtained from recursive and non-recursive systems.
3.5 Post-Lab
1. Plot the response of following system:
5 1
𝑦(𝑛) = 𝑦(𝑛 − 1) − 𝑦(𝑛 − 2) + 𝑥(𝑛), 𝑥(𝑛) = 2𝑛 𝑢(𝑛),
6 6
𝑦(−1) = 𝑦(−2) = 1, 0 ≤ 𝑛 ≤ 10

Department of Electrical and Computer Engineering 18


Lab Manual EEE324 Digital Signal Processing
Experiment No.4 SAMPLING, ALIASING AND DECIMATION
USING MATLAB
4.1 Objective
Objective of this lab is to enable students how to sample a continuous time signal to obtain discrete
time signal and to analyse aliasing and decimation phenomenon during sampling.
4.2 Equipment Required
✓ MATLAB® R2015b or above
4.3 Pre-Lab
4.3.1 Sampling, Uniform Sampling and Nyquist Theorem
Suppose we have a continuous-time signal 𝑥𝑐 (𝑡). We can get a discrete-time version of it by using
sampling. This means that we measure it at certain points in time and create a discrete-time version.
Suppose that we create a discrete-time signal 𝑥(𝑛) such that 𝑥(𝑛) = 𝑥𝑐 (𝑡𝑛 ) with 𝑡𝑘 > 𝑡𝑘−1 ∀𝑘,
i.e., 𝑡𝑘 is a strictly increasing sequence. Then 𝑥(𝑛) is a sampled version of 𝑥𝑐 (𝑡).
We say the sampling is uniform, when 𝑡𝑘 = 𝑘𝑇𝑠 , where 𝑇𝑠 is known as the sampling period. The
sampling frequency is defined as 𝑓𝑠 ≜ 1⁄𝑇𝑠 .
The Sampling Theorem, also known as the Nyquist-Shannon Sampling Theorem, or the Nyquist
Criteria, says: If a continuous-time signal 𝑥𝑐 (𝑡) is band-limited with a maximum frequency of
𝑓max , and we uniformly sample it with a sampling frequency 𝑓𝑠 , the original signal can only be
recovered if the signal was sampled at 𝑓𝑠 > 2𝑓max .
4.3.2 Aliasing
When we sample a function 𝑥𝑐 (𝑡) which is band-limited with a maximum frequency of 𝑓max at a
sampling frequency of 𝑓𝑠 < 2𝑓max , some of the frequencies mix together and we say aliasing has
occurred.
4.3.3 Decimation
Consider a discrete-time signal 𝑥1 (𝑛). If we define a signal 𝑥2 (𝑛) = 𝑥1 (𝑀𝑛), 𝑀 ∈ ℤ+ , we say that
𝑥2 is a decimated version of 𝑥1 , by a factor of 𝑀.
4.4 In-Lab
In MATLAB, sampling can be done as demonstrated in following example.
>> xc = @(t) exp(j * 2 * pi * t);
>> t = 0:0.01:1;
>> figure; plot(t, real(xc(t)));
>> figure; plot(t, imag(xc(t)));
% Non-uniform sampling instants
>> tk = [0 0.1 0.2 0.4 0.5 0.7 0.9 1.0];
% Check if monotonically increasing, if yes, answer should be 1
>> all(diff(tk) > 0)
>> x = xc(tk); % Discrete time signal
>> figure; stem(tk, real(x));
>> figure; stem(tk, imag(x));

Department of Electrical and Computer Engineering 19


Lab Manual EEE324 Digital Signal Processing
Uniform sampling is demonstrated as follows:
>> Ts = 0.05;
>> syms n
>> x = @(n) xc(n * Ts);
>> x(n) % answer should be “exp((pi*n*1i)/10)”
>> nr = 0:20;
>> figure; stem(nr, real(x(nr)));
>> figure; stem(nr, imag(x(nr)));
Consider a continuous-time signal 𝑥𝑐 (𝑡) = 𝑒 −3𝑡 sin(2𝜋𝑡) 𝑢(𝑡). Sample it and plot it such that
a. tk1 = 0:0.1:2;
b. tk2 = sort(2*rand(1,20));
Lets see an example which shows aliasing and decimation while sampling a signal usnig different
sampling times.
>> x1 = @(n) sin(2*pi*n/10) + cos(2*pi*n/5);
>> nr = 0:20;
>> figure; stem(nr, x1(nr));
We can clearly see from the function that the function has a highest angular frequency of 𝜔max =
2𝜋⁄5. Now, let’s decimate it with a factor 𝑀 = 7.
>> x2 = @(n) x1(7*n);
>> nr = 0:20;
>> figure; stem(nr, x2(nr));
It seems periodic, but the shape of the signal has changed due to aliasing. We can also observe that
𝜔max = 2𝜋⁄5 if we take its DFT over a very large number of samples.
>> nr1 = 0:2047;
>> X1 = fft(x1(nr1));
>> domega = 2*pi/2048;
>> omegar = 0:domega:(2*pi-domega);
>> figure; plot(omegar, abs(X1));
Aliasing is more prominently visible in the frequency domain as well:
>> X2 = fft(x2(nr1));
>> figure; plot(omegar, abs(X2));
4.5 Post-Lab
Decimate the following discrete time signals with the given factors. Plot the response as given and
determine if aliasing has occurred.
a. 𝑥1 (𝑛) = sin(2𝜋𝑛⁄20) + cos(2𝜋𝑛⁄30), 𝑀1 = 5
b. 𝑥2 (𝑛) = cos(𝜋𝑛⁄3) + sin(𝜋𝑛⁄5), 𝑀2 = 4
You should submit an m-file that plots the frequency response of each signal, decimates the signal,
plots the frequency response of the decimated signal. All the plots should be in separate figures.
In the comments, mention whether aliasing has occurred.

Department of Electrical and Computer Engineering 20


Lab Manual EEE324 Digital Signal Processing
Experiment No.5 Z-TRANSFORM AND ANALYSIS OF LTI
SYSTEM IN Z-PLANE USING MATLAB
5.1 Objective
The objective of this lab is to study the discrete time signals and analyzing LTI systems in Z-
domain using MATLAB.
5.2 Equipment Required
➢ MATLAB 2015b or above
5.3 Pre-Lab
5.3.1 Introduction
Z-transform is counterpart of Laplace transform when dealing with Discrete-Time signals. It is
employed to transform difference equations that describe the input /output relationships of discrete
time systems into algebraic equations and is very useful tool for the analysis and design of discrete-
time systems. Z-Transform is denoted by the symbol 𝑍{. } and expresses a signal in z-domain
represented by a function 𝐹(𝑧). The mathematical expression is:
𝐻(𝑧) = 𝑍{ℎ[𝑛]}
The mathematical expression of the two-sided (or-bilateral) z-transform is:

𝐻(𝑧) = ∑ ℎ(𝑛)𝑧 −𝑛
𝑛=−∞

Replacing the lower limit of the sum from minus infinity to zero yields the one-sided (or unilateral)
z-transform whose mathematical expression is:

𝐻(𝑧) = 𝑍{ℎ[𝑛]} = ∑ ℎ(𝑛)𝑧 −𝑛


𝑛=0

Where 𝑧 = 𝑟𝑒 𝑗𝜔 is complex, with the magnitude representing the decay and the phase representing
the oscillation. If the decay part does not exist, i.e. 𝑟 = 1, the Z-Transform simplifies to the
discrete-time Fourier transform DTFT. In order to return from the z-domain back to the discrete-
time domain, the inverse z-transform is applied. The inverse z-transform is denoted by the symbol
𝑍 −1 {. } that is, one can write:
1
ℎ[𝑛] = 𝑍 −1 {𝐻(z)} = ∮ 𝐻(𝑧)𝑧 𝑛−1 𝑑𝑧
2𝜋𝑗
Usually, this integration is complex, and inverse Z-Transform is found using tables of Z-transform
pairs.
When LTI system is described by the difference equation
𝑁 𝑀

𝑦(𝑛) + ∑ 𝑎𝑘 𝑦(𝑛 − 𝑘) = ∑ 𝑏𝑙 𝑥(𝑛 − 𝑙)


𝑘=1 𝑙=0

The system function can be easily computed, by taking the z-transform of both sides and using the
properties of z-transform, we obtain

Department of Electrical and Computer Engineering 21


Lab Manual EEE324 Digital Signal Processing
∏𝑀
𝑙=1(𝑧 − 𝑧𝑙 )
𝐻(𝑧) = 𝑏𝑜 𝑧 𝑁−𝑀 𝑁
∏𝑘=1(𝑧 − 𝑧𝑘 )
Where 𝑧𝑙 are system zeros and 𝑧𝑘 are system poles. If region of convergence ROC of 𝐻(𝑧) includes
a unit circle, then we can evaluate 𝐻(𝑧) on the unit circle, resulting in a frequency response function
or transfer function 𝐻(𝑒 𝑗𝑤 ). So, the above equation can be written as:
∏𝑀
𝑙=1(𝑒
𝑗𝑤
− 𝑧𝑙 )
𝐻(𝑒 𝑗𝑤 ) = 𝑏𝑜 𝑒 𝑗𝑤(𝑁−𝑀) 𝑁 𝑗𝑤
∏𝑘=1(𝑒 − 𝑧𝑘 )
5.3.2 Properties of the Z-Transform
1. Linearity: 𝑍[𝑎1 𝑥1 (𝑛) + 𝑎2 𝑥2 (𝑛)] = 𝑎1 𝑋1 (𝑧) + 𝑎2 𝑋2 (𝑧) 𝑅𝑂𝐶 ⊇ 𝑅𝑂𝐶(𝑥1 ) ∩ 𝑅𝑂𝐶(𝑥2 )
2. Time shifting: 𝑍[𝑥(𝑛 − 𝑛0 )] = 𝑧 −𝑛0 𝑋(𝑧) 𝑅𝑂𝐶 = 𝑅𝑂𝐶(𝑥)
3. Time expansion (Scaling): 𝑍[𝑥(𝑛⁄𝑘)] = 𝑋(𝑧 𝑘 ) 𝑅𝑂𝐶 = 𝑅𝑂𝐶(𝑥)1⁄𝑘
4. Time Difference: 𝑍[𝑥(𝑛) − 𝑥(𝑛 − 1)] = (1 − 𝑧 −1 )𝑋(𝑧) 𝑅𝑂𝐶 = 𝑅𝑂𝐶(𝑥)
5. Scaling in Z-domain: 𝑍[𝑎𝑛 𝑥(𝑛)] = 𝑋(𝑧⁄𝑎) 𝑅𝑂𝐶 = |𝑎|𝑅𝑂𝐶(𝑥)
6. Time Reversal: 𝑍[𝑥(−𝑛)] = 𝑋(1⁄𝑧) 𝑅𝑂𝐶 = 1⁄𝑅𝑂𝐶(𝑥)
𝑑
7. Differentiation in Z-domain: 𝑍[𝑛𝑥(𝑛)] = −𝑧 𝑑𝑧 𝑋(𝑧) 𝑅𝑂𝐶 = 𝑅𝑂𝐶(𝑥)
8. Convolution: 𝑍[𝑥(𝑛) ∗ 𝑦(𝑛)] = 𝑋(𝑧)𝑌(𝑧) 𝑅𝑂𝐶 ⊇ 𝑅𝑂𝐶(𝑥) ∩ 𝑅𝑂𝐶(𝑦)
5.4 In-Lab
The Z-Transform is implemented in MATLAB using the function ztrans.
>> sympref('HeavisideAtOrigin',1);
>> syms n z
>> x = @(n) 2.^(-n) .* heaviside(n);
>> ztrans(x(n), n, z)
ans =
1/(2*z - 1) + 1
>> pretty(ans)
1
------- + 1
2 z – 1
The inverse Z-Transform is implemented in MATLAB using the function iztrans.
>> X = @(z) (2 * z .^ (-1)) ./ ((1 - 2 * z .^ (-1)).^2);
>> iztrans(X(z), z, n)
ans =
2^n + 2^n*(n - 1)
>> pretty(ans)
n n
2 + 2 (n - 1)
Some important command are listed below that can be used for Z-transform analysis.
1. 𝐻(𝑧) can also be represented in the z-domain using a pole-zero plot. The function
zplane(b,a) plots poles and zeros, given the numerator row vector b and the denominator
row vector a of 𝐻(𝑧).
2. The MATLAB function freqz(b,a,w) is used to find the frequency response at the
frequencies designated in vector 𝑤.
3. Impulse response of digital filter is computed using impz(b,a,N) command.

Department of Electrical and Computer Engineering 22


Lab Manual EEE324 Digital Signal Processing
4. Z-transform partial-fraction expansion is computed using residuez(b,a) command which
finds the residues R, poles P and direct terms K of the partial-fraction expansion of
𝐻(𝑧) = 𝑏(𝑧)⁄𝑎(𝑧).
1. Find Z-transform of following:
a) 𝑥(𝑛) = 𝑎𝑛 𝑢[𝑛]
b) 𝑥(𝑛) = (1/2)𝑛 𝑢[𝑛] + (−1/3)𝑛 𝑢[𝑛]
𝜋
c) 𝑥(𝑛) = (𝑛 − 2)(0.5)(𝑛−2) 𝑐𝑜𝑠 [ 3 (𝑛 − 2)] 𝑢(𝑛 − 2)
d) 𝑥(𝑛) = 3(0.75)𝑛 𝑐𝑜𝑠(0.3𝜋𝑛)𝑢(𝑛) + 4(0.75)𝑛 𝑠𝑖𝑛(0.3𝜋𝑛)𝑢(𝑛)
2. Find inverse Z-transform of following and plot pole-zero plot.
𝑧 −1
a) 𝑋(𝑧) = 1−𝑎𝑧 −1
1−1.6180𝑧 −1 +𝑧 −2
b) 𝑋(𝑧) = 1−1.5161𝑧 −1 +0.878𝑧 −2
1
c) 𝑋(𝑧) = 1−𝑧 −1 , |𝑧| > 1
d) 𝑋1 (𝑧) = 2 + 3𝑧 −1 + 4𝑧 −2 , 𝑋2 (𝑧) = 3 + 4𝑧 −1 + 5𝑧 −2 + 6𝑧 −3 , 𝑋3 (𝑧) =
𝑋1 (𝑧)𝑋2 (𝑧)
3. Given a causal system
𝑦(𝑛) = 0.9𝑦(𝑛 − 1) + 𝑥(𝑛)
a. Determine 𝐻(𝑧) and plot pole-zero plot.
b. Plot |𝐻(𝑒 𝑗𝜔 )| and ⟨𝐻(𝑒 𝑗𝜔 ) 𝑓𝑜𝑟 𝜔 = 0: 𝜋
c. Determine the impulse responseℎ(𝑛).
5.5 Post-Lab Tasks
1. Determine the rational Z-Transform from its poles and zero locations. The zeros and
poles are at following locations in z-domain:
𝑧1 = 0.2, 𝑧2 = 3.14, 𝑧3 = −0.3 + 𝑗 0.5, 𝑧4 = −0.3 − 𝑗0.5
𝑝1 = −0.45, 𝑝2 = −0.67, 𝑝3 = 0.81 + 𝑗 0.72, 𝑝4 = 0.81 − 𝑗0.72, 𝐾 = 2.2
2. Find the Z-Transform 𝑋1 (𝑧) of 𝑥1 (𝑛) = 𝑛2 𝑢(𝑛)
3. Find the inverse Z-transform 𝑥2 (𝑛), 𝑥3 (𝑛) of the following complex-domain functions:
a. 𝑋2 (𝑧) = 1
𝑧 −1 (1+𝑧 −1 )
b. 𝑋3 (𝑧) = (1−𝑧 −1 )3
4. Given 𝐻(𝑧) is a causal system, Difference equation and Impulse response.
𝑧 −1 + 𝑧 −2
𝐻(𝑧) =
1 − 0.9𝑧 −1 + 0.81𝑧 −2
5. For difference equation given below, determine
𝑦(𝑛) = 0.81𝑦(𝑛 − 2) + 𝑥(𝑛) − 𝑥(𝑛 − 2)
a. System function 𝐻(𝑧)
b. Unit impulse response ℎ(𝑛)
c. Step response i.e. the response to the unit step u(n)
d. Frequency response 𝐻(𝑒 𝑗𝜔 ), and plot its magnitude and phase for 𝜔 = [−𝜋, 𝜋]

Department of Electrical and Computer Engineering 23


Lab Manual EEE324 Digital Signal Processing
Experiment No.6 FREQUENCY RESPONSE OF LTI
SYSTEMS, AVERAGE POWER, POWER SPECTRAL DENSITY
AND SPECTRAL DENSITY USING MATLAB
6.1 Objective
Objective of this lab is to enable students to analyse discrete time systems in frequency domain
and evaluate their power and spectrum.

6.2 Equipment Required


➢ MATLAB 2015b or above

6.3 Pre-Lab
6.3.1 Fourier series for discrete time periodic signals

If a discrete-time signal is periodic with a fundamental period of 𝑁, then its Discrete-Time Fourier
Series (DTFS) is given by
𝑁−1
1
𝑋(𝑘) = 𝑐𝑘 = ℱ{𝑥(𝑛)} = ∑ 𝑥(𝑛)𝑒 −𝑗2𝜋𝑘𝑛⁄𝑁 ,
𝑁
𝑛=0

and it is also periodic with a fundamental period of 𝑁. To get 𝑥(𝑛) back from 𝑋(𝑘), we use the
formula
𝑁−1 𝑁−1
𝑗2𝜋𝑘𝑛⁄𝑁
𝑥(𝑛) = ℱ −1 {𝑋(𝑘)}
= ∑ 𝑋(𝑘)𝑒 = ∑ 𝑐𝑘 𝑒 𝑗2𝜋𝑘𝑛⁄𝑁
𝑘=0 𝑘=0

This formula is also known as the discrete-time Fourier series representation of a signal. The since
both the series and its inverse are periodic, it is always sufficient to look at them for one time
period only.

6.3.2 Power density spectrum of periodic signals

The average power of a discrete time periodic signal with period N is given by:
𝑁−1 𝑁−1
1
𝑃𝑥 = ∑|𝑥(𝑛)|2 = ∑|𝑐𝑘 |2
𝑁
𝑛=0 𝑘=0

Where the PSD of periodic signal is given by:

𝑃𝑆𝐷 = |𝑐𝑘 |2 , 𝑘 = 0,1, … , 𝑁 − 1

6.3.3 Fourier transform of discrete time Aperiodic signals

If a discrete-time signal 𝑥(𝑛) satisfies the property that

Department of Electrical and Computer Engineering 24


Lab Manual EEE324 Digital Signal Processing

∑ |𝑥(𝑛)| ∈ ℝ+
0
𝑛=−∞

then, its Fourier transform is given by the expression


ℱ{𝑥(𝑛)} = 𝑋(𝜔) = ∑ 𝑥(𝑛)𝑒 −𝑗𝜔𝑛


𝑛=−∞

which is known as the frequency domain representation of the signal 𝑥(𝑛). To represent this, we

write 𝑥(𝑛) → 𝑋(𝜔). The DTFT of a signal is always 2𝜋-periodic. One can obtain the discrete time
signal from 𝑋(𝜔) by taking inverse Fourier transform as follows:

1 𝜋
𝑥(𝑛) = ∫ 𝑋(𝜔)𝑒 𝑗𝜔𝑛 𝑑𝜔
2𝜋 −𝜋

6.3.4 Energy density spectrum of Aperiodic signals

The energy spectral density of a signal 𝑥(𝑛) is defined as:

𝑆𝑥𝑥 (𝜔) = 𝑋 ∗ (𝜔)𝑋(𝜔) = |𝑋(𝜔)|2

Where 𝑋(𝜔) is Fourier transform of the signal 𝑥(𝑛).

6.4 In-Lab
Determine the spectra of the following signal using Fourier series coefficients.
𝜋𝑛
a) 𝑥(𝑛) = 𝑐𝑜𝑠 ( 3 )
1
b) 𝑥(𝑛) is periodic with period 𝑁 = 4 and 𝑥(𝑛) = { , 1,0,0}

%% Part a
syms n k
x = @(n) cos((pi*n)/3);
N = 6;
ck = @(k) simplify((1/N)*symsum(x(n).*exp(-(j*2*pi*k*n)/N),n,0,N-1));
ck(k)
kr = -10:10;
figure; stem(kr, ck(kr))
figure; stem(kr, (abs(ck(kr))).^2)
Px = symsum((abs(ck(k))).^2, k, 0, N-1)
%% Part b
syms n k
N = 4;
x = @(n) heaviside(mod(n,N)) - heaviside(mod(n,N)-2);
ck = @(k) simplify((1/N)*symsum(x(n).*exp(-(j*k*2*pi*n)/N),n,0,N-1));
ck(k)

Department of Electrical and Computer Engineering 25


Lab Manual EEE324 Digital Signal Processing
kr = -10:10;
figure; stem(kr, abs(ck(kr)))
figure; stem(kr, angle(ck(kr)))

Determine the Fourier series coefficients and power density spectrum of the following periodic
signal for L = 5, 𝑁 = 40 and 60

1 0≤ 𝑛 ≤ 𝐿−1
𝑥(𝑛) = {
0 𝐿 ≤𝑛 ≤𝑁−1
syms n k
sympref('HeavisideAtOrigin',1);
N1 = 40;L = 5;
x = @(n) heaviside(mod(n,N1)) - heaviside(mod(n,N1)-L);
ck = @(k) simplify((1/N1)*symsum(x(mod(n,N1)).*exp(-(j*k*2*pi*n)/N1),
n, 0, N1-1));
kr = -60:60;
figure; stem(kr,ck(kr))
figure; stem(kr,(abs(ck(kr))).^2)
N2 = 60;
x2 = @(n) heaviside(mod(n,N2)) - heaviside(mod(n,N2)-L);
ck1 = @(k)simplify((1/N2)*symsum(x2(mod(n,N2)).*exp(-(j*k*2*pi*n)/N2),
n, 0, N2-1));
figure; stem(kr,ck1(kr))
figure; stem(kr,(abs(ck1(kr))).^2)

Determine Fourier transform of following signal and plot its energy density spectrum.

x(n) = an u(n) −1 < a < 1

syms n w
a = 0.5;
x = @(n) a.^n;
X = @(w) symsum(x(n) .* exp(-j * w * n), n, 0, inf);
X(w)
wr = -pi:0.1:pi;
figure; plot(wr,X(wr));
figure; plot(wr,(abs(X(wr))).^2)

Determine the Fourier transform and energy density spectrum of the following sequence for L =
5. Plot magnitude and phase spectrum of 𝑋(𝜔)
1 0≤ 𝑛 ≤ 𝐿−1
𝑥(𝑛) = {
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
syms n w
L = 5;
x = @(n) heaviside(n) - heaviside(n-L);
X = @(w) symsum(x(n) .* exp(-j * w * n), n, 0, inf);
X(w)

Department of Electrical and Computer Engineering 26


Lab Manual EEE324 Digital Signal Processing
wr = -pi:0.1:pi;
figure; plot(wr,abs(X(wr)));
figure; plot(wr,angle(X(wr)));
figure; plot(wr,(abs(X(wr))).^2)

6.5 Post-Lab
1. Determine the signal 𝑥(𝑛) if its Fourier transform is given as follows:

2. Let 𝑥(𝑛) be a signal with Fourier transform as following

Determine and sketch the Fourier transform of following signals:

a) x1 (n) = x(n)cos(𝜋n/4)
b) x2 (n) = x(n)sin(𝜋n/2)

Department of Electrical and Computer Engineering 27

Potrebbero piacerti anche