DSP Lab 21-09-2021
DSP Lab 21-09-2021
DSP Lab 21-09-2021
Tech I Semester
PREPARED BY
MALLA KISHORE
KUMAR ASSISTANT
PROFESSIR ECE
DEPARTMENT
PART-1( SIGNALS )
1) Generation of discrete time signals for discrete signals
2) To verify the Linear Convolution
a) Using MATLAB
b) Using Code Composer Studio(CCS)
3) To verify the Circular Convolution for discrete signals
a) Using MATLAB
b) Using Code Composer Studio(CCS)
4) To Find the addition of Sinusoidal Signals
5) To verify Discrete Fourier Transform(DFT) and Inverse Discrete Fourier Transform(IDFT)
a) Using MATLAB
b) Using Code Composer Studio(CCS)
6) Transfer Function Stability Analysis: using pole-zero plot, bode plot, Nyquist plot, z-plane plot.
PART-2 ( FILTERS )
7) Frequency Response of IIR low pass Butterworth Filter
8) Frequency Response of IIR high pass Butterworth Filter
9) Frequency Response of IIR low pass Chebyshev Filter
10) Frequency Response of IIR high pass Chebyshev Filter
11) Frequency Response of FIR low pass Filter using Rectangle Window
12) Frequency Response of FIR low pass Filter using Triangle Window
PART – 3( IMAGE PROCESSING )
13) An image processing in a false contouring system
14) To generate the histogram equalization to the image
15) To verify the Normalized Cross Correlation to the addition of noise and removal of noise
using filters to an image.
16) Compute the edge of an image using spatial filters.
17) Perform the image motion blur and calculate PSNR to the noise image and also noise free image.
18) To verify the PSNR to the Second order Decomposition of Discrete Wavelet transforms and to the
reconstructed image using inverse Discrete Wavelet transform
AIM: To study the architecture of DSP processor TMS 320 6713 (a floating point DSP)
TMS320C6713 DSP
The DSK supports a TMS320C6713 DSP which can operate at a clock frequency of up
to 225 MHz. The DSP core is designed for high performance floating point operation. Beyond
the DSP core, the ‘6713 integrate a number of on-chip resources that improve functionality and
minimize hardware development complexity. Features of the processor include:
· 4Kb Program/Data Caches – separate caches for program code and data.
· On-chip PLL – generates processor clock rate from slower external clock reference.
· 2 Timers – generates periodic timer events as a function of the processor clock. Used
by DSP/BIOS to create time slices for multitasking.
· EDMA Controller – Enhanced DMA controller allows high speed data transfers
without intervention from the DSP.
· 2 McBSPs – Multichannel buffered serial ports. Each McBSP can be used for high-
speed serial data transmission with external devices or reprogrammed as general purpose I/Os.
McBSP1 is used to transmit and receive audio data from the AIC23 stereo codec. McBSP0 is
used to control the codec through its serial control port. The MISC register in the CPLD is
used to select whether McBSP0 and McBSP1 are routed to the AIC23 or the expansion
connectors.
· 2 McASPs – Multichannel audio serial ports. Used for multi-channel and professional
audio applications. Not used on the DSK, but brought out to the expansion connectors.
· 2 I2C Interfaces – Inter-Integrated Circuit Bus. An I2C bus is a serial bus format that
can support several standard devices per bus.
· EMIF – External Memory Interface. A 32-bit bus on which external memories and
other devices can be connected. It included features like internal wait state generation and
SDRAM control. The EMIF can interface to both synchronous and asynchronous memories.
For more detailed information on the ‘6713, please see the TMS320C6713 Data Sheet.
CPLD
The C6713 DSK uses an Altera EPM3128TC100-10 Complex Programmable Logic Device
(CPLD) device to implement:
The CPLD logic is specific to the functionality on the DSK. Your own hardware designs will
likely implement a completely different set of functions or take advantage of the DSPs high
level of integration for system design and avoid the use of external logic completely.
Memory-Mapped Registers
The 4 CPLD memory-mapped registers allow users to control CPLD functions in
software. On the 6713 DSK the registers are primarily used to access the LEDs and DIP
switches and control the daughter card interface. The registers are mapped into the EMIF
CE1 data space at byte address 0x90080000 with a data width of 8 bits. The following table
gives a high level overview of the CPLD registers and their bit fields:
Glue Logic
The CPLD implements simple random logic functions that eliminate the need for
additional discrete devices. In particular, the CPLD aggregates the various reset signals
coming from the reset button and power supervisors and generates a global reset. It is also
used to divide the 24MHz reference clock in half to provide a 12MHz clock to the AIC23.
Device Specifics
The EPM3128TC100-10 is a 3.3V (5V tolerant), 100-pin QFP device that provides 128 macro
cells and up to 80 I/O pins with a 10ns pin-to-pin delay. The device is EEPROM-based and is
in-system programmable via a dedicated JTAG interface (a 10-pin header on the DSK). The
CPLD source files are written in the industry-standard VHDL (Hardware Design Language)
and are included with the DSK on the installation CD-ROM.
EXTERNAL SDRAM
The DSK uses a 64 megabit Synchronous DRAM (SDRAM) on the 32-bit EMIF. The
SDRAM is mapped at the beginning of CE0 (address 0x80000000). Total available memory is
16 megabytes.
The integrated SDRAM controller is part of the EMIF and must be configured in
software for proper operation. Some of the most important parameters are listed below:
Parameter: Value
Num. Banks: 4
One of the key SDRAM parameters is the refresh period. SDRAMs must be
continuously refreshed or they will become unstable and lose their contents. The DRAM used
on the 6713 DSK must refresh one row every 15.6 microseconds. The configuration shown
above uses a value of 1400 (0x578 in hex notation) to specify a refresh period (1400 x 11.11ns,
the clock period at 90MHz).
EXTERNAL FLASH
Flash is a type of memory, which does not lose its contents when the power is turned
off. When read it looks like a simple asynchronous read-only memory (ROM). Flash can be
erased in large blocks commonly referred to as sectors or pages. Once a block has been erased
each word can be programmed once through a special command sequence. After than the
entire block must be erased again to change the contents.
The DSK uses a 512Kbyte external flash as a boot option. It is visible at the
beginning of CE1 (address 0x90000000). The Flash is wired as a 256K by 16 bit device to
support the DSK's 16-bit boot option. However, the software that ships with the DSK treats
the Flash as an 8-bit device (ignoring the top 8 bits) to match the 6713's default 8-bit boot
mode. In this configuration, only 256Kbytes are readily usable without software changes.
The Flash requires 70ns for both reads and writes. The general settings used with the
DSK use 8 cycles for both read and write strobes (80ns) to leave a little extra margin. The
DSK default is to add two write hold cycles for all asynchronous memories to account for
address propagation delay through the CPLD.
AIC23 CODEC
The DSK uses a Texas Instruments AIC23 (part #TLV320AIC23) stereo codec for
input and output of audio signals. The codec samples analog signals on the microphone or line
inputs and converts them into digital data that can be processed by the DSP. When the DSP
is finished with the data it uses the codec to convert the samples back into analog signals on
the line and headphone outputs so the user can hear the output.
The codec communicates using two serial channels, one to control the codec’s internal
configuration registers and one to send and receive digital audio samples. The AIC23 supports
a variety of configurations that affect the data formats of the control and data channels, the
following summarizes the preferred setup for the 6713 DSK, more detailed descriptions are
given below.
Data Channel McBSP1, AIC23 in master mode with 12MHz system clock. Data in
codec’s DSP format with each sample consisting of one frame with two 16-bit elements
corresponding to left and right. Clocks and frame syncs generated by the AIC23 external to the
DSP.
4 USER LED
The DSK has eight LEDs made up of four status indicators and four user defined LEDs.
The user-defined indicators are the green LEDs next to the DIPswitches.
User LEDs
The four user controllable LEDs allow for user feedback and display of simple status
information. Writing to the CPLD USER_REG register controls them. They can also be set or
cleared through the LED Module of the Board Support Library.
Status Indicators
The status indicators monitor the following functions. The PWR LED is hardwired on
the +5V supply and will illuminate whenever the power is connected. The RESET LED
illuminates when the RESET event occurs. The USB_IN_USE LED is on when USB
emulation is used and goes off when an external emulator is applied. The USB BUSY LED
indicates that the USB emulator transaction is in progress.
DIP SWITCHES
The four Dipswitches allow simple feedback from the user. The DIP switches can be
read through the CPLD USER_REG registers. They can also be read using the DIP Switch
module of the Board Support Library.
CONFIGURATION SWITCHES
The 6713 DSK has 4 configuration switches that allow users to control the
operational state of the DSP when it is released from reset. The configuration switch block is
labeled SW3 on the DSK board, next to the reset switch.
Configuration switch 1 controls the endianness of the DSP while switches 2 and 3 configure
the boot mode that will be used when the DSP starts executing. Switch 4 determines whether
the HPI or McASP signals come out on shared pins.
Default Settings
The default configuration settings are to have all switches off. This configures the DSK
to boot from the on-board Flash in little endian mode.
The DSK provides three expansion connectors that can be used to accept a plug-in
daughter card. The daughter card allows users to build on their DSK platform to extend its
capabilities and provide custom and application specific I/O. The expansion connectors are
for memory, peripherals and the Host Port Interface (HPI). For more information on the
expansion interface, please see the 6713 DSK Technical Reference.
The HPI is a high-speed interface that can be used to allow multiple DSPs to
communicate and cooperate on a given task. The HPI signals are multiplexed with McASP1.
Most of the expansion connector signals are buffered so that the daughter-card cannot
directly influence the operation of the DSK board. The use of TI low-voltage, 5-V tolerant
buffers and CBT interface devices allows the use of either +5V or +3.3V devices to be used on
the daughter-card.
The three expansion connectors are all 80-pin 0.050 x 0.050 inches low-profile
connectors from Samtec or AMP. The Samtec SFM-series (surface-mount) connectors are
designed for high-speed interconnections because they have low propagation delay,
capacitance, and cross-talk. The connectors present a small footprint on the DSK. Each
connector includes multiple ground, +5V, and +3.3V power signals so that the daughter-card
can obtain power directly from the DSK. The peripheral expansion connector additionally
provides both +12V and -12V to the daughter-card. The recommended mating connector,
whose part number is TFM-140-32-S-D-LC, is a surface-mount connector that provides a
0.465" mated height.
Non-intrusively through hardware device called a JTAG emulator. Benefits of JTAG based
debug include:
· Your target hardware can be debugged in just as if it were a finished product. You
don’t need a special version of your hardware with debug features such as chip test clips or test
points to expose signals or EEPROM sockets to hold code while you try it out.
· You don’t need any special software running on your target hardware. Many systems
use a ROM monitor to transfer debug information from the host to the target. But since the
monitor itself uses resources like memory, interrupt vectors and things like serial ports, your
application must be written with the ROM monitor in mind so it doesn’t conflict with the
monitor and kill your debug session.
· It is much faster and more flexible. You have full access to all of the internal chip
state at the same time, not just what your debug output happens to monitor. You can load
code directly into memory as soon as you have your hardware and immediately take a look at
the internal state. It is much faster than the old "burn and learn technique" where you burn a
program you think will work into an EEPROM, put the EEPROM into a socket on the board
and see what the program does. If it doesn’t work you stare at the code until you figure out
what’s wrong and keep trying.
· On TI DSP platforms you have a high degree of tool re-use across different DSPs and
hardware targets. TI DSPs use a standard 14 pin header across their C2000, C5400, C5500,
C6400, C6200, C6400, C6700 and ARM chips so you can use the same JTAG emulator across
processor families (provided you have the correct emulation drivers and Code Composer for
that family).
1. Click on the code composer studio. And create the project your own. i.e is shown below
3. Write the program in programming window and save the file in your project.i.e *.c
RESULT:
SIMULATION RESULT:
1.5
1
u
0.5
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
t
2
1
delta(
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
t
5
r
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
t
MATLAB CODE:
SIMULATION RESULT:
1.5
1
u(t-
0.5
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
t
20
delta(t+3
10
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
t
30
20
2r(4
10
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
t
RESULT:
UNDER MODULATION(M<1)
OVER MODULATION(M>1)
enter the value of mu2
RESULT:
ws=0.5;
wp=0.875;
rp=0.2;
rs=40;
[N,WN]=buttord(wp,ws,rp,rs,'s');
[B,A]=butter(N,WN,'high','s');
w=0:0.01:pi;
[H1,om]=freqs(B,A,w);
m=20*log10(abs(H1));
an=angle(H1);
subplot(2,1,1);
plot(om/pi,m);
grid;
subplot(2,1,2);
plot(om/pi,an);
ws=0.24;
wp=0.35;
rp=0.29;
rs=29;
[N,WN]=cheb1ord(wp,ws,rp,rs,'s');
[B,A]=cheby1(N,rp,WN,'high','s');
w=0:0.01:pi;
[H,om]=freqs(B,A,w);
m=20*log10(abs(H));
an=angle(H);
subplot(2,1,1);
plot(om/pi,m);
grid;
subplot(2,1,2);
plot(om/pi,an);
grid;
Aim:Design an Analog CHEBYSHEV TYPE-2 highpass filter with rp=0.34 dB of ripple in the
passband,, and at least rs=34 dB of attenuation in the stopband, with ws=0.28 and wp=0.32.
Plot the filter's frequency response
ws=0.28;
wp=0.32;
rp=0.34;
rs=34;
[N,WN]=cheb2ord(wp,ws,rp,rs,'s');
[B,A]=cheby2(N,rs,WN,'high','s');
w=0:0.01:pi;
[H,om]=freqs(B,A,w);
m=20*log10(abs(H));
an=angle(H);
subplot(2,1,1);
plot(om/pi,m);
grid;
subplot(2,1,2);
plot(om/pi,an);
grid;
Aim:Design an Analog BUTTERWORTH LOW PASS filter with rp=0.2 dB of ripple in the
passband, , and at least rs=40 dB of attenuation in the stopband, with ws=0.875 and wp=0.5.
Plot the filter's frequency response
ws=0.875;
wp=0.5;
rp=0.2;
rs=40;
[N,WN]=buttord(wp,ws,rp,rs,'s');
[B,A]=butter(N,WN,'low','s');
w=0:0.01:pi;
[H1,om]=freqs(B,A,w);
m=20*log10(abs(H1));
an=angle(H1);
subplot(2,1,1);
plot(om/pi,m);
grid;
subplot(2,1,2);
plot(om/pi,an);
grid;
wp=0.24;
ws=0.35;
rp=0.29;
rs=29;
[N,WN]=cheb1ord(wp,ws,rp,rs,'s');
[B,A]=cheby1(N,rp,WN,'low','s');
w=0:0.01:pi;
[H,om]=freqs(B,A,w);
m=20*log10(abs(H));
an=angle(H);
subplot(2,1,1);
plot(om/pi,m);
grid;
subplot(2,1,2);
plot(om/pi,an);
grid;
Aim:Design an Analog CHEBYSHEV TYPE-2 LOW PASS filter with rp=0.34 dB of ripple in
the passband, , and at least rs=34 dB of attenuation in the stopband, with ws=0.32 and wp=0.28
Plot the filter's frequency response
wp=0.28;
ws=0.32;
rp=0.34;
rs=34;
[N,WN]=cheb2ord(wp,ws,rp,rs,'s');
[B,A]=cheby2(N,rs,WN,'low','s');
w=0:0.01:pi;
[H,om]=freqs(B,A,w);
m=20*log10(abs(H));
an=angle(H);
subplot(2,1,1);
plot(om/pi,m);
grid;
subplot(2,1,2);
plot(om/pi,an);
grid;
RESULT:
Aim: To design FIR(LPF/HPF) filters using Rectangular, Triangular and Kaiser windows with 0.04 dB
of ripple in the passband, defined from 0 to 1500 Hz, and at least 0.02 dB of attenuation in the
stopband, defined from 2000 Hz to the Nyquist frequency (8000 Hz). Plot the frequency response of
each filter.(Design a Kaiser Window with P=5.8)
clc;
clear all;
close
all;
rp=0.04;
rs=0.02;
fp=1500;
fs=2000;
f=8000;
wp=2*fp/f;
ws=2*fs/f;
wp
ws
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if (rem(n,2)~=0)
n1=n;
n=n-1;
end
n1
SIMULATION RESULTS:
50 50
0 0
Gain in dB --
Gain in dB --
-50 -50
-100 -100
0 0.5 1 0 0.5 1
Normalised frequency Normalised frequency
50 20
0
Gain in dB --
Gain in dB -->
0 -20
-40
-50
-60
0 0.5 1
-100
0 0.5 1 Normalised frequency
Normalised frequency
y=boxcar(n1);
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
y=boxcar(n1);
n1
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
wn=[wp ws];
y=boxcar(n1);
wn
n1
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);
plot(o/pi,m);
ylabel('Gain in dB -->');
wn=[wp ws];
y=boxcar(n1);
n1
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
clc;
clear all;
close
all;
rp=0.04;
rs=0.02;
fp=1500;
fs=2000;
f=8000;
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if (rem(n,2)~=0)
SIMULATION RESULTS:
20 10
0
Gain in dB --
Gain in dB --
0
-10
-20 -20
-40 -30
0 0.5 1 0 0.5 1
Normalised frequency Normalised frequency
20 5
0 0
Gain in dB -->
Gain in dB -->
-20 -5
-40 -10
0 0.5 1 0 0.5 1
Normalised frequency Normalised frequency
n=n-1;
end
n1
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
n1
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
n1
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
wn=[wp ws];
y=triang(n1);
n1
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
clc;
clear all;
close all;
rp=0.02;
rs=0.01;
fp=1000;
fs=1500;
f=10000;
beta=5.8;
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13; dem=14.6*(fs-fp)/f;
SIMULATION RESULTS:
50 50
0
0
Gain in dB --
-50
Gain in dB --
-50
-100
-100
-150
-150
0 0.5 1
0 0.5 1
Normalised frequency
Normalised frequency
50
5
0
0
Gain in dB -->
Gain in dB -->
-50
-5
-100
-10
-150
-15
0 0.5 1
0 0.5 1
Normalised frequency
Normalised frequency
n1=n+1;
if (rem(n,2)~=0)
n1=n;
n=n-1;
end
%low pass
y=kaiser(n1,beta);
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
%high pass
y=kaiser(n1,beta);
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
%band pass
y=kaiser(n1,beta);
wn=[wp ws];
wn
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
%band stop
y=kaiser(n1,beta);
wn=[wp ws];
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
RESULT:
clc;
clear all;
close all;
wp = 0.5*pi; % digital passband frequency in Hz (normalized)
ws = 0.75*pi; % digital stopband frequency in Hz (normalized)
Rp=20*log10(1/sqrt(2)); % passband ripple in dB
Rp=-Rp;
As = 20*log10(0.2); % stopband attenuation in dB
As=-As;
% Analog Prototype Specifications:
Fs = 1; T = 1/Fs;
OmegaP = wp/T; % prewarp prototype passband frequency
OmegaS = ws/T; % prewarp prototype stopband frequency
% Analog butterworth Prototype Filter Calculation:
[n omegac]=buttord(OmegaP, OmegaS, Rp, As,'s');
[c d] = butter(n,omegac,'s');
% Bilinear Transformation:
[b, a] = impinvar(c, d, Fs);
%
[h db] = freqz(b,a); plot(db/pi,20*log10(abs(h)));
Axis ([0 1 -20 1])
grid
xlabel('frequency (Hz)');
ylabel('decibels');
title('Magnitude in dB');
% Bilinear transformation:
clc;;
clear all;
close all;
wp = 0.75*pi; % digital passband frequency in Hz (normalized)
ws = 0.5*pi; % digital stopband frequency in Hz (normalized)
Rp=20*log10(1/sqrt(2)); % passband ripple in dB
Rp=-Rp;
As = 20*log10(0.2); % stopband attenuation in dB
As=-As;
% Analog Prototype Specifications:
Fs = 1;
T = 1/Fs;
OmegaP = (2/T)*tan(wp/2); % prewarp prototype passband frequency
OmegaS = (2/T)*tan(ws/2); % prewarp prototype stopband frequency
% Analog butterworth Prototype Filter Calculation:
[n omegac]=buttord(OmegaP, OmegaS, Rp, As,'s');
[c d] = butter(n,omegac,'high','s');
% Bilinear Transformation:
[b, a] = bilinear(c, d, Fs);
[h db] = freqz(b,a);
plot(db/pi,20*log10(abs(h)));
axis([0 1 -20 1])
grid
xlabel('frequency (Hz)');
ylabel('decibels');
title('Magnitude in dB');
clc;;
clear all;
close all;
wp = 0.75*pi; % digital passband frequency in Hz (normalized)
ws = 0.5*pi; % digital stopband frequency in Hz (normalized)
Rp=20*log10(1/sqrt(2)); % passband ripple in dB
Rp=-Rp;
As = 20*log10(0.2); % stopband attenuation in dB
As=-As;
% Analog Prototype Specifications:
Fs = 1;
T = 1/Fs;
OmegaP = wp/T; % prewarp prototype passband frequency
OmegaS = ws/T; % prewarp prototype stopband frequency
% Analog butterworth Prototype Filter Calculation:
[n omegac]=buttord(OmegaP, OmegaS, Rp, As,'s');
[c d] = butter(n,omegac,'high','s');
% Bilinear Transformation:
[b, a] = impinvar(c, d, Fs);
[h db] = freqz(b,a);
plot(db/pi,20*log10(abs(h)));
grid
xlabel('frequency (Hz)');
ylabel('decibels');
title('Magnitude in dB');
RESULT:
SIMULATION RESULTS:
60
40
20
real
-20
0 1 2 3 4 5 6 7 8 9
k
20
10
0
imaginery
-10
-20
0 1 2 3 4 5 6 7 8 9
k
SOFTWARE USED :
MATLAB s/w.
MATLAB PROGRAM:
clc;
n =length(x)
y = fft(x,n);
k=0:n-1;
subplot(2,1,1)
stem(k,real(y));
xlabel('k');
ylabel('real value');
stem(k,imag(y));
xlabel('k');
ylabel('imaginery value');
RESULT:
LINEAR CONVOLUTION
AIM: To Write a program to compute the response of a discrete LTI system with input sequence
x(n)={1,1,2,2} and impulse response h(n)={1,1,2, 2} by using linear convolution on TMS320C6713
DSP kit.
TOOLS REQUIRED:
THEORY:
Convolution is a special operation, operated between two signals and which includes
the following operations.
❖ Folding.
❖ Shifting.
❖ Multiplication.
❖ Addition
Convolution sum is useful to obtain the response of discrete LTI system with input x(n)
and impulse response h(n).
h(n)
x(n) y(n)
∞
❖ Linear Convolution.
❖ Circular Convolution.
Linear convoluted sequence y(n) between x(n) with duration N1and h(n) with
duration N2 is defined as
y(n) = N –1
Σ x(m)h(n – m)
m=0
DFT does not support linear convolution, because of x(n) and h(n) are of different
durations. That’s why we can go for circular convolution.
PROCEDURE:
#include<stdio.h>
int x[20],h[20],y[20],N1,N2,n,m;
main()
scanf("%d",&N1);
scanf("%d",&N2);
INPUT:
Enter the length of input sequence x(n) :N1= 4
MODEL GRAPH:
THEORETICAL VALIDATION:
scanf("%d",&x[n]);
for(n=0;n<N2;n++)
scanf("%d",&h[n]);
for(n=0;n<N1;n++) printf("\t
%d",x[n]);
for(n=0;n<N2;n++) printf("\t
%d",h[n]); for(n=0;n<N1+N2-1;n++)
y[n]=0;
for(m=0;m<=n;m++)
y[n]=y[n]+x[m]*h[n-m];
for(n=0;n<N1+N2-1;n++)
printf("\t%d",y[n]) ;
RESULT:
CIRCULAR CONVOLUTION
AIM: To Write a program to compute the response of a discrete LTI system with input sequence
x(n)={1,2,3,4} and impulse response h(n)={1,2,3,4} by using Circular convolution on TMS320C6713
DSP kit.
TOOLS REQUIRED:
THEORY:
Let h (n) and x (n) be finite-length sequences of length N with N-point DFTs H (k) and
X(k) respectively. The sequence that has a DFT equal to the product Y(k)=H(k)X(k) is
「N –1 ~ ~ º 「 N –1 ~ ~ º
y(n) = |Σ h (k )x (n – k )| R N (n) = |Σ h (n – k)x (k ) | R N (n)
¬k =0 ] ¬k =0 ]
Where ~ ~
x (n) h (n) are the periodic extensions of the sequences x(n) and h(n),respectively.
and
~
Because h (n) =h(n) for 0 ≤ n ≤ N, the sum in equation may also be written as
「 N –1 ~ º
y(n) = |Σ h(k )x (n – k ) | R N (N )
¬k =0 ]
The sequence y(n) in the above equation is the C-point circular convolution of h(n) with
x(n), and it is written as
The circular convolution of two finite-length sequences h(n) and x(n) is equivalent to one
~
period of the periodic convolution of the periodic sequences h ~
and x (n),
(n)
~
y(n) = h(n) x(n) = ~ N
The N-point circular convolution of x(n) with h(n) is related to y(n) as follows:
「∞
º
h(n) x(n) = Σ kN ) R (n)
| y(n + |N
¬k =–∞ ]
In other words, the circular convolution of two sequences is found by performing the linear
convolution and aliasing the result.
An important property that follows from above eq. is that if y(n) is of the length N or
less,y(n-kN)RN(n)=0 for k≠0 and
h(n) x(n) = h(n) * x(n)
that is, circular convolution is equivalent to linear convolution. Thus, if h(n) and x(n) are finite-
length sequences of length N1 and N2, respectively, y(n)=h(n)*x(n) is of length N1+N2-1, and
the C-point circular convolution is equivalent to linear convolution provided N ≥ N1+ N2 –1.
PROCEDURE:
MODEL GRAPH:
THEORETICAL VALIDATION:
/*circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{ y[k]=
0;
/*circular shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf("The circular convolution\n");
for(i=0;i<n;i++) printf("%d\
t",y[i]);
}
RESULT:
SOFTWARE USED:
FFT ALGORITHM:
1. Pad input sequence of N samples with ZERO’s until the number of samples is the nearest
power of two e.g. 500 samples are padded to 512.
2. Bit reverse the input sequence
Ex: 3 = 011 goes to 110 = 6.
3. Compute (N/2) two sample DFT’s from the shuffled inputs
4. Compute (N/4) four sample DFT’s from the two sample DFT’s
5. Compute (N/2) eight sample DFT’s from the four sample DFT’s
6. Until all the samples combine into one N-sample DFT.
PROCEDURE:
MODEL GRAPH:
samples[i].real=0.0;
samples[i].imag=0.0;
}
for (i = 0 ; i < PTS ; i++) //swap buffers
{
samples[i].real=iobuffer[i]; //buffer with new data
/* iobuffer[i] = x1[i]; //processed frame to iobuffer*/
}
for (i = 0 ; i < PTS ; i++)
samples[i].imag = 0.0; //imag components = 0
FFT(samples,PTS); //call function FFT.c
for (i = 0 ; i < PTS ; i++) //compute magnitude
{
x1[i] = sqrt(samples[i].real*samples[i].real
+ samples[i].imag*samples[i].imag);///32;
}
}
RESULT:
do
num_stages +=1;
i = i*2;
}while (i!=N);
index = 0;
lower_leg = upper_leg+leg_diff;
(Y[lower_leg]).real = temp2.real*(w[index]).real
-temp2.imag*(w[index]).imag;
(Y[lower_leg]).imag = temp2.real*(w[index]).imag
+temp2.imag*(w[index]).real;
(Y[upper_leg]).real = temp1.real;
(Y[upper_leg]).imag = temp1.imag;
index += step;
leg_diff = leg_diff/2;
step *= 2;
j = 0;
k = N/2;
while (k <= j)
j=j-
k; k =
k/2;
j=j+
k; if
(i<j)
temp1.real = (Y[j]).real;
temp1.imag = (Y[j]).imag;
(Y[j]).real = (Y[i]).real;
(Y[j]).imag = (Y[i]).imag;
(Y[i]).real = temp1.real;
(Y[i]).imag = temp1.imag;
return;
#define PI 3.14159265358979
float y[128];
main()
float j,sum=0.0 ;
int n,k,i,a;
for(i=0,j=0;i<PTS;i++)
samples[i].real=0.0;
samples[i].imag=0.0;
for(n=0;n<PTS;n++)
sum=0;
for(k=0;k<PTS-n;k++)
MODEL GRAPH:
iobuffer[n] = sum;
x1[i] = sqrt(samples[i].real*samples[i].real
+ samples[i].imag*samples[i].imag);
RESULT:
10
d[
5
n]
amplitud
0 s[
-5 time index
0 5
8
6 y[n]
s[n]
4
amplitud
2
0
time index
0 5101520253035404550
Expt.No: Date:
MATLAB Software,
Personal Computer.
PROGRAM:
clc;
clear all;
close all;
R = 51;
d = 0.8*(rand(R,1) - 0.5);
m = 0:R-1;
s = 2*m.*(0.9.^m);
x = s+d';
subplot(2,1,1);
plot(m,d','r-',m,s,'g-',m,x,'b-.');
xlabel('time index');
ylabel('amplitude');
legend('d[n]','s[n]','x[n]');
grid;
x1 = [0 0 x];
x2 = [0 x 0];
x3 = [x 0 0];
y = (x1 + x2 + x3)/3;
subplot(2,1,2);
plot(m,y(2:R+1),'r-',m,s,'g-.');
legend('y[n]','s[n]');
xlabel('time index');
ylabel('amplitude');
grid;
RESULT: