DSPlab 5
DSPlab 5
Sr.
List of Experiments
No
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
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
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);
%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:
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.