DSP LAB Staff Manual 2
DSP LAB Staff Manual 2
STAFF MANUAL
Vision:
To impart state-of-the art technical education, including sterling values and shining character,
producing engineers who contribute to nation building thereby achieving our ultimate objective of
sustained development of an unparalleled society, nation and world at large.
Mission:
Vision
Mission
Developing and motivating research ability among students by establishing research linkage with
leading industries.
Equipping faculty and students with the latest developments in Electronics and Communication and
to face the challenges.
● PSO1: Learn discrete Fourier transform, properties of DFT and its application to linear filtering
● PSO2: Understand the characteristics of digital filters, design digital IIR and FIR filters and apply
these filters to filter undesirable signals in various frequency bands
● PSO3: Understand the effects of finite precision representation on digital filters and understand the
fundamental concepts of multi rate signal processing and its applications.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
PEO1: To provide appropriate knowledge in applying the concepts and analysis of digital signals
and systems & communication engineering.
PEO2: To be able to identify, analyse and solve engineering problems in the field of electronics &
communication engineering.
PEO3: To provide an opportunity to work in multidisciplinary groups and research environments.
PEO4: To educate and inculcate professional ethics, human values, self-confidence and awareness
of societal needs.
PEO5: To motivate the students in intellectual pursuits, lifelong learning in order to develop
different perspectives of technological developments.
in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive clear
instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the engineering
and management principles and apply these to one’s own work, as a member and leader in a team, to
manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
SYLLABUS
10. Design and demonstration of FIR Filter for Low pass, High pass, Band pass and
11. Design and demonstration of Butter worth and Chebyshev IIR Filters for Low pass,
INDEX
MATLAB Programs
S.NO EXPERIMENT PAGE NO.
1 Generation of Signals
7 Generation of Waveforms
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:1 Generation of signals
Aim
To generate continuous and discrete-time signals for Digital Signal Processing (DSP)
applications using MATLAB
a) Unit impulse b) Unit step c) Unit ramp d) Parabolic e) Exponential f) Sine g)
Cosine h) Sinc I) Square
Procedure
1. Launch MATLAB: Double-click the MATLAB icon or search for it in the
application launcher.
2. Create/Open Script:
o To create a new script: Go to the "Home" tab and click "New Script."
o To open an existing script: Go to the "Home" tab, click "Open," and select
the script.
3. Write/Paste Code: In the MATLAB Editor, write or paste your MATLAB code.
4. Save Script: Save the script with a meaningful name and ".m" extension (e.g.,
"my_script.m").
5. Run Script:
o Click the "Run" button in the Editor toolbar, or
o Type the script name (without ".m") in the Command Window and press
Enter.
6. View Output: MATLAB will display the results in the Command Window or
graphical output in figure windows.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Program
% Continuous-Time Signals
t = -5:0.01:5; % Time vector for continuous signals
% Discrete-Time Signals
n = -5:5; % Discrete time vector
Outputs
Continuous time signals
Industrial Applications
1. Unit Impulse:
o Used in system identification and characterization, particularly for
determining the impulse response of a system or analyzing transient
behavior.
2. Unit Step:
o Applied in industrial control systems, especially for modelling and
simulating the response of systems to step inputs (e.g., PID controllers for
regulating temperature or pressure in industrial processes).
3. Unit Ramp:
o Useful in modelling linear growth or accumulation processes over time,
such as in sensor calibration or tracking systems.
4. Parabolic:
o Used for modelling physical phenomena with quadratic relationships,
including projectile motion in aerospace engineering or certain types of
vibrations in mechanical systems.
5. Exponential:
o Commonly applied for modelling exponential growth or decay processes,
such as radioactive decay, charging and discharging of capacitors, or
population growth models.
6. Sine and Cosine:
o Applied for modelling periodic phenomena, such as alternating current
(AC) signals in electrical systems, vibrations in mechanical systems, or
oscillations in control systems.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
7. Sinc:
o Important in digital signal processing (DSP), telecommunications, and
audio processing, particularly in interpolation, filtering, and spectral
analysis.
8. Square:
o Used for representing binary data or digital signals in systems like digital
communication, pulse-width modulation (PWM) for motor control, and
digital control systems.
(called the period) such that the signal repeats itself after every N samples.
Mathematically, this is expressed as:
x[n]=x[n+N],∀n∈Z
where N is the smallest positive integer that satisfies the above equation. If such an N
exists, the signal is periodic with period N
Impulse Response: The impulse response of a system is the output of the system
when the input is a unit impulse signal (denoted by δ[n] for discrete-time or δ(t)
for continuous-time). It characterizes the system's reaction to a brief input at a
specific time instant.
Significance: The impulse response is crucial because it completely describes the
linear time-invariant (LTI) system's behavior. Once the impulse response is
known, the output for any arbitrary input can be determined through convolution
(discrete-time) or integration (continuous-time). It serves as a fundamental tool in
system analysis and design.
Causality: A system is said to be causal if its output at any time t (or n in discrete
time) depends only on current and past inputs, not on future inputs.
Mathematically, for a continuous-time system, this means that the system's output
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
y(t) at time t is influenced by the input x(t) only for t≥0 t (or for n≥0 n in discrete
time).
Importance: Causality is important because in physical systems, future values
cannot affect present or past behavior. Causal systems are realizable in practice
since the output depends only on available or past inputs. Non-causal systems, on
the other hand, are theoretical and cannot be physically realized.
1. Periodicity:
o Periodic: A signal that repeats at regular intervals (e.g., sine wave).
o Aperiodic: A signal that does not repeat (e.g., step function).
2. Energy and Power:
o Energy Signals: Signals with finite energy and zero average power. The
energy is calculated as the sum of the squared values of the signal.
o Power Signals: Signals with infinite energy but finite average power,
typically periodic signals.
3. Deterministic and Random:
o Deterministic: Signals that can be precisely described by a mathematical
expression (e.g., sine wave).
o Random: Signals that are described by probabilistic models and cannot be
predicted exactly (e.g., noise).
4. Even and Odd Signals:
o Even Signal: A signal that satisfies x[n]=x[−n] for all n
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Result
Thus, the MATLAB program to generate signals was simulated and the waveforms are
Plotted.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:2 Computation of Linear convolution with and without function
Aim
To learn about the manual computation and application of MATLAB's built-in
functions for linear convolution of two finite length sequences.
Where:
x[n] is the input signal,
This operation is referred to as the convolution sum of the sequences x[n] and
h[n]and it is represented as:
The result of convolving two sequences depends on their lengths. If the length of
sequence x[n] is M and the length of sequence h[n] is N, then the length of the resulting
sequence y[n] will be M+N−1.
MATLAB Implementation:
In MATLAB, the convolution of two finite-length sequences a and b is implemented
using the conv function. The command:
c=conv(a,b)
computes the convolution of sequences a and b, producing the resulting sequence c,
which has a length of M+N−1, where Mand N are the lengths of a and b, respectively.
Procedure
Launch MATLAB:
Open MATLAB by double-clicking on the MATLAB icon on your desktop or by
searching for MATLAB in your computer's application launcher and selecting it.
Create or Open a Script:
In MATLAB, you can either create a new script or open an existing one.
To create a new script:
Go to the "Home" tab in the toolbar.
Click on "New Script". This will open a new script file in the MATLAB
Editor.
To open an existing script:
Go to the "Home" tab.
Click on "Open" and select the script file you want to open from your
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
directories.
Write or paste the MATLAB Code:
In the MATLAB Editor, paste or write your MATLAB code into the script file.
Ensure that the code includes all necessary commands, functions, variable
assignments, and plot commands.
Save the Script File:
Save your script with a meaningful name and the extension .m (e.g.,
convolution_script.m).
To save, click on "Save" or "Save As" in the toolbar, or use the keyboard
shortcut Ctrl + S (Windows) or Command + S (Mac).
Run the Script:
To run the entire script, click on the "Run" button in the Editor's toolbar, or:
Type the name of the script (without the .m extension) in the Command
Window and press Enter.
For example, type convolution_script and press Enter.
MATLAB Executes the Code:
After running the script, MATLAB will execute the code and display the results in
the Command Window or other MATLAB windows.
If your script generates plots or figures, they will be displayed in separate figure
windows.
View the Output:
The script should plot:
The input sequence x[n]
The impulse response h[n]
The output sequence after manual convolution
The output sequence from the built-in conv function
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Pseudocode
BEGIN
// Step 1: Initialize environment
Close any open figure windows
Clear workspace variables
// Step 5: Zero-padding
Calculate the padding needed for x[n] and h[n]
Calculate the difference 'd' = c - a
Calculate the difference 'e' = c - b
FOR n = 1 to c
Set z[n] = 0
FOR i = 1 to c
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Set j = n - i + 1
IF j <= 0 THEN
Adjust 'j' by wrapping around (j = j + c)
END IF
// Step 8: Plotting
Create a figure window for displaying plots
END
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Program
% MATLAB Code for Convolution of Sequences (Manual & Built-in Function)
% Display results
disp('Manual Convolution Output (z):');
disp(z);
disp('Built-in Convolution Output (g):');
disp(g);
subplot(2, 2, 2);
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
subplot(2, 2, 3);
stem(z, 'LineWidth', 1.5);
xlabel('n');
ylabel('y(n) - Manual Convolution');
title('Output Response (Manual Convolution)');
subplot(2, 2, 4);
stem(g, 'LineWidth', 1.5);
xlabel('n');
ylabel('y(n) - Built-in Convolution');
title('Output Response (Built-in Convolution)');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Output
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Industrial Applications
Significance:
o It is used for system analysis, filtering, and designing systems like FIR
and IIR filters.
Importance:
Based on Symmetry:
Based on Duration:
Based on Behavior:
RESULT
Thus, the convolution of two finite length sequences was simulated using MATLAB
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:3 Computation of Circular convolution with and without function
Aim
To learn about the manual computation and application of MATLAB's built-in
functions for circular convolution of two finite length sequences.
Mapping with theory
Circular Convolution
Circular convolution is a fundamental operation in Digital Signal Processing (DSP)
used primarily to process finite-length sequences, especially in the context of
periodic signals or systems.
Definition: Circular convolution is a mathematical operation performed on two
finite-length sequences to obtain a third sequence. Unlike linear convolution,
circular convolution assumes that the sequences are periodic, meaning they
"wrap around" at their boundaries.
Here, the sequence a(m) represents the result of the circular convolution of x(n) and
y(n), where the indices are wrapped around at the boundaries.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Procedure
Launch MATLAB:
Double-click on the MATLAB icon on your desktop or search for MATLAB in
your computer's application launcher and open it.
To create a new script, go to the "Home" tab, click on "New Script", and a new
script file will open in the Editor.
To open an existing script, go to the "Home" tab, click on "Open", and select
the script file you want to open.
To save, click on "Save" or "Save As" in the MATLAB Editor's toolbar, or use
the keyboard shortcut (Ctrl + S on Windows).
Execute and Display the Output:After running the script, MATLAB will execute
the code and display the output in the Command Window or other MATLAB
windows (e.g., figure windows for plots).
Plotting Output (For Graphical Results):
If your code generates plots, figures, or other graphical outputs, they will be
displayed in separate windows.
Pseudocode
1. Start
2. Initialize MATLAB environment (clear previous variables, close plots)
3. Prompt user to input the sequence 'x' (input sequence)
- Input: x = [user-provided sequence]
4. Prompt user to input the sequence 'y' (impulse response)
- Input: y = [user-provided sequence]
11. Display the manual convolution result 'd' and the built-in convolution result 'g'
subplot(2, 2, 1);
stem(x);
title('Input Sequence');
xlabel('n');
ylabel('x(n)');
subplot(2, 2, 2);
stem(y);
title('Impulse Response');
xlabel('n');
ylabel('h(n)');
subplot(2, 2, 3);
stem(d);
title('Output Response (Manual Convolution)');
xlabel('n');
ylabel('y(n)');
subplot(2, 2, 4);
stem(g);
title('Output Response (Built-in Function)');
xlabel('n');
ylabel('y(n)');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Output
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Industrial applications
Communication Systems: Circular convolution plays a significant role in
communication systems for tasks such as channel equalization, modulation,
and demodulation processes.
Lout=M+N-1
where M and N are the lengths of the two sequences.
Circular Convolution: The output length of circular convolution is the length
of the larger sequence (usually the length of the sequence after zero-padding to
make both sequences of equal length).
Lout=max(M,N)
where M and N are the lengths of the two sequences, and padding is used to make the
lengths equal if needed.
convolution sum:
where x[k] is the input sequence, h[n-k] is the impulse response, and y[n] is the
output sequence. This formula is used for linear convolution.
It is widely used in periodic systems where the signals wrap around, such as
wireless communication and multimedia applications.
where x(n) and h(n) are the two input sequences, and y(m) is the output of the
convolution. The term (m-n) mod N ensures that the indices wrap around in a
circular manner.
RESULT
Thus, the convolution of two finite length sequences was simulated using MATLAB.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:4 Computation of Auto correlation and cross correlation
Aim
To gain a thorough understanding of auto-correlation and cross-correlation functions
and their significance in signal processing and communication systems.
Mapping with Theory
Auto correlation & Cross correlation
a) Auto-correlation:
Auto-correlation is a measure of similarity between a signal and a delayed version of
itself. It quantifies how much a signal correlates with itself at different time lags.
Auto-correlation is useful in identifying patterns such as periodicity or self-similarity
in signals.
b) Cross-correlation:
Cross-correlation measures the similarity between two different signals as a function
of the displacement of one relative to the other. It determines how much one signal
resembles another when one is shifted in time. Cross-correlation is used to detect
similarities and alignment between two signals.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Procedure
Pseudocode
1. Start
2. Clear the workspace and close any open figures:
- Call the command 'close'
- Call the command 'clear'
3. Prompt the user to input the first sequence (for auto-correlation):
- Display the message: "Enter the input sequence for Auto-correlation"
- Store the input in variable 'x'
4. Compute the auto-correlation of sequence 'x':
- Use the function 'xcorr(x)' to compute the auto-correlation and store the result in
variable 'z_auto'
5. Prompt the user to input the second sequence (for cross-correlation):
- Display the message: "Enter the input sequence for Cross-correlation"
- Store the input in variable 'y'
6. Compute the cross-correlation of sequences 'x' and 'y':
- Use the function 'xcorr(x, y)' to compute the cross-correlation and store the result
in variable 'z_cross'
7. Display the auto-correlation and cross-correlation results:
- Display 'z_auto' in the Command Window
- Display 'z_cross' in the Command Window
8. Create a new figure for plotting:
9. Create the first subplot for the input sequence of auto-correlation:
- Plot 'x' using 'stem' function with thick black lines ('LineWidth' = 2, 'Color' = [0 0
0])
- Set the title: "Input Sequence for Auto-correlation"
- Label the x-axis as "n"
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Program
close;
clear;
% Auto-correlation
x = input('Enter the input sequence for Auto-correlation: '); % Input sequence
z_auto = xcorr(x); % Auto-correlation calculation
% Cross-correlation
y = input('Enter the input sequence for Cross-correlation: '); % Input sequence 2
z_cross = xcorr(x, y); % Cross-correlation calculation
disp('Cross-correlation result:');
disp(z_cross);
subplot(2, 2, 2);
stem(z_auto, 'LineWidth', 2, 'Color', [0 0 0]); % Thicker dark line for auto-
correlation
title('Auto-correlation Output');
xlabel('n');
ylabel('z(n)');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
grid on;
subplot(2, 2, 4);
stem(z_cross, 'LineWidth', 2, 'Color', [0 0 0]); % Thicker dark line for cross-
correlation
title('Cross-correlation Output');
xlabel('n');
ylabel('z(n)');
grid on;
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Outputs
Cross-correlation:
Motion Tracking Systems: Cross-correlation is used in real-time motion
tracking systems for object detection, tracking, and localization in video
surveillance, autonomous vehicles, and robotics. This helps in enabling
accurate and robust motion analysis and control.
Properties of Cross-correlation:
Commutative: Rxy(τ)=Ryx(−τ)
Cross-correlation:
Results
Thus, the autocorrelation and cross correlation for the given sequence is simulated
using MATLAB.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:5 Calculation of Fast Fourier Transform of a signal
Aim
To write a MATLAB program to compute the Discrete Fourier Transform (DFT) of
finite length sequence x[n]and Inverse Discrete Fourier Transform (IDFT) of a
sequence x(k).
Mapping with Theory
FFT and IFFT
The FFT (Fast Fourier Transform) and its inverse, IFFT (Inverse Fast Fourier
Transform), are fundamental tools in digital signal processing (DSP) for analyzing
and synthesizing signals in the frequency domain.
from its
frequency-domain representation.
Given the frequency components obtained from the FFT, the IFFT reconstructs the
original signal by summing up the sinusoidal components at their respective
frequencies.
Like the FFT, the IFFT algorithm is also efficient, with a computational
complexity of O(N log N).
x[n] = (1/N) * ∑[k=0 to N-1] X[k] * e^(j2πkn/N)
Procedure
Pseudocode
FFT&IFFT-WITH FUNCTION
START
4. Compute FFT:
- Set `y = FFT(x)`.
5. Compute IFFT:
- Set `z = IFFT(y)`.
6. Display Results:
7. Plot Results:
END
- If length of `x` is not 4, display "Input sequence must be of length 4." and
terminate.
4. Stage 1 of DIT-FFT:
5. Compute FFT:
- For j = 1 to n/2:
6. Compute IFFT:
- q = conj(y)
7. Compute IFFT:
- For j = 1 to n/2:
- s = conj(z)
-w=s/4
9. Display results:
END
8 POINT DIT-FFT&IFFT
START
- If length of `x` is not 8, display "Input sequence must be of length 8." and
terminate.
4. Stage 1 of DIT-FFT:
- Compute `a(1) = x(1) + x(5)`, `a(2) = x(1) - x(5)`, `b(1) = x(3) + x(7)`, `b(2) =
x(3) - x(7)`, `a(3) = x(2) + x(6)`, `a(4) = x(2) - x(6)`, `b(3) = x(4) + x(8)`, `b(4) = x(4)
- x(8)`.
- For `j = 1` to `n/2`:
6. Stage 2 of DIT-FFT:
- For `j = 1` to `n/2`:
7. IFFT Process:
- Compute `a(1) = q(1) + q(5)`, `a(2) = q(1) - q(5)`, `b(1) = q(3) + q(7)`, `b(2) =
q(3) - q(7)`, `a(3) = q(2) + q(6)`, `a(4) = q(2) - q(6)`, `b(3) = q(4) + q(8)`, `b(4) = q(4)
- q(8)`.
8. Compute IFFT:
- For `j = 1` to `n/2`:
- For `j = 1` to `n/2`:
- `s = conj(k)`
- `l = s / n`
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
END
4 POINT DIF-FFT&IFFT
START
- If length of `x` is not 4, display "Input sequence must be of length 4." and
terminate.
4. Stage 1: DIF-FFT:
- Initialize arrays `a` and `b` with size 2 (half of sequence length).
- For `j = 1` to `n/2`:
- Compute `y(1) = a(1) + a(2)`, `y(3) = a(1) - a(2)`, `y(2) = b(1) + b(2)`, `y(4) = b(1)
- b(2)`.
6. Stage 2: IFFT:
- For `j = 1` to `n/2`:
7. Compute IFFT:
- Compute `h(1) = a(1) + a(2)`, `h(3) = a(1) - a(2)`, `h(2) = b(1) + b(2)`, `h(4) = b(1)
- b(2)`.
9. Display results:
END
START
- For `j = 1` to `n/2`:
- For `j = 1` to `n/2`:
8. Inverse FFT:
- For `j = 1` to `n/2`:
- For `j = 1` to `n/2`:
- Normalize: `r = p / n`
END
Programs
FFT&IFFT-WITH FUNCTION
close all;
clear;
clc;
% Input sequence
x = input('Enter the input sequence (e.g., [1 2 3 4]): ');
% Display results
disp('FFT of the input sequence:');
disp(y);
disp('IFFT of the sequence (should match input):');
disp(z);
ylabel('x(n)');
if length(x) ~= 4
error('Input sequence must be of length 4.');
end
% Stage 1 of DIT-FFT
a(1) = x(1) + x(3);
a(2) = x(1) - x(3);
b(1) = x(2) + x(4);
b(2) = x(2) - x(4);
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
% Compute FFT
for j = 1:c
y(j) = a(j) + (b(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / n));
y(j + 2) = a(j) - (b(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / n));
end
% Compute IFFT
q = conj(y); % Take conjugate of FFT
a(1) = q(1) + q(3);
a(2) = q(1) - q(3);
b(1) = q(2) + q(4);
b(2) = q(2) - q(4);
for j = 1:c
z(j) = a(j) + (b(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / n));
z(j + 2) = a(j) - (b(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / n));
end
% Display results
disp('FFT of the input sequence:');
disp(y);
disp('IFFT of the sequence (should match input):');
disp(w);
% Plot results
figure;
% Input sequence
subplot(2, 2, 1);
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
stem(x, 'filled');
title('Input sequence');
xlabel('n');
ylabel('x(n)');
% IFFT sequence
subplot(2, 2, 4);
stem(real(w), 'filled'); % Only plot real part
title('IFFT sequence');
xlabel('n');
ylabel('x(n)');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
% Input sequence
x = input('Enter the input sequence (length must be 8): ');
if length(x) ~= 8
error('Input sequence must be of length 8.');
end
% Stage 1
a = zeros(4, 1);
b = zeros(4, 1);
y = zeros(4, 1);
z = zeros(4, 1);
for j = 1:c/2
y(j) = a(j) + (b(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / c));
y(j + 2) = a(j) - (b(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / c));
z(j) = a(j + 2) + (b(j + 2) * exp((-1 * 2 * pi * 1i * (j - 1)) / c));
z(j + 2) = a(j + 2) - (b(j + 2) * exp((-1 * 2 * pi * 1i * (j - 1)) / c));
end
% Stage 2
w = zeros(8, 1);
for j = 1:c
w(j) = y(j) + (z(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / n));
w(j + 4) = y(j) - (z(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / n));
end
% IFFT Process
q = conj(w); % Conjugate of FFT result
for j = 1:c/2
y(j) = a(j) + (b(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / c));
y(j + 2) = a(j) - (b(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / c));
z(j) = a(j + 2) + (b(j + 2) * exp((-1 * 2 * pi * 1i * (j - 1)) / c));
z(j + 2) = a(j + 2) - (b(j + 2) * exp((-1 * 2 * pi * 1i * (j - 1)) / c));
end
k = zeros(8, 1);
for j = 1:c
k(j) = y(j) + (z(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / n));
k(j + 4) = y(j) - (z(j) * exp((-1 * 2 * pi * 1i * (j - 1)) / n));
end
% Display results
disp('FFT of the input sequence:');
disp(w);
disp('IFFT of the sequence (should match input):');
disp(l);
% Plot results
figure;
% Input sequence
subplot(2, 2, 1);
stem(x, 'filled');
title('Input Sequence');
xlabel('n');
ylabel('x(n)');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
% IFFT Sequence
subplot(2, 2, 4);
stem(real(l), 'filled'); % Only plot real part
title('IFFT Sequence');
xlabel('n');
ylabel('x(n)');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
clc;
% Input sequence
x = input('Enter the input sequence (length must be 4): ');
if length(x) ~= 4
error('Input sequence must be of length 4.');
end
% Stage 1: DIF-FFT
a = zeros(c, 1);
b = zeros(c, 1);
for j = 1:c
a(j) = x(j) + x(j + c);
b(j) = (x(j) - x(j + c)) * exp((-1 * 2 * pi * 1i * (j - 1)) / n);
end
y = zeros(n, 1);
y(1) = a(1) + a(2);
y(3) = a(1) - a(2);
y(2) = b(1) + b(2);
y(4) = b(1) - b(2);
% Stage 2: IFFT
g = conj(y); % Conjugate for IFFT
for j = 1:c
a(j) = g(j) + g(j + c);
b(j) = (g(j) - g(j + c)) * exp((-1 * 2 * pi * 1i * (j - 1)) / n);
end
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
h = zeros(n, 1);
h(1) = a(1) + a(2);
h(3) = a(1) - a(2);
h(2) = b(1) + b(2);
h(4) = b(1) - b(2);
% Display results
disp('FFT of the input sequence:');
disp(y);
disp('IFFT of the sequence (should match input):');
disp(l);
% Plot results
figure;
% Input sequence
subplot(2, 2, 1);
stem(x, 'filled');
title('Input Sequence');
xlabel('n');
ylabel('x(n)');
subplot(2, 2, 3);
stem(imag(y), 'filled');
title('FFT Sequence - Imaginary Part');
xlabel('k');
ylabel('Im(x(k))');
% IFFT Sequence
subplot(2, 2, 4);
stem(real(l), 'filled'); % Only plot real part
title('IFFT Sequence');
xlabel('n');
ylabel('x(n)');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
8 Point DIF-FFT&IFFT
close()
clear()
% Input sequence
x = input('Enter the input sequence: ');
n = length(x);
c = n / 2;
% FFT results
w(1) = y(1) + y(2);
w(5) = y(1) - y(2);
w(3) = y(3) + y(4);
w(7) = y(3) - y(4);
w(2) = z(1) + z(2);
w(6) = z(1) - z(2);
w(4) = z(3) + z(4);
w(8) = z(3) - z(4);
% Inverse FFT
s = conj(w);
for j = 1:c/2
a(j) = s(j) + s(j + 4);
b(j) = (s(j) - s(j + 4)) * exp((-1 * 2 * pi * i * (j - 1)) / n);
a(j + 2) = s(j + 2) + s(j + 6);
b(j + 2) = (s(j + 2) - s(j + 6)) * exp((-1 * 2 * pi * i * (j + 1)) / n);
end
for j = 1:c/2
y(j) = a(j) + a(j + 2);
y(j + 2) = (a(j) - a(j + 2)) * exp((-1 * 2 * pi * i * (j - 1)) / c);
z(j) = b(j) + b(j + 2);
z(j + 2) = (b(j) - b(j + 2)) * exp((-1 * 2 * pi * i * (j - 1)) / c);
end
% Display results
disp('FFT sequence:');
disp(w);
disp('IFFT sequence:');
disp(r);
% Plotting results
subplot(2, 2, 1);
stem(x);
title('Input sequence');
xlabel('n');
ylabel('x(n)');
subplot(2, 2, 2);
stem(real(w));
title('FFT sequence (Real part)');
xlabel('k');
ylabel('Re{x(k)}');
subplot(2, 2, 3);
stem(imag(w));
title('FFT sequence (Imaginary part)');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
xlabel('k');
ylabel('Im{x(k)}');
subplot(2, 2, 4);
stem(real(r));
title('IFFT sequence');
xlabel('n');
ylabel('x(n)');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
INDUSTRIAL APPLICATIONS:
FFT is employed for efficient implementation of digital filters, including low-pass,
high pass, band-pass, and notch filters
Magnitude plots help in designing filters by identifying the frequency components
to be attenuated or preserved.
In communication systems, phase plots aid in equalizing channel distortions by
compensating for phase shifts introduced during transmission.
like the Laplace Transform or the Z-Transform can be used to analyze the system.
4. Real-world Applications of Fourier Transform: Fourier Transforms are widely
used in various fields:
Signal Processing: Filtering, noise reduction, and feature extraction.
Image Processing: Image compression, edge detection, and noise reduction.
Communication Systems: Modulation, demodulation, and channel equalization.
Spectroscopy: Analyzing the spectral composition of materials.
5. Fast Fourier Transform (FFT): FFT is an efficient algorithm for computing the
Discrete Fourier Transform (DFT). It reduces the computational complexity from
O(N^2) to O(N log N), making it suitable for large datasets. FFT works by
recursively dividing the input signal into smaller sub-signals and combining their
DFTs to obtain the DFT of the original signal.
RESULT
Thus the magnitude and phase plot for FFT was simulated using MATLAB.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Aim
To write a MATLAB program to compute the Linear convolution of two finite length
sequences using FFT
N-1
X[k] = ∑ x[n] * e^(-2πikn/N)
n=0
X[k]: Represents the kth frequency component in the frequency domain.
x[n]: Represents the nth sample of the sequence in the time domain.
N: Represents the length of the sequence.
k: Is an index ranging from 0 to N-1.
e: Is the base of the natural logarithm.
i: Is the imaginary unit.
Procedure
Pseudocode
1. **Input:**
- Get the first sequence `a` from the user.
- Get the second sequence `b` from the user.
4. **Compute DFT:**
- Calculate the Discrete Fourier Transform (DFT) of `a` and `b`, padding with zeros
to length `M`:
```
X = DFT(a, M)
Y = DFT(b, M)
```
6. **Compute IDFT:**
- Calculate the Inverse Discrete Fourier Transform (IDFT) of `C` to obtain the linear
convolution result `c`:
```
c = IDFT(C)
```
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
7. **Display Output:**
- Print the output sequence `c` to the console.
8. **Plot Sequences:**
- **Plot Input Sequence 1:**
- Plot `a` against the first `length(a)` elements of `N`.
- Label the x-axis as "n".
- Label the y-axis as "x(n)".
- Title the plot "Input sequence 1".
- **Plot Input Sequence 2:**
- Plot `b` against the first `length(b)` elements of `N`.
- Label the x-axis as "n".
- Label the y-axis as "x(n)".
- Title the plot "Input sequence 2".
- **Plot Output Sequence:**
- Plot `c` against the entire `N` vector.
- Label the x-axis as "n".
- Label the y-axis as "c(n)".
- Title the plot "Output sequence"
Program
a = input('Enter the first sequence=');
b = input('Enter the second sequence=');
N = 0:M-1;
subplot(2,2,2);
stem(N(1:length(b)), b); % Adjust N to match the length of b
xlabel('n');
ylabel('x(n)');
title('Input sequence 2');
subplot(2,2,3);
stem(N, C);
xlabel('n');
ylabel('c(n)');
title('Output sequence');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Output
INDUSTRIAL APPLICATIONS
In industries such as telecommunications, audio processing, and radar systems, DSP
plays a critical role. Linear convolution using FFT is extensively used in DSP systems
for tasks such as filtering, equalization, and signal analysis
In industries such as multimedia, linear convolution using FFT finds applications in
image and video processing tasks such as edge detection, image enhancement, and
motion estimation. By convolving images or video frames with appropriate filters, FFT
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
based linear convolution allows for efficient feature extraction and manipulation.
RESULT
Thus,the Linear convolution of two finite length sequences was simulated using FFT.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Aim
To write a MATLAB program to compute the Circular convolution of two finite
length sequences using FFT
x[n]: Represents the nth sample of the sequence in the time domain.
N: Represents the length of the sequence.
k: Is an index ranging from 0 to N-1.
Procedure
Program
% Time indices
N1 = 0:M1-1;
N2 = 0:M2-1;
N = 0:M-1;
% Input sequence 1
subplot(2, 2, 1);
stem(N1, a(1:M1), 'filled');
xlabel('n');
ylabel('x(n)');
title('Input Sequence 1');
% Input sequence 2
subplot(2, 2, 2);
stem(N2, b(1:M2), 'filled');
xlabel('n');
ylabel('x(n)');
title('Input Sequence 2');
% Output sequence
subplot(2, 2, 3);
stem(N, C, 'filled');
xlabel('Time Index n');
ylabel('Amplitude');
title('Output Sequence (Circular Convolution)');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
INDUSTRIAL APPLICATIONS
In wireless communication systems, circular convolution using FFT plays a crucial
role in channel equalization, synchronization, and symbol detection.
By convolving transmitted signals with channel impulse responses or modulation
waveforms, FFT-based circular convolution helps compensate for channel distortion,
multipath fading, and interference, thereby improving data transmission reliability
and spectral efficiency.
In industries related to audio and music production, circular convolution using FFT
is utilized for tasks such as reverberation effects, echo generation, and convolution
reverb processing.
RESULT
Thus, the Circular convolution of two finite length sequences was simulated using
FFT.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Aim
To write a MATLAB program to obtain the magnitude and phase plot for FFT.
Procedure
Pseudocode
START
1. INPUT the length of the sequence, N.
2. INPUT the length of the DFT/IDFT, M.
3. INPUT the sequence, u.
4. IF computing DFT:
U = fft(u, M) // Perform Discrete Fourier Transform
ELSE IF computing IDFT:
U = ifft(u, M) // Perform Inverse Discrete Fourier Transform
END IF
5. DEFINE time index: t = 0 to N-1
6. DEFINE frequency index: k = 0 to M-1
7. PLOT:
- Subplot 1: Original sequence u
Title: "Original Time Domain Sequence"
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
- Subplot 3: Phase of U
Title: "Phase of DFT/IDFT Samples"
X-axis: "Frequency Index k"
Y-axis: "Phase"
8. DISPLAY:
- Magnitude of U: abs(U)
- Phase of U: angle(U)
- Transformation result: U
END
Key Differences:
Transformation Function:
o For DFT: Use fft(u, M).
o For IDFT: Use ifft(u, M).
Interpretation of Results:
o For DFT: The output represents the frequency-domain representation of the
sequence.
o For IDFT: The output represents the reconstructed time-domain sequence.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Program
FFT
% Illustration of DFT Computation
% Prompt the user for input values
N = input('Enter the length of the sequence: ');
M = input('Enter the length of the DFT: ');
IFFT
% Illustration of IDFT computation
% Prompt user inputs
N = input('Enter the length of the sequence: ');
M = input('Enter the length of the DFT: ');
u = input('Enter the sequence: ');
Output
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
INDUSTRIAL APPLICATIONS
FFT is employed for efficient implementation of digital filters, including low-pass,
high pass, band-pass, and notch filters
Magnitude plots help in designing filters by identifying the frequency components to
be attenuated or preserved.
In communication systems, phase plots aid in equalizing channel distortions by
compensating for phase shifts introduced during transmission.
RESULT
Thus, the magnitude and phase plot for FFT was simulated using MATLAB
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Aim
To write a MATLAB program to verify sampling theorem.
Procedure
Pseudocode
BEGIN
% Close all figures and clear workspace
CLOSE all figures
CLEAR workspace
% Input parameters
PRINT "Enter the sampling frequency: "
fs = USER input for sampling frequency
T = 1 / fs % Sampling period
% Generate signals
x1 = COSINE wave with frequency f1 at time vector t
x2 = COSINE wave with frequency f2 at time vector t
x3 = COSINE wave with frequency f3 at time vector t
% Plot x1
PLOT first 100 samples of x1
TITLE "Signal with Frequency f1"
LABEL x-axis as "Sample Index"
LABEL y-axis as "Amplitude"
% Plot x2
PLOT first 100 samples of x2
TITLE "Signal with Frequency f2"
LABEL x-axis as "Sample Index"
LABEL y-axis as "Amplitude"
% Plot x3
PLOT first 100 samples of x3
TITLE "Signal with Frequency f3"
LABEL x-axis as "Sample Index"
LABEL y-axis as "Amplitude"
% Compute FFT
nfft = NEXT power of 2 greater than or equal to length of x
s = FFT of x with length nfft % Compute FFT
f = FREQUENCY vector from 0 to fs/2 with nfft/2 + 1 points
END
Program
% Input Parameters
fs = input('Enter the sampling frequency: '); % Sampling frequency
T = 1 / fs; % Sampling period
f1 = input('Enter the first input frequency: '); % Frequency 1
f2 = input('Enter the second input frequency: '); % Frequency 2
f3 = input('Enter the third input frequency: '); % Frequency 3
L = 1000; % Signal length
t = (0:L-1) * T; % Time vector
% Generate Signals
x1 = cos(2 * pi * f1 * t); % Signal with frequency f1
x2 = cos(2 * pi * f2 * t); % Signal with frequency f2
x3 = cos(2 * pi * f3 * t); % Signal with frequency f3
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
subplot(4, 1, 2);
plot(x2(1:100)); % Plot first 100 samples of x2
title('Signal with Frequency f2');
xlabel('Sample Index');
ylabel('Amplitude');
subplot(4, 1, 3);
plot(x3(1:100)); % Plot first 100 samples of x3
title('Signal with Frequency f3');
xlabel('Sample Index');
ylabel('Amplitude');
% Combine Signals
x = x1 + x2 + x3; % Combined signal
% Compute FFT
nfft = 2^nextpow2(length(x)); % Next power of 2 for FFT
s = fft(x, nfft); % FFT computation
f = fs / 2 * linspace(0, 1, (nfft / 2) + 1); % Frequency vector
Output
INDUSTRIAL APPLICATIONS
In telecommunications and multimedia applications, the Sampling Theorem
ensures accurate digitization and processing of audio and speech signals for tasks
such as speech recognition, compression, and enhancement.
Sampling is crucial for digitizing and processing images and videos in
applications like digital cameras, video surveillance, and medical imaging
systems.
The Sampling Theorem guides the design and operation of RF communication
systems by ensuring accurate sampling of baseband and modulated signals,
enabling reliable transmission and reception of data in wireless networks.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
RESULT
Thus, the Sampling theorem was verified using MATLAB and waveforms are plotted
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
Department: Electronics & Communication Engineering Lab Name: EC3492-DSP laboratory
no:10
Design of INFINITE IMPULSE RESPONSE (IIR) FILTER
Aim
To write various MATLAB programs to implement different Infinite Impulse
response (IIR) filters
Mapping with Theory
i)BUTTERWORTH FILTER
The Butterworth filter is a type of signal processing filter designed to have a
frequency response as flat as possible in the passband while rolling off smoothly into
the stopband
The Butterworth filter is a type of maximally flat filter, meaning that it provides
the maximum possible flatness in the passband while meeting the desired cutoff
frequency and attenuation requirements in the stopband.
Unlike other filter types such as Chebyshev or elliptic filters, the Butterworth filter
does not have ripples in the passband or stopband.
Where
H(s) is the transfer function.
s is the Laplace variable.
ω_c is the cutoff frequency.
N is the order of the filter
ii) CHEBYSHEV TYPE 1 FILTER
Chebyshev Type I filters are a type of analog or digital filter characterized by
allowing ripples in the passband while providing a steeper roll-off in the transition
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Where:
H(s) is the transfer function.
s is the Laplace variable.
ω_c is the cutoff frequency.
T_N(x) is the Chebyshev polynomial of order N.
ε is the ripple factor, controlling the amount of passband ripple.
iii) CHEBYSHEV TYPE 2 FILTER
Chebyshev Type II filters are designed to achieve a sharper transition between the
passband and stopband by allowing controlled ripples in the stopband while
maintaining a flat response in the passband.
Unlike Chebyshev Type I filters, which allow ripples in the passband, Chebyshev
Type II filters exhibit ripples in the stopband to achieve the desired trade-off between
the sharpness of the transition region and the stopband attenuation.
The key parameter that governs the behavior of Chebyshev Type II filters is the
ripple factor or stopband ripple, denoted by ε.
This parameter controls the amount of ripple allowed in the stopband, and higher
values of ε result in greater stopband ripple but steeper roll-off in the transition
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
region.
Where
Procedure
5. Run Script:
1. Click the "Run" button in the Editor toolbar, or
2. Type the script name (without ".m") in the Command Window and
press Enter.
6. View Output: MATLAB will display the results in the Command Window or
graphical output in figure windows.
Pseudocode
i) BUTTERWORTH FILTER:
a) Low pass filter:
1. Close all open figures and clear workspace:
close();
clear();
2. Input parameters:
2.1. Prompt user to enter the sampling frequency (Fs)
2.2. Prompt user to enter the passband frequency (wp)
2.3. Prompt user to enter the stopband frequency (ws)
2.4. Prompt user to enter the passband attenuation (ap)
2.5. Prompt user to enter the stopband attenuation (as)
2.6. Calculate the normalized passband frequency (w1) as (2 * wp) / Fs
2.7. Calculate the normalized stopband frequency (w2) as (2 * ws) / Fs
3. Design the Butterworth filter:
3.1. Determine the filter order (n) and normalized cutoff frequency (wn)
using the buttord function:
n, wn = buttord(w1, w2, ap, as)
3.2. Display the filter order (n) and normalized cutoff frequency (wn).
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
5.1. Use the freqz function to plot the frequency response of the designed
filter: freqz(b, a, [], Fs)
5.2. Set the title of the plot to 'BUTTERWORTH BANDPASS FILTER'
d) Band stop filter:
1. Close all open figures and clear workspace:
close();
clear();
2. Input parameters:
2.1. Prompt user to enter the sampling frequency (Fs)
2.2. Prompt user to enter the passband frequency (wp)
2.3. Prompt user to enter the stopband frequency (ws)
2.4. Prompt user to enter the passband attenuation (ap)
2.5. Prompt user to enter the stopband attenuation (as)
2.6. Calculate the normalized passband frequency (w1) as (2 * wp) / Fs
2.7. Calculate the normalized stopband frequency (w2) as (2 * ws) / Fs
3. Design the Butterworth bandstop filter:
3.1. Determine the filter order (n) and normalized cutoff frequency (wn) using
the buttord function:
n, wn = buttord(w1, w2, ap, as)
3.2. Display the filter order (n) and normalized cutoff frequency (wn).
4. Generate the filter coefficients:
4.1. Use the butter function to design the Butterworth bandstop filter:
b, a = butter(n, wn, 'stop')
5. Plot the frequency response:
5.1. Use the freqz function to plot the frequency response of the designed
filter: freqz(b, a, [], Fs)
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Program
i) BUTTERWORTH FILTER:
a) Low pass filter
close();
clear();
fs=input('Enter the frequency Fs:');
wp=input('Enter the pass band freq:');
ws=input('Enter the stop band freq:');
ap=input('Enter the pass band attenaution:');
as=input('Enter the stop band attenaution:');
w1=(2*wp)/fs;
w2=(2*ws)/fs;
[n,wn]=buttord(w1,w2,ap,as);
disp('order');
disp(n);
disp('Normalized cut-off freq');
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
disp(wn);
[b,a]=butter(n,wn);
freqz(b,a,[],fs);
disp(n);
disp('Normalized cut-off freq');
disp(wn);
[b,a]=butter(n,wn,'stop');
freqz(b,a,[],fs);
title('BUTTERWORTH BANDSTOP FILTER');
disp(wn);
[b,a]=cheby2(n,as,wn,'stop');
freqz(b,a,[],fs);
title('CHEBYSHEV ORDER 2 BANDSTOP FILTER');
Output
BUTTERWORTH FILTER
LPF:
Enter the frequency Fs:1000
Enter the pass band freq:40
Enter the stop band freq:150
Enter the pass band attenaution:3
Enter the stop band attenaution:60
Order 5
Normalized cut-off freq 0.0810
HPF:
Enter the frequency Fs:1000
Enter the pass band freq:40
Enter the stop band freq:150
Enter the pass band attenaution:3
Enter the stop band attenaution:60
Order 5
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
BPF:
Enter the frequency Fs:1000
Enter the pass band freq:[60 200]
Enter the stop band freq:[50 250]
Enter the pass band attenaution:3
Enter the stop band attenaution:40
Order 16
Normalized cut-off freq 0.1198 0.4005
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
BSF:
Enter the frequency Fs:1000
Enter the pass band freq:[60 200]
Enter the stop band freq:[50 250]
Enter the pass band attenaution:3
Enter the stop band attenaution:40
Order 16
Normalized cut-off freq 0.1198 0.4005
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
LPF:
Enter the frequency Fs:1000
Enter the pass band freq:40
Enter the stop band freq:150
Enter the pass band attenaution:3
Enter the stop band attenaution:60
Order 5
Normalized cut-off freq 0.0810
HPF:
Enter the frequency Fs:1000
Enter the pass band freq:40
Enter the stop band freq:150
Enter the pass band attenaution:3
Enter the stop band attenaution:60
order 5
Normalized cut-off freq 0.0810
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
BPF:
Enter the frequency Fs:1000
Enter the pass band freq:[60 200]
Enter the stop band freq:[50 250]
Enter the pass band attenaution:3
Enter the stop band attenaution:40
Order 16
Normalized cut-off freq 0.1198 0.4005
BSF:
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Industrial applications
a) Butterworth filter:
Butterworth filters are commonly used in audio equalization and crossover networks
to ensure a smooth frequency response and minimal phase distortion, providing high
quality sound reproduction in speakers, headphones, and audio amplifiers.
Butterworth filters are used in instrumentation systems for signal conditioning, data
acquisition, and noise reduction, ensuring accurate measurement and analysis of sensor
signals in industrial processes, automotive systems, and scientific instruments
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
For a filter to have linear phase, its impulse response must be symmetric or anti-
symmetric. This ensures that all frequency components of the signal are delayed by the
same amount, resulting in no distortion of the signal's waveform. Specifically:
FIR filters can have linear phase because their impulse response is symmetric
(or anti-symmetric).
IIR filters, however, generally do not have linear phase because their impulse
response is not symmetric due to the feedback structure. Therefore, it is difficult
(or impossible) to achieve linear phase in IIR filters.
3. Why is the impulse response "infinite"?
The impulse response of IIR filters is infinite because of the recursive nature of their
structure. IIR filters are characterized by feedback, where the output depends on past
outputs as well as the current and past inputs. As a result, even after the impulse input
(which is a "1" at time 0 and "0" at all other times) is applied, the output continues
indefinitely due to the recursive feedback. Thus, the impulse response is infinite, unlike
FIR filters, where the impulse response is finite and typically ends after a certain
number of samples.
4. What are the disadvantages of IIR filters (compared to FIR filters)?
Some disadvantages of IIR filters compared to FIR filters include:
Non-linear phase response: IIR filters generally do not have linear phase,
which can cause distortion in phase-sensitive applications.
Stability issues: IIR filters can become unstable if the poles are not properly
placed inside the unit circle in the z-plane.
Design complexity: IIR filters are more difficult to design compared to FIR
filters, especially when achieving specific phase and stability requirements.
Sensitivity to coefficient quantization: IIR filters can be more sensitive to
quantization errors in filter coefficients, leading to performance degradation in
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
fixed-point implementations.
5. List out the properties of IIR filters:
IIR filters have several key properties:
Recursive structure: IIR filters use feedback, meaning that past output values
affect current outputs.
Infinite impulse response: The impulse response of an IIR filter theoretically
lasts forever due to the feedback.
More efficient than FIR: IIR filters can achieve a desired filtering effect (e.g.,
a lowpass or bandpass response) with fewer coefficients compared to FIR filters,
making them computationally more efficient.
Can have poles and zeros: IIR filters can have both poles (feedback) and zeros
(feedforward), allowing more flexibility in shaping the frequency response.
Stability concerns: IIR filters can become unstable if the poles lie outside the
unit circle in the z-plane.
Non-linear phase: IIR filters generally do not have linear phase, leading to
phase distortion in the filtered signal.
Frequency selectivity: IIR filters are capable of implementing sharp frequency
responses (e.g., lowpass, highpass) with relatively few coefficients compared to
FIR filters.
RESULT
Thus, the MATLAB program for IIR filters was implemented and the responses are
plotted.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
Department: Electronics & Communication Engineering Lab Name: EC3492-DSP laboratory
no:11
Design of FINITE IMPULSE RESPONSE (FIR) FILTER
Aim
To write a MATLAB program for Finite Impulse Response (FIR) filter using window
technique.
Mapping with theory
BARTLETT WINDOW:
The Bartlett window is characterized by its triangular shape, with tapering ends
that smoothly reduce the amplitude towards the edges of the window.
This tapering reduces spectral leakage compared to rectangular windows, which
abruptly cut off at the edges.
The triangular shape of the Bartlett window ensures that the Fourier transform of
the window function exhibits a sinc-like main lobe with relatively low sidelobes,
resulting in improved frequency resolution.
HAMMING WINDOW:
The Hamming window is characterized by its raised cosine shape, with tapering
ends that smoothly reduce the amplitude towards the edges of the window.
This tapering reduces spectral leakage compared to rectangular windows, resulting
in a narrower main lobe and lower sidelobes in the frequency domain.
HANNING WINDOW:
The Hanning window is characterized by its raised cosine shape, similar to the
Hamming window. It smoothly tapers towards the edges, reducing spectral leakage
and sidelobes in the frequency domain.
BLACKMAN WINDOW:
The Blackman window is characterized by its three-term cosine shape, which
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
provides a good balance between main lobe width and sidelobe suppression. It
smoothly tapers towards the edges, reducing spectral leakage and sidelobes in the
frequency domain.
KAISER WINDOW:
It is a variable-parameter window function that offers greater control over the
trade-off between main lobe width and sidelobe levels compared to other window
functions.
The Kaiser window is particularly useful when precise control over spectral
characteristics is required.
The Kaiser window is defined by a parameter β, also known as the shape parameter
or beta parameter, which controls the trade-off between main lobe width and sidelobe
levels
RECTANGULAR WINDOW:
It is characterized by a constant value of one across its entire length and abruptly
drops to zero at the edges.
While the rectangular window has some drawbacks compared to other window
functions, such as high sidelobe levels and poor frequency resolution, it is still useful
in certain applications where simplicity and minimal processing are desired.
Procedure
4. Save Script: Save the script with a meaningful name and ".m" extension (e.g.,
"my_script.m").
5. Run Script:
1. Click the "Run" button in the Editor toolbar, or
2. Type the script name (without ".m") in the Command Window
and press Enter.
6. View Output: MATLAB will display the results in the Command Window or
graphical output in figure windows.
Pseudocode
Main Function: window_design
1. Initialize Program:
o Clear previous variables, close all figures, and clear the command
window.
2. Input Parameters:
o Prompt the user for:
rp = Passband ripple.
rs = Stopband ripple.
fp = Passband frequency.
fs = Stopband frequency.
f = Sampling frequency.
3. Calculate Normalized Frequencies:
o Compute wp = 2 * (fp / f) (normalized passband frequency).
o Compute ws = 2 * (fs / f) (normalized stopband frequency).
4. Calculate Filter Order:
o Use the formula:
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Function: design_and_plot_filter
1. Inputs:
o Filter order n.
o Passband frequency wp.
o Stopband frequency ws.
o Window type.
o Sampling frequency f.
o Filter type (lowpass, highpass, bandpass, or bandstop).
2. Determine Cutoff Frequencies:
o If filter type is bandpass or bandstop:
Set wn = [wp, ws].
o Else:
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Set wn = wp.
3. Design Filter:
o Try designing the filter using:
b = fir1(n, wn, filter_type, window_function);
4. Validate and Adjust Window Length:
Compute the actual filter order, n_actual = length(b) - 1.
Regenerate the window with n_actual + 1 length if the initial window length
doesn’t match.
5. Redesign Filter with Adjusted Window:
Use the adjusted window to redesign the filter:
b = fir1(n_actual, wn, filter_type, adjusted_window);
6. Plot Frequency Response:
Use freqz to compute the frequency response.
Plot the magnitude response on a shared subplot grid.
Annotate the title with the filter type and order.
7. Error Handling:
If any error occurs during filter design, catch it and:
o Display a warning message with the window type and filter type.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Program
function window_design()
% Clear and reset
close all;
clear;
clc;
% Normalized frequencies
wp = 2 * (fp / f);
ws = 2 * (fs / f);
% Window types
windows = {'bartlett', 'hamming', 'hann', 'blackman', 'rectwin', 'kaiser'};
for i = 1:length(windows)
window_name = windows{i};
% Lowpass filter
subplot(2, 2, 1);
design_and_plot_filter(n, wp, ws, f, window_name, 'low', 'Lowpass');
% Highpass filter
subplot(2, 2, 2);
design_and_plot_filter(n, wp, ws, f, window_name, 'high', 'Highpass');
% Bandpass filter
subplot(2, 2, 3);
design_and_plot_filter(n, wp, ws, f, window_name, 'bandpass',
'Bandpass');
% Bandstop filter
subplot(2, 2, 4);
design_and_plot_filter(n, wp, ws, f, window_name, 'stop', 'Bandstop');
end
end
switch window_name
case 'bartlett'
win = bartlett(n_actual + 1);
case 'hamming'
win = hamming(n_actual + 1);
case 'hann'
win = hann(n_actual + 1);
case 'blackman'
win = blackman(n_actual + 1);
case 'rectwin'
win = rectwin(n_actual + 1);
case 'kaiser'
win = kaiser(n_actual + 1, 1.5);
end
Output
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Industrial Applications
BARTLETT WINDOW:
Acoustic Signal Processing: Bartlett windows are used in acoustic signal
processing applications such as noise reduction, echo cancellation, and beamforming.
Sonar Systems: Bartlett windows are employed in sonar systems for underwater
signal processing to improve range resolution and reduce sidelobe interference.
HAMMING WINDOW:
Speech Processing: Hamming windows are widely used in speech processing
applications such as speech recognition, voice activity detection, and speaker
identification to improve spectral analysis and feature extraction.
Telecommunications: Hamming windows are employed in digital communication
systems for channel equalization, pulse shaping, and signal detection to reduce
intersymbol interference and improve signal-to-noise ratio.
HANNING WINDOW:
Spectrum Analysis: Hanning windows are commonly used in spectrum analysis
applications such as Fourier analysis, power spectral density estimation, and
frequency domain filtering to reduce spectral leakage and improve frequency
resolution.
RECTANGULAR WINDOW BANDSTOP FILTER
Medical Imaging: Hanning windows are applied in medical imaging modalities
such as MRI and CT scans for image reconstruction and artifact reduction, leading to
improved image quality and diagnostic accuracy.
BLACKMAN WINDOW:
Signal Processing: Blackman windows are widely used in signal processing
applications such as filtering, spectral analysis, and modulation to reduce spectral
leakage and
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
where:
h[n] are the filter coefficients (impulse response of the FIR filter).
N is the length of the filter.
Since FIR filters have a finite number of non-zero coefficients, the Z-transform is a
polynomial in z−1.
where:
h[n] are the FIR filter coefficients.
ω is the angular frequency in radians/second.
4. Can I calculate the frequency response of a FIR using the Discrete Fourier
Transform (DFT)?
Yes, the frequency response of a FIR filter can be calculated using the Discrete
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
3. The result H[k] gives the frequency response at discrete frequency points.
This method is computationally efficient and widely used in practical applications.
5. Why are FIR filters generally preferred over IIR filters in multirate
(decimating and interpolating) systems?
FIR filters are preferred over IIR filters in multirate systems because:
1. Linear Phase: FIR filters can be designed to have a linear phase response,
ensuring no phase distortion during decimation or interpolation.
2. Stability: FIR filters are inherently stable since they do not have feedback.
3. Efficient Implementation: In multirate systems, FIR filters can be optimized
using polyphase decomposition, reducing computational complexity.
4. Anti-Aliasing: FIR filters provide better control over the stopband attenuation,
making them suitable for anti-aliasing and anti-imaging operations in multirate
processing.
5. No Recursive Artifacts: IIR filters, due to their feedback, can produce
artifacts that are undesirable in systems where the sampling rate changes.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Result
Thus, the FIR filters using window technique was implemented using MATLAB.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:1 Study of Architecture of Digital Signal Processor
Aim
To study the Architecture of TMS320VC67XX DSP processor.
Introduction
The hardware experiments in the DSP lab are carried out on the Texas Instruments
TMS320C6713 DSP Starter Kit (DSK), based on the TMS320C6713 floating point
DSP running at 225MHz. The basic clock cycle instruction time is 1/ (225 MHz) = 4.44
nanoseconds. During each clock cycle, up to eight instructions can be carried out in
parallel, achieving up to 8×225 = 1800 million instructions per second (MIPS). The
DSK board includes a 16MB SDRAM memory and a 512KB Flash ROM. It has an on-
board 16-bit audio stereo codec (the Texas Instruments AIC23B) that serves both as an
A/D and a D/A converter. There are four 3.5 mm audio jacks for microphone and stereo
line input, and speaker and headphone outputs. The AIC23 codec can be programmed
to sample audio inputs at the following sampling rates: fs = 8, 16, 24, 32, 44.1, 48, 96
kHz.
The ADC part of the codec is implemented as a multi-bit third-order noise-shaping
delta-sigma converter) that allows a variety of oversampling ratios that can realize the
above choices of fs. The corresponding oversampling decimation filters act as anti-
aliasing pre- filters that limit the spectrum of the input analog signals effectively to the
Nyquist interval [−fs/2, fs/2]. The DAC part is similarly implemented as a multi-bit
second-order noise- shaping delta-sigma converter whose oversampling interpolation
filters act as almost ideal reconstruction filters with the Nyquist interval as their pass
band.
The DSK also has four user-programmable DIP switches and four LEDs that can be
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
used to control and monitor programs running on the DSP. All features of the DSK are
managed by the Code Composer Studio (CCS). The CCS is a complete integrated
development environment (IDE) that includes an optimizing C/C++ compiler,
assembler, linker, debugger, and program loader. The CCS communicates with the
DSK via a USB connection to a PC. In addition to facilitating all programming aspects
of the C6713 DSP, the CCS can also read signals stored on the DSP‟s memory, or the
SDRAM, and plot them in the time or frequency domains. The following block diagram
depicts the overall operations involved in all of the hardware experiments in the DSP
lab. Processing is interrupt-driven at the sampling rate fs, as explained below.
TMS320C6713 floating point DSP
The AIC23 codec is configured (through CCS) to operate at one of the above
sampling rates fs. Each collected sample is converted to a 16-bit two’s complement
integer (a short data type in C). The codec actually samples the audio input in stereo,
that is, it collects two samples for the left and right channels
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Architecture
The 67XX DSPs use an advanced, modified Harvard architecture that maximizes
processing power by maintaining one program memory bus and three data memory
buses. These processors also provide an arithmetic logic unit (ALU) that has a high
degree of parallelism, application-specific hardware logic, on-chip memory, and
additional on-chip peripherals. These DSP families also provide a highly specialized
instruction set, which is the basis of the operational flexibility and speed of these DSPs.
Separate program and data spaces allow simultaneous access to program instructions
and data, providing the high degree of parallelism. Two reads and one write operation
can be performed in a single cycle. Instructions with parallel store and application-
specific instructions can fully utilize this architecture. In addition, data can be
transferred between data and program spaces. Such parallelism supports a powerful set
of arithmetic, logic, and bit-manipulation operations that can all be performed in a
single machine cycle. Also included are the control mechanisms to manage interrupts,
repeated operations, and function calls.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Detailed Explanation
Central Processing Unit (CPU)
‟
Accumulators
The accumulators, ACCA and ACCB, store the output from the ALU or the multiplier
/ adder block; the accumulators can also provide a second input to the ALU or the
multiplier / adder. The bits in each accumulator are grouped as follows:
Guard bits (bits 32–39)
A high-order word (bits 16–31)
A low-order word (bits 0–15)
Instructions are provided for storing the guard bits, the high-order and the low- order
accumulator words in data memory, and for manipulating 32-bit accumulator words in
or out of data memory. Also, any of the accumulators can be used as temporary storage
for the other.
Barrel Shifter
The barrel shifter has a 40-bit input connected to the accumulator or data memory
(CB, DB) and a 40-bit output connected to the ALU or data memory (EB). The barrel
shifter produces a left shift of 0 to 31 bits and a right shift of 0 to 16 bits on the input
data. The shift requirements are defined in the shift-count field (ASM) of ST1 or
defined in the temporary register (TREG), which is designated as a shift-count register.
This shifter and the exponent detector normalize the values in an accumulator in a
single cycle. The least significant bits (LSBs) of the output are filled with 0s and the
most significant bits (MSBs) can be either zero-filled or sign- extended, depending on
the state of the sign-extended mode bit (SXM) of ST1
Multiplier/Adder
The multiplier / adder performs 17-bit 2s-complement multiplication with a 40- bit
accumulation in a single instruction cycle. The multiplier / adder block consists of
several elements: a multiplier, adder, signed/unsigned input control, fractional control,
a zero detector, a rounder (2s-complement), overflow/saturation logic, and TREG.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
The multiplier has two inputs: one input is selected from the TREG, a data memory
operand, or an accumulator; the other is selected from the program memory, the data
memory, an accumulator, or an immediate value. The fast on-chip multiplier allows
the C67XX to perform operations such as convolution, correlation, and filtering
efficiently. In addition, the multiplier and ALU together execute multiply/accumulate
(MAC) computations and ALU operations in parallel in a single instruction cycle. This
function is used in determining the Euclid distance, and in implementing symmetrical
and least mean square (LMS) filters, which are required for complex DSP algorithms.
Compare, Select, and Store Unit (CSSU)
The compare, select, and store unit (CSSU) performs maximum comparisons between
the accumulator’s high and low words, allows the test/control (TC) flag bit of status
register 0 (ST0) and the transition (TRN) register to keep their transition histories, and
selects the larger word in the accumulator to be stored in data memory. The CSSU also
accelerates Viterbi-type butterfly computation with optimized on-chip hardware.
Program Control
Program control is provided by several hardware and software mechanisms:
The program controller decodes instructions, manages the pipeline, stores the status of
operations, and decodes conditional operations. Some of the hardware elements
included in the program controller are the program counter, the status and control
register, the stack, and the address-generation logic.
Some of the software mechanisms used for program control includes branches, calls,
and conditional instructions, are peat instruction, reset, and interrupt.
The C67XX supports both the use of hardware and software interrupts for program
control. Interrupt service routines are vectored through a re-locatable interrupt vector
table. Interrupts can be globally enabled / disabled and can be individually masked
through the interrupt mask register (IMR). Pending interrupts are indicated in the
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
interrupt flag register (IFR). For detailed information on the structure of the interrupt
vector table, the IMR and the IFR, see the device-specific data sheets.
Status Registers (ST0, ST1)
The status registers, ST0 and ST1, contain the status of the various conditions and
modes for the ‟67XX devices. ST0 contains the flags (OV, C, and TC) produced
by arithmetic operations and bit manipulations in addition to the data page pointer
(DP) and the auxiliary register pointer (ARP) fields. ST1 contains the various modes
and instructions that the processor operates on and executes.
Auxiliary Registers (AR0–AR7)
The eight 16-bit auxiliary registers (AR0–AR7) can be accessed by the central
arithmetic logic unit (CALU) and modified by the auxiliary register arithmetic units
(ARAUs). The primary function of the auxiliary registers is generating 16-bit
addresses for data space. However, these registers also can act as general-purpose
registers or counters.
Temporary Register (TREG)
The TREG is used to hold one of the multiplicands for multiply and
multiply/accumulate instructions. It can hold a dynamic (execution-time
programmable) shift count for instructions with a shift operation such as ADD, LD,
and SUB. It also can hold a dynamic bit address for the BITT instruction. The EXP
instruction stores the exponent value computed into the TREG, while the NORM
instruction uses the TREG value to normalize the number. For ACS operation of
Viterbi decoding, TREG holds branch metrics used by the DADST and DSADT
instructions.
Transition Register (TRN)
The TRN is a 16-bit register that is used to hold the transition decision for the path to
new metrics to perform the Viterbi algorithm. The CMPS (compare, select, max, and
store) instruction updates the contents of the TRN based on the comparison between
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
‟
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
considerably less power than in normal operation. The IDLE1instruction is used to shut
down the CPU. The IDLE2 instruction is used to shut down the CPU and on-chip
peripherals. The IDLE3 instruction is used to shut down the 67XX processor
completely. This instruction stops the PLL circuitry as well as the CPU and peripherals.
RESULT
Thus, the study of architecture TMS320VC67XX and its functionalities has been
identified.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:2 Addition of two numbers
Aim
To perform addition of two 16-bit numbers using TMS320C50 processor, by
writing an assembly language program (ALP). This operation demonstrates basic
arithmetic functionality using the TMS320C50 processor.
In the DSP processor various addressing modes are studied. ALP for
understanding different modes this program has been done.
Addressing Modes the TMS320C67XX DSP supports three types of addressing modes
that enable flexible access to data memory, to memory-mapped registers, to register
bits, and to I/O space:
The absolute addressing mode allows you to reference a location by supplying all or
part of an address as a constant in an instruction.
The direct addressing mode allows you to reference a location using an address offset.
The indirect addressing mode allows you to reference a location using a pointer.
Each addressing mode provides one or more types of operands. An instruction that
supports an addressing-mode operand has one of the following syntax elements listed
below.
Baddr
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
When an instruction contains Baddr, that instruction can access one or two bits in an
accumulator (AC0–AC3), an auxiliary register (AR0–AR7), or a temporary register
(T0–T3). Only the register bit test/set/clear/complement instructions support Baddr.
As you write one of these instructions, replace Baddr with a compatible operand.
Cmem
When an instruction contains Cmem, that instruction can access a single word (16 bits)
of data from data memory. As you write the instruction, replace Cmem with a
compatible operand.
Lmem
When an instruction contains Lmem, that instruction can access a long word (32 bits)
of data from data memory or from a memory-mapped registers. As you write the
instruction, replace Lmem with a compatible operand.
Smem
When an instruction contains Smem, that instruction can access a single word (16
bits) of data from data memory, from I/O space, or from a memory-mapped register.
As you write the instruction, replace Smem with a compatible operand.
When an instruction contains Xmem and Ymem, that instruction can perform two
simultaneous 16-bit accesses to data memory. As you write the instruction, replace
Xmem and Ymem with compatible operands.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
This mode uses the 7-bit register called DPH (high part of the extended data page
register) and a 16-bit unsigned constant to form a 23-bit data space address. This mode
is used to access a memory location or a memory-mapped register.
k23 absolute
This mode enables you to specify a full address as a 23-bit unsigned constant. This
mode is used to access a memory location or a memory-mapped register.
I/O absolute
This mode enables you to specify an I/O address as a 16-bit unsigned constant. This
mode is used to access a location in I/O space.
This mode uses the main data page specified by DPH (high part of the extended data
page register) in conjunction with the data page register (DP).This mode is used to
access a memory location or a memory-mapped register.
SP direct
This mode uses the main data page specified by SPH (high part of the extended stack
pointers) in conjunction with the data stack pointer (SP). This mode is used to access
stack values in data memory.
Register-bit direct
This mode uses an offset to specify a bit address. This mode is used to access one
register bit or two adjacent register bits.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
PDP direct
This mode uses the peripheral data page register (PDP) and an offset to specify an I/O
address. This mode is used to access a location in I/O space. The DP direct and SP
direct addressing modes are mutually exclusive. The mode selected depends on the
CPL bit in status register ST1_67: 0 DP direct addressing mode 1 SP direct addressing
mode The register-bit and PDP direct addressing modes are independent of the CPL
bit.
You may use these modes for linear addressing or circular addressing.
AR indirect
This mode uses one of eight auxiliary registers (AR0–AR7) to point to data. The way
the CPU uses the auxiliary register to generate an address depends on whether you are
accessing data space (memory or memory-mapped registers), individual register bits,
or I/O space.
Dual AR indirect
This mode uses the same address-generation process as the AR indirect addressing
mode. This mode is used with instructions that access two or more data-memory
locations.
CDP indirect
This mode uses the coefficient data pointer (CDP) to point to data. The way the CPU
uses CDP to generate an address depends on whether you are accessing data space
(memory or memory-mapped registers), individual register bits, or I/O space.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Coefficient indirect
This mode uses the same address-generation process as the CDP indirect addressing
mode. This mode is available to support instructions that can access a coefficient in
data memory at the same time they access two other data-memory values using the
dual AR indirect addressing mode.
Circular Addressing
Circular addressing can be used with any of the indirect addressing modes. Each of
the eight auxiliary registers (AR0–AR7) and the coefficient data pointer (CDP) can be
independently configured to be linearly or circularly modified as they act as pointers
to data or to register bits, see Table 3−10. This configuration is done with a bit
(ARnLC) in status register ST2_67. To choose circular modification, set the bit. Each
auxiliary register ARn has its own linear/circular configuration bit in ST2_67: 0 Linear
addressing 1 Circular addressing The CDPLC bit in status register ST2_67 configures
the DSP to use CDP for linear addressing or circular addressing: 0 Linear addressing
1 Circular addressing You can use the circular addressing instruction qualifier, .CR, if
you want every pointer used by the instruction to be modified circularly, just add
.CR to the end of the instruction mnemonic (for example, ADD.CR). The circular
addressing instruction qualifier overrides the linear/circular configuration in ST2_67.
Apparatus required
PC with C50 Debugger
TMS320C50 Trainer Kit.
Pseudo Code
1. Load data pointer to address 100h.
2. Load accumulator with input 1234h.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
3. Add the input 1234h with the content of accumulator and store the result in
accumulator.
4. Branch conditionally to the loop if there is no carry.
5. If the above instruction is false, Store the lower order content of Accumulator
that represents sum will be moved to zeroth location of 255th page.
6. Load the accumulator with one which represent the presence of carry.
7. Store the higher order content of Accumulator that represents carry will be
moved to first location of 255th page.
8. Unconditional branch to end the program.
9. Store the lower order content of Accumulator that represents sum will be
moved to zeroth location of 255th page.
10. Load the accumulator with one which represents no carry.
11. Store the lower byte of accumulator in location 00.
12. End.
Program
Output
PI C000
Downloading From Host....
#GO C000
Executing....
Micro-50eb Serial Monitor, Ver-2.0
(c)1999, Vi Microsystems Pvt. Ltd., Chennai -96
#SD 8000
Substitute Data 8000:2468
Procedure
1. Open C50 Debugger, select project- new project.
2. Assign name for the project with the extension. dpj
3. Select file-new-assembly file and save it with the extension .asm
4. Type the program and save it.
5. Right click on assembly and select add file to project. Right click on assembly
and add
6. the file micro50
7. Right click on assembly and select build.
8. Select serial- open port 1-ok. this connects the processor to the port.
9. Switch on the processor
10. Select serial-load program-ok
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Industrial Applications
In industrial environments, signals from sensors often need conditioning before
being processed further. Addition might be part of such conditioning, for example, to
offset or calibrate sensor readings.
Addition operations might be used in error correction algorithms, modulation
schemes, or encryption/decryption processes in communication systems deployed in
industrial settings.
In systems where multiple sensors are used to gather information about a process
or environment, addition could be involved in combining sensor readings to derive
more accurate or comprehensive information.
Many industrial control systems involve calculations on sensor inputs, reference
values, and control signals. Addition might be involved in summing up multiple sensor
inputs or adjusting control signals.
impulse response (FIR) or infinite impulse response (IIR) filters, involve adding the
weighted outputs of filter taps, which are typically 16-bit numbers.
In industrial automation and robotics, motor control algorithms often require
real-time calculations on sensor inputs and control signals. Adding 16-bit values might
be involved in tasks such as computing control errors, adjusting PWM (pulse-width
modulation) signals, or implementing PID (proportional-integral-derivative)
controllers.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Result
Thus, the Addition of two 16-bit numbers was performed using DSP processor.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:3 Subtraction of two numbers
Aim
To perform subtraction of two 16-bit numbers using TMS320C50 processor, by
writing an assembly language program (ALP). This operation demonstrates basic
arithmetic functionality using the TMS320C50 processor.
Pseudo Code
1. Load data pointer to address 100h.
2. Load accumulator with input 1234h.
3. Add the input 1234h with the content of accumulator and store the result in
accumulator.
4. Branch conditionally to the loop if there is no carry.
5. If the above instruction is false, Store the lower order content of Accumulator
that represents sum will be moved to zeroth location of 255th page.
6. Load the accumulator with one which represent the presence of carry.
7. Store the higher order content of Accumulator that represents carry will be
moved to first location of 255th page.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Procedure
1. Open C50 Debugger, select project- new project.
2. Assign name for the project with the extension. dpj
3. Select file-new-assembly file and save it with the extention .asm
4. Type the program and save it.
5. Right click on assembly and select add file to project.right click on assembly and
add
6. the file micro-50
7. Right click on assembly and select build.
a.Select serial- open port 1-ok. this connects the processor to the port.
b. Switch on the processor
c.Select serial-load program-ok
d. Select serial –communication window.
e.Enter the file name in it and obtain the output.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
PI C000
Downloading From Host....
#GO C000
Executing....
Micro-50eb Serial Monitor, Ver-2.0
(c)1999, Vi Microsystems Pvt. Ltd., Chennai -96
#SD 8000
Substitute Data 8000:1110
Industrial Applications
In industrial control systems, precise control of processes or machinery often
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
requires subtracting feedback signals from reference values or set points. For example,
in temperature control systems, the difference between the desired temperature set
point and the actual temperature measured by a sensor can be calculated through
subtraction to adjust control parameters.
In industrial automation and communication systems, error detection and
correction algorithms, Subtraction can help to identify discrepancies and errors in data
transmission or reception, enabling real-time correction to ensure reliability and
accuracy.
In industrial applications where sensors measure physical quantities such as
pressure, displacement, or strain, subtraction can help eliminate unwanted DC offsets
or biases, ensuring accurate measurements.
In power generation and distribution systems, real-time monitoring and control of
electrical parameters such as voltage, current, and power factor are essential for
maintaining system stability and efficiency. Subtraction operations can be used to
calculate parameters such as active power, reactive power, and power factor from
measured voltage and current values.
Result
Thus, Subtraction of two 16-bit numbers was performed using DSP processor.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:4 Multiplication of two numbers
Aim
To perform multiplication of two 16-bit numbers using TMS320C50 processor,
by writingan assembly language program (ALP).
Objective
The objective of performing multiplication of two 16-bit numbers using a
TMS320C50 processor, is to compute the product of the two numbers accurately and
efficiently
Mapping with theory
To understand the concept of different instruction sets and different types of
register operations such as temporary registers and product registers in addition to the
accumulation and also the usage of direct addressing mode
Apparatus Required
PC with C50 Debugger
TMS320C50 Trainer Kit.
Procedure
1. Open C50 Debugger , select project- new project.
2. Assign name for the project with the extension .dpj
3. Select file-new-assembly file and save it with the extention .asm
4. Type the program and save it.
5. Right click on assembly and select add file to project.right click on assembly
and add the file micro 50
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Pseudo Code
1. Load the data pointer to 100h, (Zeroth location of 255th page)
2. Load the temporary register with the contents of memory location 00
3. Multiply the contents of memory location 01 & 00 and keep the result in
the product register. (unsigned number)
4. Move the content of product register to accumulator
5. Store the lower byte of accumulator to location 02
6. Store the upper byte of accumulator to location 03
7. End the program
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Program
LABEL PROGRAM COMMENT
ldp #10h Load the data pointer to 100h,Zeroth location of 255th page
Output
#SD 8000
Substitute Data 8000:0345-
Industrial Application
In industries where motors are used extensively, such as robotics, manufacturing, or
automotive sectors, precise control of motor speed, torque, and position, Multiplication
operations are used in motor control algorithms for tasks like generating pulse-width
modulation (PWM) signals, calculating motor torque, or implementing sensor less control
techniques.
In power electronic systems like inverters, converters, and rectifiers, multiplication
operations are essential for tasks like calculating power flow, voltage/current control, and
harmonic analysis.
In industrial automation and monitoring systems, Multiplication operations may be
employed to process sensor signals, calibrate measurements, or perform statistical
analysis for condition monitoring and predictive maintenance applications.
The ability to efficiently multiply 16-bit numbers using the TMS320C50 processor
enables faster and more accurate computation, leading to improved system performance,
reliability, and productivity in industrial processes.
Result
Thus, the Multiplication of two 16-bit numbers was performed using DSP processor.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:5 Exchange a block of Data
Aim
To write an assembly language program to exchange a block of data using
TMS320C50 DSP processor. The program aims to transfer a block of data as quickly
and efficiently as possible to minimize processing overhead and reduce latency.
Apparatus Required
PC with C50 Debugger
TMS320C50 Trainer Kit.
Procedure
1. Open C50 Debugger, select project- new project.
2. Assign name for the project with the extension. dpj
3. Select file-new-assembly file and save it with the extension .asm
4. Type the program and save it.
5. Right click on assembly and select add file to project. Right click on
assembly and add the file micro-50
6. Right click on assembly and select build.
7. Switch on the processor
8. Select serial-load program-ok Select serial –
communication window.
9. Enter the file name in it and obtain the output.
Pseudocode
1. Load the data pointer to 100h
2. Load the auxiliary register0 with address 8000h (first block)
3. Load the auxiliary register1 with address 9000h (second Block)
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Program
LABEL PROGRAM COMMENT
Ldp #100h Load the data pointer to 100h
Lar ar0, #8000h Load the auxiliary register0 with address 8000h
(POINTER REGISTER TO POINT ARRAY OF
DATA)
Lar ar1, #9000h Load the auxiliary register1 with address 9000h
(POINT THE SECOND ARRAY)
Lar ar2, #04 Load the auxiliary register with count 04
mar*, ar1 Modify the auxiliary register ar1
loop lacc*, ar0 Load the accumulator with data pointed by the
pointer and modify to ar0
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
L b l End
Output
PI C000
Downloading From Host....
#SD 8000
Industrial Application
In industrial power electronics applications such as motor drives, inverters,
and power converters, exchanging data blocks is crucial for controlling power
flow, voltage regulation, and current sensing.The TMS320C50 can be employed
in data acquisition systems, oscilloscopes, spectrum analyzers, and other test
instruments for exchanging data blocks with high throughput and low latency.
In embedded control systems for industrial machinery, robotics, and
automation equipment, the TMS320C50 can serve as a central processing unit for
exchanging data between sensors, actuators, and control algorithms.
Industrial signal processing applications, such as audio processing, image
processing, and vibration analysis, often involve the exchange of large blocks of
data for real-time analysis and manipulation. Industrial communication systems,
including wired and wireless networks, require efficient data exchange for
transmitting and receiving data packets.
In medical devices for patient monitoring and diagnostics, exchanging
blocks of physiological data (e.g., ECG, EEG) enables real-time analysis for
detecting abnormalities and providing timely feedback to healthcare
professionals.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Result
Thus, the block of data has been exchanged successfully using the DSP Processor
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:6 Implementation Of Linear Convolution
Aim
To write an assembly language program to perform linear convolution of two
sequence using TMS320C50 DSP processor.
Mapping with theory
Linear convolution is a fundamental operation in digital signal processing used to
determine the output of a Linear Time-Invariant (LTI) system when the input signal
and the system's impulse response are known.A DSP processor efficiently implements
convolution due to its specialized architecture, including hardware multipliers,
accumulators, and support for addressing modes like circular buffering and pipelining.
Implementation in DSP Processors
DSP processors perform convolution using:
1. Multiply-and-Accumulate (MAC):
o Multiply elements of x[n] and h[n] and accumulate the result.
2. Efficient Addressing Modes:
o Use circular buffering to handle wrap-around for input/output buffers.
3. Pipelining:
o Perform multiple operations simultaneously for faster execution.
Apparatus required
PC with C50 Debugger
TMS320C50 Trainer Kit.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Pseudo Code
1. Load data pointer with address data #100h
2. Load auxiliary register ar0 with h(n) data with starting address 8100h
3. Load auxillary register ar1for output data y(n) from 8050h
4. Load auxillary register ar4with the length of output sequence. (n1+n2-1)
5. Load auxillary register ar3 with x(n) data with starting address 800fh
6. Load accumulator with program memory c100h
7. Modify the auxillary register to point to ar3
8. Repeat next instruction (5+1) times as a specified byte data #05
9. The contents of data memory address 800fh-8013h are moved to program
memory address c100h-c104h
10. Load auxillary register ar0.Actual data starts at 8104h
11. Clear the accumulator and product register as zero
12. Modify Auxillary register to point to ar0
13. Repeat the next instruction (5+1) times as a specified byte of data #05h
14. The PREG content is added to accumulator. The content of program memory
address and data memory address is multiplied and product is loaded in PREG
and the program memory address is incremented and data memory address is
decremented
15. Modify auxillary register to point to ar1
16. Store lower order byte of accumulator in memory location pointed by ar1.
Increment ar1 and modify pointer to ar0. ar0=ar0+7
17. Modify auxillary register to point to ar4
18. Branch on accumulator ar4 not zero to loop
19. Indefinite loop
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Program
LABEL PROGRAM COMMENT
ldp #100h Load data pointer with address data #100h
lar ar0,#8100h Load auxillary register ar0 with h(n) data with
starting address 8100h
lar ar1,#8050h Load auxillary register ar1for output data y(n)
from 8050h
lar ar4,#0007h Load auxillary register ar4with the length of
output sequence.(n1+n2-1)
lar ar3,#800fh Load auxillary register ar3 with x(n) data with
starting address 800fh
lacc #0c100h Load accumulator with program memory c100h
mar*,ar3 Modify the auxillary register to point to ar3
rpt #05h Repeat next instruction (5+1) times as a specified
byte data #05
tblw*+ The contents of data memory address 800fh-
8013h are moved to program memory address
c100h-c104h
lar ar0,#8104h Load auxillary register ar0.Actual data starts at
8104h
Loop zap Clear the accumulator and product register as zero
mar*,ar0 Modify Auxillary register to point to ar0
rpt #05h Repeat the next instruction (5+1) times as a
specified byte of data #05h
mac 0c100,*- The PREG content is added to accumulator. The
content of program memory address and data
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Output
PI C000
Downloading From Host....
#SD 8100
Substitute Data 8100:0000-
Substitute Data 8101:0000-
Substitute Data 8102:0000-
Substitute Data 8103:0000-
Substitute Data 8104:0003-
Substitute Data 8105:0004-
Substitute Data 8106:0005-
Substitute Data 8107:0000-
Substitute Data 8108:0000-
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Procedure
1. Open C50 Debugger, select project- new project.
2. Assign name for the project with the extension. dpj
3. Select file-new-assembly file and save it with the extension .asm
4. Type the program and save it.
5. Right click on assembly and select add file to project. Right click on assembly
and add file micro-50
6. Right click on assembly and select build.
7. Select serial- open port1-ok. this connects the processor to the port.
8. Switch on the processor
9. Select serial-load program-ok
10. Select serial –communication window.
11. Enter the data in it and obtain the output.
Industrial application
In industrial automation and control systems, linear convolution is used for
filtering and conditioning sensor signals to remove noise, interference, or undesired
components. This ensures accurate and reliable measurement of process variables such
as temperature, pressure, and flow rates.
In telecommunications and networking equipment, linear convolution is
employed for tasks such as channel equalization, error correction coding, and
modulation/demodulation.
Linear convolution is utilized in audio processing applications for tasks like room
impulse response modeling, reverberation effects, and equalization. In industrial
settings such as auditoriums, conference rooms, or recording studios, linear
convolution helps in simulating acoustic environments and enhancing audio quality.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
In medical imaging and diagnostic equipment, linear convolution is used for tasks
such as image filtering, deconvolution, and signal enhancement. It helps in improving
the clarity and resolution of medical images obtained from modalities such as MRI
(Magnetic Resonance Imaging), CT (Computed Tomography), and ultrasound.
Linear convolution is applied in structural health monitoring systems for
analyzing vibration signals from machinery, buildings, bridges, and other structures. It
helps in identifying structural defects, detecting anomalies, and predicting potential
failures based on the characteristics of vibration signals.
Result
Thus, linear convolution of two sequences was performed using DSP
processor.
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Experiment
no:7 Generation of various waveforms
Aim
To generate a sine wave, square wave, Triangular wave and Saw tooth wave using
TMS320C5416XX DSP KIT.
Mapping with theory
Generating waveforms using a DSP processor involves utilizing the computational
power of the processor to compute and output the desired waveform in real-time or
pre-computed samples. The waveforms are essential in signal processing for testing
systems, simulating signals, and driving hardware.
1. Theory of Waveform Generation
Waveforms are mathematical representations of signals over time. Common types
include sinusoidal, square, triangular, and sawtooth waveforms. These can be
generated using algorithms that define the waveform mathematically or through table
lookups.
Types of Waveforms
Sinusoidal Waveform
o Defined by
Where:
A: Amplitude
f: Frequency
T: Sampling period (T=1/fs, fs is the sampling frequency)
ϕ: Phase offset
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Triangular Waveform:
Linearly increases and decreases over a period.
Typically derived from sawtooth with modifications.
Sawtooth Waveform:
A ramp signal that resets periodically.
Defined by:
MAIN_LOOP:
// Step 4: Read the next sine sample from the lookup table
sineValue = SINE_TABLE[currentIndex]
// Step 5: Output the sine sample to the DAC
Write sineValue to DAC output port
// Step 6: Increment the index for the next sample
currentIndex = currentIndex + stepSize
If currentIndex >= TABLE_SIZE:
currentIndex = currentIndex - TABLE_SIZE // Wrap around to start of
table
// Step 7: Wait for the next sampling period
Wait for interrupt or timer event
// Repeat the loop
Go to MAIN_LOOP
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Square waveform
START:
// Step 1: Initialize DSP processor and configure registers
Set stack pointer to 0x140 (STM #140H, ST0)
Reset the CPL register (RSBX CPL)
Perform stabilization with no-operation instructions (NOP, NOP, NOP, NOP)
MAIN_LOOP:
// Step 2: Toggle DATA value and create a delay
Set DATA to 0x0000 // Clear DATA
Call DELAY subroutine // Introduce a delay
Set DATA to 0x0FFF // Set DATA to maximum value
Call DELAY subroutine // Introduce a delay
DELAY:
// Step 4: Introduce a delay using a counter
Initialize AR1 to 0x0FFF // Set counter (STM #0FFFH, AR1)
DELAY_LOOP:
Output DATA value to port 0x04 (PORTW DATA, 04H)
Decrement AR1 (AR1 = AR1 - 1)
If AR1 is not zero, repeat DELAY_LOOP (BANZ DELAY_LOOP)
Return from the subroutine (RET)
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Triangular wave
BEGIN
WHILE DATA < 0FFFH: // Continue incrementing while DATA is less than
0FFFH
// Load DATA into register A
A = DATA
// Increment the value in register A by 1
A = A + 1H
// Store the incremented value back into DATA
DATA = A
// Output the value of DATA to port 04H (simulate hardware output)
OUTPUT(DATA, 04H)
// Compare DATA with 0FFFH
IF DATA == 0FFFH THEN
BREAK // Exit the loop if DATA reaches 0FFFH
END WHILE
// Repeat the main loop (reset and continue the process)
GOTO LOOP
END
Program
Sine waveform
mmreg
.text
START:
STM #140H,ST0
RSBX CPL
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
NOP
NOP
NOP
NOP
REP:
LD #TABLE,A
STM #372,AR1
LOOP:
READA DATA
PORTW DATA,04H
ADD #1H,A
B REP
}
}
Square waveform
DATA .SET 0H
.mmregs
.text
START:
STM #140H,ST0
RSBX CPL ; NOP
NOP
NOP
NOP
REP:
ST #0H,DATA
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
CALL DELAY
ST #0FFFH,DATA
CALL DELAY
B REP
DELAY:
STM #0FFFH,AR1
DEL1:
PORTW DATA,04H
BANZ DEL1,*AR1-
RET
TRIANGULAR WAVE GENERATION
DATA .SET 0H
.mmregs
.text
START:
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
REP:
ST #0H,DATA
INC:
LD DATA,A
ADD #1H,A
STL A,DATA
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
PORTW DATA,04H
CMPM DATA,#0FFFH
BC INC,NTC
DEC:
LD DATA,A
SUB #1H,A
STL A,DATA
PORTW DATA,04H
CMPM DATA,#0H
BC DEC,NTC
B REP
ADD #1H,A
STL A,DATA
PORTW DATA,04H
CMPM DATA,#0FFFH
BC INC,NTC
B REP
Procedure
1. Open C50 Debugger, select project- new project.
2. Assign name for the project with the extension. dpj
3. Select file-new-assembly file and save it with the extension .asm
4. Type the program and save it.
5. Right click on assembly and select add file to project. Right click on assembly
and add file micro-50
6. Right click on assembly and select build.
7. Select serial- open port1-ok. this connects the processor to the port.
8. Switch on the processor
9. Select serial-load program-ok
10. Select serial –communication window.
Enter the data in it and obtain the output.
Industrial Applications
Digital Signal Processors (DSPs) are widely used in communication systems for
generating and processing modulated signals like AM, FM, and PM for radio
transmitters and receivers, enabling efficient transmission of data over
communication channels. DSPs are also integral in audio and speech processing
MEENAKSHI SUNDARARAJAN ENGINEERING COLLEGE
(An autonomous Institution)
#363, Arcot Road, Kodambakkam, Chennai – 600024, Tamil Nadu, India
Answer:
A DSP processor generates a sine wave using a look-up table with precomputed
sine values or by calculating the sine function directly using algorithms like Direct
Digital Synthesis (DDS).
Question 4: What are the advantages of using DSP processors for waveform
generation over analog methods?
Answer:
DSP processors offer better precision, flexibility, ease of frequency control, and the
ability to generate complex waveforms without the need for analog components.
Result
Thus, the Sine wave, Square, Triangular and Saw tooth waveform was
generated displayed at graph.