0% found this document useful (0 votes)
36 views18 pages

DSPlab 5

Uploaded by

shreyadhanbhar23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views18 pages

DSPlab 5

Uploaded by

shreyadhanbhar23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

COEP, Technological University

Dept. of Electronics and Telecommunication Engineering

Name: Shreya Mangesh Dhanbhar


MIS: 612207020
Branch : TY B.Tech E & TC
Course : Digital Signal Processing LAB
Course Code: ET-21006

Digital Signal Processing LAB Submission


INDEX

Sr.
List of Experiments
No

1 a) Generation of basic signals using C/ Python and MATLAB.


b) Verification of Sampling theorem
a) Program to obtain Linear Convolution of two finite length sequences and verify the
properties of linear convolution
2 b) Program to obtain Circular Convolution of two finite length sequences using FFT method
Using C/ Python and MATLAB

a) Program for computing auto correlation of two finite length sequences and obtain the
energy of the input sequence.
3 b) Program for computing cross correlation of two finite length sequences and using it to
find the delay between signals.
Using C/ Python and MATLAB

4 To perform spectral analysis of discrete signal using C/ Python and MATLAB

a) Implementation of Low Pass and High Pass FIR filter for a given sequence
5 b) Implementation of Low Pass and High Pass IIR filter for a given sequence
Using C/ Python and MATLAB

a) Implementation of Decimation Process


6 b) Implementation of Interpolation Proces
Using C/ Python and MATLAB

7 Generation of Sinusoidal signal through filtering C/ Python and MATLAB

8 To perform audio/speech processing C/ Python and MATLAB

9 To perform ECG signal processing C/ Python and MATLAB

Implementing Linear Convolution and Circular Convolution in TMS320 C6748 DSP


10
Processor.

11 DFT with FFT using TMS320 C6748 DSP Processor.

Noise removal: Add noise above 3kHz and then remove; Interference Suppression using
12
400 Hz Tone using TMS320 C6748 DSP Processor.
EXPERIMENT 5

AIM:
a. Implementation of Low Pass and High Pass FIR filter for a given sequence
b. Implementation of Low Pass and High Pass IIR filter for a given sequence

Software: MATLAB

Code:
%Butterworth low pass filter
rp = 1; rs = 40; fpass = 1000; fstop = 2000; fsample = 8000; Wp = fpass/(fsample/2);
Ws = fstop/(fsample/2);
[n, Wn] = buttord(Wp, Ws, rp, rs); [b, a] = butter(n, Wn, 'low');
fvtool(b, a);

%Butterworth high pass filter


rp = 1; rs = 40; fpass = 1000; fstop = 2000; fsample = 8000; Wp = fpass/(fsample/2);
Ws = fstop/(fsample/2);
[n, Wn] = buttord(Wp, Ws, rp, rs); [b, a] = butter(n, Wn, 'high'); fvtool(b, a);

%Chebyshev I Low Pass filter


rp = 1; rs = 40; fpass = 1000; fstop = 2000; fsample = 8000; Wp = fpass/(fsample/2);
Ws = fstop/(fsample/2);
[n, Wn] = cheb1ord(Wp, Ws, rp, rs); [b, a] = cheby1(n, rp, Wn, 'low');
fvtool(b, a);

%Chebyshev I high Pass filter


rp = 1; rs = 40;
fpass = 1000;
fstop = 2000;
fsample = 8000;
Wp = fpass/(fsample/2);
Ws = fstop/(fsample/2);
[n, Wn] = cheb1ord(Wp, Ws, rp, rs); [b, a] = cheby1(n, rp, Wn, 'high');
fvtool(b, a)

%Rectangular Window Low Pass filter


fsample = 8000;
fcutoff = 1000;
filter_order = 50;
Wn = fcutoff / (fsample / 2);
b = fir1(filter_order, Wn, 'low', rectwin(filter_order + 1));
fvtool(b, 1, 'Fs', fsample);

%Hamming Window Low Pass filter


fsample = 8000;
fcutoff = 1000;
filter_order = 50;
Wn = fcutoff / (fsample / 2);
b = fir1(filter_order, Wn, 'low', hamming(filter_order + 1));
fvtool(b, 1, 'Fs', fsample);

%Hanning Window high Pass filter


fsample = 8000;
fcutoff = 1000;
filter_order = 50;
Wn = fcutoff / (fsample / 2);
b = fir1(filter_order, Wn, 'high', hanning(filter_order + 1));
fvtool(b, 1, 'Fs', fsample);

%Bartlett Window Low Pass filter


fsample = 8000;
fcutoff = 1000;
filter_order = 13;
Wn = fcutoff / (fsample / 2);
b = fir1(filter_order, Wn, 'low', bartlett(filter_order + 1));
fvtool(b, 1, 'Fs', fsample);

%Bartlett Window high Pass filter


fsample = 8000; fcutoff = 1000;
filter_order = 50;
Wn = fcutoff / (fsample / 2);
b = fir1(filter_order, Wn, 'high', bartlett(filter_order + 1));
fvtool(b, 1, 'Fs', fsample);

%NOISE REMOVE:
sample_rate = 1000;
t = 0:1/sample_rate:1.0;
freq1 = 500;
freq2 = 100;
freq3 = 120;
signal = sin(2 * pi * freq1 * t) + 0.5 * sin(2 * pi * freq2 * t) + 0.2 * sin(2 * pi * freq3 * t);
wo = 50/(sample_rate/2); bw = wo/35;
[b, a] = iirnotch(wo, bw);
filtered_signal_iir = filter(b, a, signal);
filt_order = 100; nyquist = sample_rate / 2;
cutoff = [45 55]; fir_coeff = fir1(filt_order, cutoff/nyquist, 'stop');
filtered_signal_fir = filter(fir_coeff, 1, signal);
figure; subplot(3,1,1); plot(t, signal, 'b-');
title('Original Signal (Time Domain)'); xlabel('Time [s]'); ylabel('Amplitude'); grid on;
subplot(3,1,2);
plot(t, filtered_signal_iir, 'r-'); title('IIR Filtered Signal (Time Domain)'); xlabel('Time [s]');
ylabel('Amplitude');
grid on;
subplot(3,1,3); plot(t, filtered_signal_fir, 'g-'); title('FIR Filtered Signal (Time Domain)'); xlabel('Time
[s]'); ylabel('Amplitude');
grid on;
n = length(signal);
f = (0:n-1)*(sample_rate/n);
signal_fft = abs(fft(signal));
filtered_signal_iir_fft = abs(fft(filtered_signal_iir));
filtered_signal_fir_fft = abs(fft(filtered_signal_fir));
figure;
subplot(3,1,1);
plot(f, signal_fft);
title('Original Signal (Frequency Domain)');
xlabel('Frequency [Hz]');
ylabel('Magnitude');
grid on;
subplot(3,1,2);
plot(f, filtered_signal_iir_fft);
title('IIR Filtered Signal (Frequency Domain)'); xlabel('Frequency [Hz]');
ylabel('Magnitude');
grid on;
subplot(3,1,3);
plot(f, filtered_signal_fir_fft);
title('FIR Filtered Signal (Frequency Domain)'); xlabel('Frequency [Hz]');
ylabel('Magnitude');
grid on;
Output:

• Butterworth low pass filter


• Butterworth high pass filter
• Chebyshev I Low Pass filter
• Chebyshev I high Pass filter
• Rectangular Window Low Pass filter
• Rectangular Window High Pass filter
• Hamming Window Low Pass filter
• Hamming Window High Pass filter
• Bartlett Window Low Pass filter
• Bartlett Window High Pass filter
• NOISE REMOVE
Observation:
1. Butterworth Filter: A smooth and maximally flat response in the passband with no ripples.
Chebyshev Type I Filter: A filter with ripples in the passband and sharper roll-off than Butterworth.
2. Chebyshev Type II Filter: A filter with ripples in the stopband and sharper roll-off but no ripples
in the passband. FIR Filters:
3. Rectangular Window: Exhibits the sharpest transition between passband and stopband. Results in
more ripple in the stopband, which can cause unwanted frequencies to pass through.
4. Hamming and Hann Windows: Provide smoother transitions with less ripple in the stopband. The
frequency response is more gradual compared to the rectangular window, reducing the presence of
stopband ripple.
5. Blackman Window: Produces the smoothest frequency response. Offers the highest attenuation in
the stopband but has a wider transition band, meaning the filter doesn't cut off frequencies as
sharply as the rectangular window.

Conclusion:
IIR filters like Butterworth and Chebyshev offer sharper roll-offs, with Chebyshev filters introducing
ripples either in the passband or stopband for increased efficiency. FIR filters, using windows like
Rectangular, Hamming, and Blackman, trade between sharp transitions and smoother responses with
reduced ripple.

You might also like