Upload
anonymous-ndsvh2so
View
217
Download
0
Embed Size (px)
Citation preview
7/30/2019 Final Dsp Lab 2-06-12
1/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
1SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
TABLE OF CONTENTS
S.NO. NAME OF THE EXPERIMENT PAGE NO
1 To study the architecture of DSP chipsTMS 320CSA/Instructions
5
2 To verify Linear Convolution 19
3 To verify Circular Convolution 23
4 To design FIR filter (LP/HP) using Windowing technique:
a. Using Rectangular Windowb. Using Triangular Windowc. Using Kaiser Window 27
5 To design IIR filter (LP/HP) 39
6 5. Npoint FFT algorithm47
7 MATLAB program to generate sum of sinusoidal signal algorithm55
8 MATLAB program to find frequency response of analog LP/HP
filters 59
9 To compute Power Density Spectrum of a sequence 67
10 To find the FFT of given 1-D signal and plot 75
ADDITIONAL EXPERIMENTS
11 Basic signals generation using MATLAB 83
12 Signal smoothing using MATLAB 91
7/30/2019 Final Dsp Lab 2-06-12
2/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
2SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
7/30/2019 Final Dsp Lab 2-06-12
3/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
3SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
LAB INTERNAL EVALUATION
S.No Name of the Experiment Date Remarks
7/30/2019 Final Dsp Lab 2-06-12
4/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
4SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
TMS320C6713 DSK Overview Block Diagram
7/30/2019 Final Dsp Lab 2-06-12
5/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
5SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
TO STUDY THE ARCHITECTURE OF DSP CHIPS
TMS 320 CSA / INSTRUCTIONS
AIM: To study the architecture of DSP processor TMS 320C6713 / Instructions.
TOOLS REQUIRED:
TMS 320 C6713Kit,
Code Composer Studio Software,
Personal Computer
The C6713 Digital Signal Processor (DSP) Starter Kit (DSK) builds on Texas
Instruments (TI's) industry-leading line of low cost, easy-to-use DSK development boards.
The high-performance board features the TMS320C6713 floating-point DSP. Capable of
performing 1350 Million Floating-point Operations Per Second (MFLOPS), the C6713 DSP
makes the C6713 DSK the most powerful DSK development board. The DSK is USB port
interfaced platform that allows to efficiently develop and test applications for the C6713. The
DSK consists of a C6713-based printed circuit board that will serve as a hardware reference
design for TIs customers products. With extensive host PC and target DSP software
support, including bundled TI tools, the DSK provides ease-of-use and capabilities that are
attractive to DSP engineers.
The C6713 DSK has a TMS320C6713 DSP onboard that allows full-speed verification of
code with Code Composer Studio. The C6713 DSK provides:
A USB Interface SDRAM and ROM An analog interface circuit for Data conversion (AIC) An I/O port Embedded JTAG emulation support
The C6711 DSK includes a stereo codec. This analog interface circuit (AIC) has the
following characteristics:
1. High-Performance Stereo Codec 90-dB SNR Multibit Sigma-Delta ADC (A-weighted at 48 kHz) 100-dB SNR Multibit Sigma-Delta DAC (A-weighted at 48 kHz) 1.42 V3.6 V Core Digital Supply: Compatible With TI C54x DSP Core
Voltages 2.7 V3.6 V Buffer and Analog Supply: Compatible Both TI C54x DSP
Buffer Voltages
8-kHz96-kHz Sampling-Frequency Support
7/30/2019 Final Dsp Lab 2-06-12
6/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
6SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
7/30/2019 Final Dsp Lab 2-06-12
7/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
7SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
2. Software Control Via TI McBSP-Compatible Multiprotocol Serial Port I 2 C-Compatible and SPI-Compatible Serial-Port Protocols Glueless Interface to TI McBSPs
3. Audio-Data Input/Output Via TI McBSP-Compatible Programmable Audio Interface I 2 S-Compatible Interface Requiring Only One McBSP for both ADC and
DAC
Standard I 2 S, MSB, or LSB Justified-Data Transfers 16/20/24/32-Bit Word Lengths
The C6713DSK has the following features:
The 6713 DSK is a low-cost standalone development platform that enables customers to
evaluate and develop applications for the TI C67XX DSP family. The DSK also serves as a
hardware reference design for the TMS320C6713 DSP. Schematics, logic equations and
application notes are available to ease hardware development and reduce time to market.
The DSK uses the 32-bit EMIF for the SDRAM (CE0) and daughter card expansion interface(CE2 and CE3). The Flash is attached to CE1 of the EMIF in 8-bit mode.
An on-board AIC23 codec allows the DSP to transmit and receive analog signals. McBSP0
is used for the codec control interface and McBSP1 is used for data. Analog audio I/O is
done through four 3.5mm audio jacks that correspond to microphone input, line input, line
output and headphone output. The codec can select the microphone or the line input as the
active input. The analog output is driven to both the line out (fixed gain) and headphone
(adjustable gain) connectors. McBSP1 can be re-routed to the expansion connectors in
software.
The DSK includes 4 LEDs and 4 DIP switches as a simple way to provide the user with
interactive feedback. Both are accessed by reading and writing to the CPLD registers.
An included 5V external power supply is used to power the board. On-board voltage
regulators provide the 1.26V DSP core voltage, 3.3V digital and 3.3V analog voltages. A
voltage supervisor monitors the internally generated voltage, and will hold the board in reset
until the supplies are within operating specifications and the reset button is released. If
desired, JP1 and JP2 can be used as power test points for the core and I/O power supplies.
Code Composer communicates with the DSK through an embedded JTAG emulator with a
USB host interface. The DSK can also be used with an external emulator through the
external JTAG connector.
TMS320C6713 DSP Features
Highest-Performance Floating-Point Digital Signal Processor (DSP): Eight 32-Bit Instructions/Cycle 32/64-Bit Data Word 300-, 225-, 200-MHz (GDP), and 225-, 200-, 167-MHz Clock Rates 3.3-, 4.4-, 5-, 6-Instruction Cycle Times 2400/1800, 1800/1350, 1600/1200, and 1336/1000 MIPS /MFLOPS Rich Peripheral Set, Optimized for Audio Highly Optimized C/C++ Compiler Extended Temperature Devices Available
7/30/2019 Final Dsp Lab 2-06-12
8/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
8SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
TMS320C6713 DSP Block Diagram
7/30/2019 Final Dsp Lab 2-06-12
9/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
9SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Advanced Very Long Instruction Word (VLIW) TMS320C67x DSP Core Eight Independent Functional Units:
Two ALUs (Fixed-Point) Four ALUs (Floating- and Fixed-Point) Two Multipliers (Floating- and Fixed-Point)
Load-Store Architecture with 32 32-Bit General-Purpose Registers Instruction Packing Reduces Code Size All Instructions Conditional
Instruction Set Features Native Instructions for IEEE 754
Single- and Double-Precision Byte-Addressable (8-, 16-, 32-Bit Data) 8-Bit Overflow Protection Saturation; Bit-Field Extract, Set, Clear; Bit-Counting; Normalization
L1/L2 Memory Architecture 4K-Byte L1P Program Cache (Direct-Mapped) 4K-Byte L1D Data Cache (2-Way) 256K-Byte L2 Memory Total: 64K-Byte L2 Unified Cache/Mapped RAM, and 192K-
Byte Additional L2 Mapped RAM
Device Configuration Boot Mode: HPI, 8-, 16-, 32-Bit ROM Boot Endianness: Little Endian, Big Endian
32-Bit External Memory Interface (EMIF) Glueless Interface to SRAM, EPROM, Flash, SBSRAM, and SDRAM 512M-Byte Total Addressable External Memory Space
Enhanced Direct-Memory-Access (EDMA) Controller (16 Independent Channels) 16-Bit Host-Port Interface (HPI) Two Multichannel Audio Serial Ports (McASPs)
Two Independent Clock Zones Each (1 TX and 1 RX) Eight Serial Data Pins Per Port:
Individually Assignable to any of the Clock Zones
Each Clock Zone Includes: Programmable Clock Generator Programmable Frame Sync Generator TDM Streams From 2-32 Time Slots Support for Slot Size:
8, 12, 16, 20, 24, 28, 32 Bits
Data Formatter for Bit Manipulation Wide Variety of I2S and Similar Bit Stream Formats Integrated Digital Audio Interface Transmitter (DIT) Supports:
S/PDIF, IEC60958-1, AES-3, CP-430 Formats Up to 16 transmit pins Enhanced Channel Status/User Data
Extensive Error Checking and Recovery Two Inter-Integrated Circuit Bus (I2C Bus) Multi-Master and Slave Interfaces
Two Multichannel Buffered Serial Ports: Serial-Peripheral-Interface (SPI) High-Speed TDM Interface AC97 Interface
7/30/2019 Final Dsp Lab 2-06-12
10/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
10SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Procedure used for running Code Composer Studio:
1. Click on the Code Composer Studio. And create the project of your own i.e. as shownbelow:
2. To create the new source file, Click on File-> NEW-> Source file
3. Write the program in edit window and save the file in your project as *.C (for C
Program) or *.asm (Assembly Language Program)
7/30/2019 Final Dsp Lab 2-06-12
11/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
11SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
TMS320C6713 CPU Datapath
Two 32-Bit General-Purpose Timers Dedicated GPIO Module With 16 pins (External Interrupt Capable) Flexible Phase-Locked-Loop (PLL) Based Clock Generator Module IEEE-1149.1 (JTAG ) Boundary-Scan-Compatible Package Options:
208-Pin Power PAD Plastic (Low-Profile) Quad Flat pack (PYP) 272-BGA Packages (GDP and ZDP)
0.13-m/6-Level Copper Metal Process CMOS Technology
3.3-V I/Os, 1.2 -V Internal (GDP & PYP) 3.3-V I/Os, 1.4-V Internal (GDP)(300 MHz only)The TMS320C6713 CPU contains :
1. Program Fetch unit2. Instruction dispatch unit3. Instruction decode unit4. Two data paths, each with four functional units5. 32 32-bit registers6. Control registers7. Control logic8. Test, emulation, and interrupt logic
7/30/2019 Final Dsp Lab 2-06-12
12/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
12SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
4. Click on Project ->Add files to Project-> click your Source file.
5. Click on Project ->Add files to Project ->C:\CCStudio\cgtools\lib\rts6700.lib
(File type is Object and Library Files *.o, *.l)
6. Click Project ->Add files to Project -:\CCStudio\Tutorial\dsk6713\hello1\hello.cmd(File type is Linker Command File *.cmd)
7/30/2019 Final Dsp Lab 2-06-12
13/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
13SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Mapping Between Instructions and Functional Units : The following Table shows which
instructions can be executed in which of the functional units for fixed point instructions.
7/30/2019 Final Dsp Lab 2-06-12
14/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
14SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
6. Click on Project -> Compile your file.
8. Click on Project-> Build your File.
9. Click on File-> Load project.
7/30/2019 Final Dsp Lab 2-06-12
15/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
15SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Mapping Between Instructions and Functional Units : The following Table shows which
instructions can be executed in which of the functional units for floating point instructions.
7/30/2019 Final Dsp Lab 2-06-12
16/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
16SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
10. Disassembly file is available in the below Window.
11. Click on Debug -> Run (see the result in the Output window.)
7/30/2019 Final Dsp Lab 2-06-12
17/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
17SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Program:
.global _main
_main:
MVKL .S1 -5, A4
ABS .L1 A4, A4
ZERO .L1 A3ADD .L1 A4, A4, A3
SUB .L1 A3, A4, A5
MPY .M1 A3, A4, A0
NOP 1
SUB .L2X A0, B0, B0
B B3
NOP 5
RESULT:
7/30/2019 Final Dsp Lab 2-06-12
18/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
18SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
MODEL GRAPH:
7/30/2019 Final Dsp Lab 2-06-12
19/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
19SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
TO VERIFY LINEAR CONVOLUTION
AIM: To write a program to compute the response of a discrete LTI system with input
sequence x(n) and impulse response h(n) by using linear convolution.
TOOLS REQUIRED:
TMS 320 C6713Kit,
Code Composer Studio Software,
Personal Computer
PROCEDURE:
1. Create a Project in Code Composer Studio.2. Create a Source file in C language for Linear Convolution and add it to the project.3. Add both hello.cmd & rts6700.lib files to the current project folder from the
following locations:
C:\CCStudio\tutorial\dsk6713\hello1 and C:\CCStudio\c6000\cgtools\lib
4. Compile C file for debugging errors.5. Build the project.6. Load Program (.out file) into DSK from file menu.7. Run the program from Debug menu.8. Plot the Graph of linear convolution from Viewgraph menu.
C-PROGRAM FOR LINEAR CONVOLUTION:
#include
int x[20],h[20],y[20],N1,N2,n,m;
main()
{
printf("Enter the length of input sequence x(n)\t:N1=");
scanf("%d",&N1);
printf("Enter the length of impulse response h(n)\t:N2=");
scanf("%d",&N2);
printf("Enter %d samples for input sequence x(n):\n",N1);
for(n=0;n
7/30/2019 Final Dsp Lab 2-06-12
20/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
20SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
GRAPH:
7/30/2019 Final Dsp Lab 2-06-12
21/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
21SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
for(n=0;n
7/30/2019 Final Dsp Lab 2-06-12
22/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
22SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
MODEL GRAPH:
7/30/2019 Final Dsp Lab 2-06-12
23/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
23SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
TO VERIFY CIRCULAR CONVOLUTION
AIM: To write a program to compute the response of a discrete LTI system with input
sequence x(n) and impulse response h(n) by using Circular convolution.
TOOLS REQUIRED:
TMS 320 C6713Kit,
Code Composer Studio Software,
Personal Computer
PROCEDURE:
1. Create a Project in Code Composer Studio.2. Create a Source file in C language for Circular Convolution and add it to the project.3. Add both hello.cmd & rts6700.lib files to the current project folder from the
following locations:
C:\CCStudio\tutorial\dsk6713\hello1 and C:\CCStudio\c6000\cgtools\lib
4. Compile C file for debugging errors.5. Build the project.6. Load Program (.out file) into DSK from file menu.7. Run the program from Debug menu.8. Plot the Graph of Circular convolution from Viewgraph menu.
C-PROGRAM FOR CIRCULAR CONVOLUTION:
#include
int m,n,x[30],h[30],y[30],i,j,temp[30],k,x2[30],a[30];
void main()
{
printf(" enter the length of the first sequence\n");
scanf("%d",&m);
printf(" enter the length of the second sequence\n");
scanf("%d",&n);
printf(" enter the first sequence\n");
for(i=0;i
7/30/2019 Final Dsp Lab 2-06-12
24/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
24SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
GRAPH:
CALUCLATION:
Enter the length of input sequence x(n) :N1=
Enter the length of impulse response h(n):N2=
Enter 4 samples for input sequence x(n):
Enter 4 samples for impulse response h(n):
Input sequence after zero padding
x(n)=
Impulse Response after zero padding
h(n)=
Response of LT1 system is
y(n)=
7/30/2019 Final Dsp Lab 2-06-12
25/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
25SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
{ if(m>n) /* Pad the smaller sequence with zero*/
for(i=n;i
7/30/2019 Final Dsp Lab 2-06-12
26/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
26SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
OUTPUT: Rectangular Window
OUTPUT: Triangular Window
0 0.5 1-60
-40
-20
0
Gain in dB -->
Normalised
0 0.5 1-40
-20
0
20
Gain in dB -->
Normalised
0 0.5 1-60
-40
-20
0Gain in dB -->
Normalised
0 0.5 1-15
-10
-5
0
5Gain in dB -->
Normalised
0 0.5 1-100
-50
0
50Gain in dB -->
Normalised
0 0.5 1-100
-50
0
50Gain in dB -->
Normalised
0 0.5 1-100
-50
0
50Gain in dB -->
Normalised
0 0.5 1-60
-40
-20
0
20Gain in dB -->
Normalised
7/30/2019 Final Dsp Lab 2-06-12
27/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
27SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
DESIGN OF FIR FILTER USING WINDOWING
TECHNIQUES
AIM: To write a program to design a FIR filters using different windowing techniques.
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
ALGORITHM:
1. Get the pass band and stop band ripples.
2. Get the pass band and stop band edge frequencies.
3. Get the sampling frequency.
4. Calculate the order of filter.
5. Find filter coefficients.
6. Draw the magnitude and phase response.
MATLAB PROGRAM FOR FIR FILTER USING RECTANGULAR WINDOW:
clc;
clear all;
close all;
fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
f=input ('enter the sample frequency');
wp=2*fp;
ws=2*fs;w1=wp/f;
w2=ws/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)
n1=n;
n=n-1;
end
7/30/2019 Final Dsp Lab 2-06-12
28/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
28SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Kaiser window:
7/30/2019 Final Dsp Lab 2-06-12
29/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
29SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
%low pass filter
y=boxcar(n1);
n1
b=fir1(n,w1,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 filter
y=boxcar(n1);
n1
b=fir1(n,w1,'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 filter
wn=[w2 w1];
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 -->');
xlabel('Normalised frequency');
%band stop filter
wn=[w2 w1];
y=boxcar(n1);
n1
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
7/30/2019 Final Dsp Lab 2-06-12
30/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
30SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Gaph:
7/30/2019 Final Dsp Lab 2-06-12
31/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
31SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
m=20*log10 (abs(h));
subplot(2,2,4);
plot(o/pi,m);
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
MATLAB PROGRAM FOR FIR FILTER USING TRIANGULAR WINDOW:
clc;
clear all;
close all;
fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
f=input ('enter the sample frequency');
wp=2*fp;
ws=2*fs;
w1=wp/f;
w2=ws/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)
n1=n;
n=n-1;
end
%low pass filter
y=triang(n1);
n1
b=fir1(n,w1,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');
7/30/2019 Final Dsp Lab 2-06-12
32/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
32SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Graph:
7/30/2019 Final Dsp Lab 2-06-12
33/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
33SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
%high pass filter
y=triang(n1);
n1
b=fir1(n,w1,'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 filter
wn=[w2 w1];
y=triang(n1);
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 -->');
xlabel('Normalised frequency');
%band stop filter
wn=[w2 w1];
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');
7/30/2019 Final Dsp Lab 2-06-12
34/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
34SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Graph:
7/30/2019 Final Dsp Lab 2-06-12
35/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
35SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
MATLAB PROGRAM FOR FIR FILTER USING KAISER WINDOW:
clc;
clear all;
close all;
beta=0.5;
fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
f=input ('enter the sample frequency');
wp=2*fp;
ws=2*fs;
w1=wp/f;
w2=ws/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)
n1=n;n=n-1;
end
%low pass
y=kaiser(n1,beta);
b=fir1(n,w1,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,w1,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m);
7/30/2019 Final Dsp Lab 2-06-12
36/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
36SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
7/30/2019 Final Dsp Lab 2-06-12
37/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
37SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
ylabel('Gain in dB -->');
xlabel('Normalised frequency');
%band pass
y=kaiser(n1,beta);
wn=[w2 w1];
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 -->');
xlabel('Normalised frequency');
%band stop
y=kaiser(n1,beta);
wn=[w2 w1];
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:
7/30/2019 Final Dsp Lab 2-06-12
38/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
38SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
OUTPUT:
OUTPUT:
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-400
-300
-200
-100
0
(a) Normalised frequency
Gain in dB
BUTTERWORTH HIGH PASS FILTER
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4
-2
0
(b) Normalised frequency
Phase in radians
7/30/2019 Final Dsp Lab 2-06-12
39/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
39SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
To design IIR filter (LP/HP)
AIM: Design of IIR Butter worth, Chebyshevhigh pass & low pass digitalfilters using
MATLAB.
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
MATLAB PROGRAM FOR IIR BUTTERWORTH HIGH PASS FILTER:
clc;
clear all;
close all;
fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
f=input ('enter the sample frequency');
wp=2*pi*fp;
ws=2*pi*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=buttord(w1,w2,rp,rs);
[B,A]=butter(N,WN,'HIGH');
w=0:0.01:pi;
[H1,om]=freqz(B,A,w);
m=20*log10(abs(H1));
an=angle(H1);
subplot(2,1,1);
plot(om/pi,m);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('BUTTERWORTH HIGH PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
7/30/2019 Final Dsp Lab 2-06-12
40/92
7/30/2019 Final Dsp Lab 2-06-12
41/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
41SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
MATLAB PROGRAM FOR IIR BUTTERWORTH LOW PASS FILTER
clc;
clear all;
close all;
fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
f=input ('enter the sample frequency');
wp=2*pi*fp;
ws=2*pi*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=buttord(w1,w2,rp,rs);
[B,A]=butter(N,WN,'LOW');
w=0:0.01:pi;
[H1,om]=freqz(B,A,w);
m=20*log10(abs(H1));
an=angle(H1);
subplot(2,1,1);
plot(om/pi,m);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('BUTTERWORTH LOW PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
MATLAB PROGRAM FOR IIR CHEBYSHEV HIGH PASS FILTER:
clc;
clear all;
close all;
fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');
rp=input('enter the pass band ripple');
7/30/2019 Final Dsp Lab 2-06-12
42/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
42SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Graph:
7/30/2019 Final Dsp Lab 2-06-12
43/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
43SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
rs=input('enter the stop band ripple');
f=input ('enter the sample frequency');
wp=2*pi*fp;
ws=2*pi*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=cheb1ord(w1,w2,rp,rs);
[B,A]=cheby1(N,rp,WN,'high');
w=0:0.01:pi;
[H,om]=freqZ(B,A,w);
m=20*log10(abs(H));
an=angle(H);
subplot(2,1,1);
plot(om/pi,m);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('CHEBYSHEV TYPE-1 HIGH PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
MATLAB PROGRAM FOR IIR CHEBYSHEV LOW PASS FILTER:
clc;
clear all;
close all;fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
f=input ('enter the sample frequency');
wp=2*pi*fp;
ws=2*pi*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=cheb1ord(w1,w2,rp,rs);
7/30/2019 Final Dsp Lab 2-06-12
44/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
44SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
[B,A]=cheby1(N,rp,WN,'LOW');
Graph:
7/30/2019 Final Dsp Lab 2-06-12
45/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
45SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
w=0:0.01:pi;
[H,om]=freqZ(B,A,w);
m=20*log10(abs(H));
an=angle(H);
subplot(2,1,1);
plot(om/pi,m);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('CHEBYSHEV LOW PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
RESULT:
7/30/2019 Final Dsp Lab 2-06-12
46/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
46SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
GRAPH PROPERTY DIALOG SETTINGS:
MODEL GRAPH:
7/30/2019 Final Dsp Lab 2-06-12
47/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
47SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
N-POINT FFT ALGORITHM
AIM: To obtain the frequency spectrum of the given sampled data (input signal) by using
Fast Fourier Transform on TMS320C6713 DSK Kit (or Simulator).
TOOLS REQUIRED:
TMS 320 C6713Kit,
Code Composer Studio Software,
Personal Computer
PROCEDURE:
1. Create a Project in Code Composer Studio.2. Create Source files in C language for Main.C and FFT.C and add them to the project.3. Add both hello.cmd & rts6700.lib files to the current project folder from the
following locations:
C:\CCStudio\tutorial\dsk6713\hello1 and C:\CCStudio\c6000\cgtools\lib
4. Compile C file for debugging errors.5. Build the project.6. Load Program (.out file) into DSK from file menu.7. Run the program from Debug menu.8. Plot the Graph for input and output from Viewgraph menu.
CSOURCE CODE FOR MAIN.C
#include
#define PTS 8 //# of points for FFT
#define PI 3.14159265358979
typedef struct {float real,imag;} COMPLEX;
void FFT(COMPLEX *Y, int n); //FFT prototype
float iobuffer[PTS]; //as input and output buffer
float x1[PTS],a[PTS]={1,1,1,1,2,2,2,2},y1[PTS],y2[PTS];
short i; //general purpose index variable
short buffercount = 0; //number of new samples in iobuffer
short flag = 0; //set to 1 by ISR when iobuffer full
COMPLEX w[PTS]; //twiddle constants stored in w
COMPLEX samples[PTS]; //primary working buffer
main()
{
7/30/2019 Final Dsp Lab 2-06-12
48/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
48SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
7/30/2019 Final Dsp Lab 2-06-12
49/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
49SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
for (i = 0 ; i
7/30/2019 Final Dsp Lab 2-06-12
50/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
50SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
7/30/2019 Final Dsp Lab 2-06-12
51/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
51SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
int leg_diff; //difference between upper/lower leg
int num_stages = 0; //number of FFT stages (iterations)
int index, step; //index/step through twiddle constant
i = 1; //log(base2) of N points= # of stages
do
{
num_stages +=1;
i = i*2;
}while (i!=N);
leg_diff = N/2; //difference between upper&lower legs
step = (PTS*2)/N; //step between values in twiddle.h // 512
for (i = 0;i < num_stages; i++) //for N-point FFT
{
index = 0;
for (j = 0; j < leg_diff; j++)
{ for (upper_leg = j; upper_leg < N; upper_leg += (2*leg_diff))
{
lower_leg = upper_leg+leg_diff;
temp1.real = (Y[upper_leg]).real + (Y[lower_leg]).real;
temp1.imag = (Y[upper_leg]).imag + (Y[lower_leg]).imag;
temp2.real = (Y[upper_leg]).real - (Y[lower_leg]).real;
temp2.imag = (Y[upper_leg]).imag - (Y[lower_leg]).imag;
(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;
for (i = 1; i < (N-1); i++) //bit reversal for resequencing data
{
k = N/2;
while (k
7/30/2019 Final Dsp Lab 2-06-12
52/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
52SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
7/30/2019 Final Dsp Lab 2-06-12
53/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
53SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
k = k/2;
} j = j + k;
if (i
7/30/2019 Final Dsp Lab 2-06-12
54/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
54SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
MODEL GRAPH:
0 2 4 6 8 10 12 14 16 18 20-1
0
1
TIME INDEX
AMPLITUDE
SUM OF SIN WAVES
0 2 4 6 8 10 12 14 16 18 20-1
0
1
TIME INDEX
AMPLITUDE
0 2 4 6 8 10 12 14 16 18 20-2
0
2
TIME INDEX
AMPLITUDE
7/30/2019 Final Dsp Lab 2-06-12
55/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
55SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
MATLAB PROGRAM TO GENERATE SUM OF SINUSOIDAL
SIGNALS
AIM: To generate sum of sinusoidal signals using MATLAB
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
MATLAB PROGRAM:
clc;
clear all;close all;
t=0:0.01:20;
x1=sin(2*pi*t/5);
subplot(3,1,1);
plot(t,x1);
xlabel('TIME INDEX');
ylabel('AMPLITUDE');
title('SUM OF SIN WAVES');
x2=sin(2*pi*t/7);
subplot(3,1,2);
plot(t,x2);
xlabel('TIME INDEX');
ylabel('AMPLITUDE');
x=x1+x2;
subplot(3,1,3);plot(t,x);
xlabel('TIME INDEX');
ylabel('AMPLITUDE');
7/30/2019 Final Dsp Lab 2-06-12
56/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
56SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Graph:
7/30/2019 Final Dsp Lab 2-06-12
57/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
57SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Result:
7/30/2019 Final Dsp Lab 2-06-12
58/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
58SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
OUTPUT:
OUTPUT:
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 .8 0.9 1-400
-300
-200
-100
0
(a) Normalised frequency
Gain in dB
CHEBYSHEV TYPE-1 HIGH PASS FILTER
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 .8 0.9 1-4
-2
0
2
4
(b) Normalised frequency
Phase in radians
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1000
-500
0
500
(a) Normalised frequency
Gain in dB
BUTTERWORTH HIGH PASS FILTER
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4
-2
0
2
4
(b) Normalised frequency
Phase in radians
7/30/2019 Final Dsp Lab 2-06-12
59/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
59SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
MATLAB PROGRAM TO FIND FREQUENCY RESPONSE OF
ANALOG LP/HP FILTERS
AIM: Design of IIR Butter worthand ChebyshevLP/HP filters using MATLAB.
TOOLS REQUIRED:
MATLAB Software,
Personal Computer.
MATLAB PROGRAM FOR ANALOG BUTTERWORTH HIGH PASS FILTER:
clc;
clear all;
close all;
fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
f=input ('enter the sample frequency');
wp=2*pi*fp; ws=2*pi*fs;
w1=wp/f; w2=ws/f;
[N,WN]=buttord(w1,w2,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);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('BUTTERWORTH HIGH PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
7/30/2019 Final Dsp Lab 2-06-12
60/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
60SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
OUTPUT:
OUTPUT:
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-150
-100
-50
0
(a) Normalised frequency
Gain in dB
CHEBYSHEV LOW PASS FILTER
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 14
2
0
2
4
(b) Normalised frequency
Phase in radians
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-300
-200
-100
0
100
(a) Normalised frequency
Gain in dB
BUTTERWORTH LOW PASS FILTER
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4
-2
0
2
4
(b) Normalised frequency
Phase in radians
7/30/2019 Final Dsp Lab 2-06-12
61/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
61SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
MATLAB PROGRAM FOR ANALOG CHEBYSHEV HIGH PASS FILTER:
clc;
clear all;
close all;
fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
f=input ('enter the sample frequency');
wp=2*pi*fp;
ws=2*pi*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=cheb1ord(w1,w2,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);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('CHEBYSHEV TYPE-1 HIGH PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
7/30/2019 Final Dsp Lab 2-06-12
62/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
62SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Graph:
7/30/2019 Final Dsp Lab 2-06-12
63/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
63SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
MATLAB PROGRAM FOR ANALOG BUTTERWORTH LOW PASS FILTER:
clc;
clear all;
close all;
fp=input('enter the pass band frequency');fs=input('enter the stop band frequency');
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
f=input ('enter the sample frequency');
wp=2*pi*fp;
ws=2*pi*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=buttord(w1,w2,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);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('BUTTERWORTH LOW PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
MATLAB PROGRAM FOR ANALOG CHEBYSHEV LOW PASS FILTER:
clear all;
close all;
fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');rp=input('enter the pass band ripple');
7/30/2019 Final Dsp Lab 2-06-12
64/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
64SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Graph:
7/30/2019 Final Dsp Lab 2-06-12
65/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
65SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
rs=input('enter the stop band ripple');
f=input ('enter the sample frequency');
wp=2*pi*fp;
ws=2*pi*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=cheb1ord(w1,w2,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);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('CHEBYSHEV LOW PASS FILTER');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
grid;
RESULT:
7/30/2019 Final Dsp Lab 2-06-12
66/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
66SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Graph:
7/30/2019 Final Dsp Lab 2-06-12
67/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
67SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
TO COMPUTE POWER DENSITY SPECTRUM OF A
SEQUENCE
AIM: To write a Program to compute non real time Power Spectral Density.
TOOLS REQUIRED:
TMS 320 C6713Kit,
Code Composer Studio Software,
Personal Computer
PROCEDURE:
1. Create a Project in Code Composer Studio.2. Create Source files in C language for Main.C and FFT.C and add them to the project.3. Add both hello.cmd & rts6700.lib files to the current project folder from the
following locations:
C:\CCStudio\tutorial\dsk6713\hello1 and C:\CCStudio\c6000\cgtools\lib
4. Compile C file for debugging errors.5. Build the project.6. Load Program (.out file) into DSK from file menu.7. Run the program from Debug menu.8. Plot the Graph for input and output from Viewgraph menu.
C-SOURCE CODE FOR PSD.C
#include
#define PTS 128 //# of points for FFT
#define PI 3.14159265358979
typedef struct {float real,imag;} COMPLEX;
void FFT(COMPLEX *Y, int n); //FFT prototypefloat iobuffer[PTS]; //as input and output buffer
float x1[PTS],x[PTS]; //intermediate buffer
short i; //general purpose index variable
short buffercount = 0; //number of new samples in iobuffer
short flag = 0; //set to 1 by ISR when iobuffer full
float y[128];
COMPLEX w[PTS]; //twiddle constants stored in w
COMPLEX samples[PTS]; //primary working buffer
main()
{
7/30/2019 Final Dsp Lab 2-06-12
68/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
68SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
GRAPH PROPERTY DIALOG SETTINGS:
MODEL GRAPH:
7/30/2019 Final Dsp Lab 2-06-12
69/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
69SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
float j,sum=0.0 ;
int n,k,i,a;
for (i = 0 ; i
7/30/2019 Final Dsp Lab 2-06-12
70/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
70SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
GRAPH PROPERTY DIALOG SETTINGS:
MODEL GRAPH:
7/30/2019 Final Dsp Lab 2-06-12
71/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
71SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
int leg_diff; //difference between upper/lower leg
int num_stages = 0; //number of FFT stages (iterations)
int index, step; //index/step through twiddle constant
i = 1; //log(base2) of N points= # of stages
do
{
num_stages +=1;
i = i*2;
}while (i!=N);
leg_diff = N/2; //difference between upper&lower legs
step = (PTS*2)/N; //step between values in twiddle.h // 512
for (i = 0;i < num_stages; i++) //for N-point FFT
{
index = 0;
for (j = 0; j < leg_diff; j++)
{
for (upper_leg = j; upper_leg < N; upper_leg += (2*leg_diff))
{
lower_leg = upper_leg+leg_diff;
temp1.real = (Y[upper_leg]).real + (Y[lower_leg]).real;
temp1.imag = (Y[upper_leg]).imag + (Y[lower_leg]).imag;
temp2.real = (Y[upper_leg]).real - (Y[lower_leg]).real;
temp2.imag = (Y[upper_leg]).imag - (Y[lower_leg]).imag;
(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;
for (i = 1; i < (N-1); i++) //bit reversal for resequencing data
{
k = N/2;
while (k
7/30/2019 Final Dsp Lab 2-06-12
72/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
72SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
7/30/2019 Final Dsp Lab 2-06-12
73/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
73SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
j = j - k;
k = k/2;
} j = j + k;
if (i
7/30/2019 Final Dsp Lab 2-06-12
74/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
74SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
OUTPUT:
7/30/2019 Final Dsp Lab 2-06-12
75/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
75SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
TO FIND THE FFT OF GIVEN 1-D SIGNAL AND PLOT
AIM: To find the FFT of a given 1-D signal and plot the graph.
TOOLS REQUIRED:
TMS 320 C6713Kit,
Code Composer Studio Software,
Personal Computer
PROCEDURE:
1. Create a Project in Code Composer Studio.2. Create Source files in C language for Main.C and FFT.C and add them to the project.3. Add both hello.cmd & rts6700.lib files to the current project folder from the
following locations:
C:\CCStudio\tutorial\dsk6713\hello1 and C:\CCStudio\c6000\cgtools\lib
4. Compile C file for debugging errors.5. Build the project.6. Load Program (.out file) into DSK from file menu.7. Run the program from Debug menu.8. Plot the Graph for input and output from Viewgraph menu.
CSOURCE CODE FOR MAIN.C
#include
#define PTS 128 //# of points for FFT
#define PI 3.14159265358979
typedef struct {float real,imag;} COMPLEX;
void FFT(COMPLEX *Y, int n); //FFT prototype
float iobuffer[PTS]; //as input and output buffer
float x1[PTS]; //intermediate buffer
short i; //general purpose index variable
short buffercount = 0; //number of new samples in iobuffer
short flag = 0; //set to 1 by ISR when iobuffer full
COMPLEX w[PTS]; //twiddle constants stored in w
COMPLEX samples[PTS]; //primary working buffer
main(){
for (i = 0 ; i
7/30/2019 Final Dsp Lab 2-06-12
76/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
76SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
7/30/2019 Final Dsp Lab 2-06-12
77/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
77SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
w[i].imag =-sin(2*PI*i/(PTS*2.0)); //Im component of twiddle constants
}
for (i = 0 ; i < PTS ; i++) //swap buffers
{ iobuffer[i] =sin(2*pi*5*i/(PTS)); /*10- > freq,100 -> sampling freq*/
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;
}
}
CSOURCE CODE FOR FFT.C
#define PTS 128 //# of points for FFT
typedef struct {float real,imag;} COMPLEX;
extern COMPLEX w[PTS]; //twiddle constants stored in w
void FFT(COMPLEX *Y, int N) //input sample array, # of points
{
COMPLEX temp1,temp2; //temporary storage variables
int i,j,k; //loop counter variables
int upper_leg, lower_leg; //index of upper/lower butterfly leg
int leg_diff; //difference between upper/lower leg
int num_stages = 0; //number of FFT stages (iterations)
int index, step; //index/step through twiddle constant
i = 1; //log(base2) of N points= # of stages
do
{
num_stages +=1;
i = i*2;
7/30/2019 Final Dsp Lab 2-06-12
78/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
78SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
7/30/2019 Final Dsp Lab 2-06-12
79/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
79SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
}while (i!=N);
leg_diff = N/2; //difference between upper&lower legs
step = (PTS*2)/N; //step between values in twiddle.h // 512
for (i = 0;i < num_stages; i++) //for N-point FFT
{
index = 0;
for (j = 0; j < leg_diff; j++)
{
for (upper_leg = j; upper_leg < N; upper_leg += (2*leg_diff))
{
lower_leg = upper_leg+leg_diff;
temp1.real = (Y[upper_leg]).real + (Y[lower_leg]).real;
temp1.imag = (Y[upper_leg]).imag + (Y[lower_leg]).imag;
temp2.real = (Y[upper_leg]).real - (Y[lower_leg]).real;
temp2.imag = (Y[upper_leg]).imag - (Y[lower_leg]).imag;
(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;
for (i = 1; i < (N-1); i++) //bit reversal for resequencing data
{
k = N/2;
while (k
7/30/2019 Final Dsp Lab 2-06-12
80/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
80SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
7/30/2019 Final Dsp Lab 2-06-12
81/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
81SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
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;
}
RESULT:
7/30/2019 Final Dsp Lab 2-06-12
82/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
82SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
OUTPUT:
OUTPUT:
-5 0 5 10 150
0.5
1
time
amplitud
UNIT STEP SEQUENCE
-5 0 5 10 150
0.5
1
time
amplitud
DELAYED UNIT STEP SEQUENCE
-5 0 5 10 150
0.5
1
time
amplitud
UNIT SAMPLE SEQUENCE
-5 0 5 10 150
0.5
1
time
amplitud
DELAYED UNIT SAMPLE SEQUENCE
7/30/2019 Final Dsp Lab 2-06-12
83/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
83SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
BASIC SIGNALS GENERATION USING MATLAB
AIM: Generation of basic signals using MATLAB.
TOOLS REQUIRED:MATLAB Software,
Personal Computer.
MATLAB PROGRAM FOR UNIT SAMPLE SEQUENCE:
n = -5:15;
g = [zeros(1,5) 1 zeros(1,15)];
h = [zeros(1,10) 1 zeros(1,10)];
subplot(2,1,1);
stem(n,g);
xlabel('time index');
ylabel('amplitude');
title('UNIT SAMPLE SEQUENCE');
axis([-5 15 0 1.2]);
subplot(2,1,2);
stem(n,h);
xlabel('time index');
ylabel('amplitude');
title(' DELAYED UNIT SAMPLE SEQUENCE');
axis([-5 15 0 1.2]);
MATLAB PROGRAM FOR UNIT STEP SEQUENCE:
n = -5:15;
i = [zeros(1,5) ones(1,6) zeros(1,10)];
j = [zeros(1,10) ones(1,6) zeros(1,5)];
subplot(2,1,1);
stem(n,i);
xlabel('time index');
ylabel('amplitude');
title(' UNIT STEP SEQUENCE');
axis([-5 15 0 1.2]);
subplot(2,1,2);
stem(n,j);
7/30/2019 Final Dsp Lab 2-06-12
84/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
84SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Graph:
7/30/2019 Final Dsp Lab 2-06-12
85/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
85SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
xlabel('time index');
ylabel('amplitude');
title(' DELAYED UNIT STEP SEQUENCE');
axis([-5 15 0 1.2]);
MATLAB PROGRAM FOR SINE WAVE:
clc;
clear all;
close all;
t=0:.2:10;
y=sin(2*pi*t/5);
subplot(2,1,1);
plot(t,y);xlabel('time index');
ylabel('amplitude');
title('SINE WAVE');
subplot(2,1,2);
stem(t,y);
xlabel('time index');
ylabel('amplitude');
title('SINE WAVE');
7/30/2019 Final Dsp Lab 2-06-12
86/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
86SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
OUTPUT:
OUTPUT:
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.5
1
time
amplitud
UNIT RAMP
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.5
1
time
amplitud
UNIT RAMP
7/30/2019 Final Dsp Lab 2-06-12
87/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
87SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
MATLAB PROGRAM FOR RAMP SIGNAL:
clc;
clear all;
close all;
m=1;
t=0:.1:1;
y=m*t;
subplot(2,1,1);
plot(t,y);
xlabel('time index');
ylabel('amplitude');
title('UNIT RAMP');
subplot(2,1,2);
stem(t,y);
xlabel('time index');
ylabel('amplitude');
title('UNIT RAMP');
MATLAB PROGRAM FOR TRIANGULAR WAVE:
clc;
clear all;
close all;
m=-1;
t=0:1:10;
y=m.^t;
subplot(2,1,1);
plot(t,y);
xlabel('time index');
ylabel('amplitude');title('TRIANGULAR WAVE');
subplot(2,1,2);
stem(t,y);
xlabel('time index');
ylabel('amplitude');
title('TRIANGULAR WAVE');
7/30/2019 Final Dsp Lab 2-06-12
88/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
88SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
OUTPUT:
Graph:
0 1 2 3 4 5 6 7 8 9 10-1
-0.5
0
0.5
1
time index
amplitude
TRIANGULAR WAVE
0 1 2 3 4 5 6 7 8 9 10-1
-0.5
0
0.5
1
time index
amplitude
TRIANGULAR WAVE
7/30/2019 Final Dsp Lab 2-06-12
89/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
89SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Result:
7/30/2019 Final Dsp Lab 2-06-12
90/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
90SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
OUTPUT:
0 5 10 15 20 25 30 35 40 45 50-5
0
5
10
time index
amplitude
d[n]
s[n]
x[n]
0 5 10 15 20 25 30 35 40 45 500
2
4
6
8
time index
amplitude
y[n]
s[n]
7/30/2019 Final Dsp Lab 2-06-12
91/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
91SRI SAI ADITYA INSTITUTE OF SCIENCE & TECHNOLOGY
Expt.No: Date:
MATLAB PROGRAM FOR SIGNAL SMOOTHING
AIM: Write a program for signal smoothing using MATLAB
TOOLS REQUIRED:
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:
7/30/2019 Final Dsp Lab 2-06-12
92/92
DIGITAL SIGNAL PROCESSING LAB Dept. of ECE
Graph: