MATLAB Answers

Isolating a single pulse by removing noise

39 views (last 30 days)
Hans123
Hans123 on 13 Sep 2019
Commented: Star Strider on 13 Sep 2019
I hope my title wasn't misleading, I simply want to remove the oscillatory noise from the pulse I obtain from a monostable multivibrator.
I have attached a picture of the Time Domain waveform (which is the same as the snapshot from the o-scope) below, I want to isolate the 50ns initial pulse. I am thinking of using a low-pass filter to achieve that but inorder to do so I need to find the frequencies of the noise.
And I have attached the plots for the Frequency Domain graphs that I obtained after using FFT.
zoomed into the range of 0~20 Hz
I am having a hard time identifying which frequencies are from the noise and which frequency is that of the 50ns initial pulse that I am interested in, so I can find the ideal resistor-capacitor combination for the low pass filter to isolate the pulse from the noise
Any help would be greatly appreciated. I have attached the CSV file I obtained from the o-scope and my code incase that helps.
Thanks in advance!
clc; clear all; close all
A = dlmread("F0000CH1.CSV",",",0,3);
Time = 1e9.*A(:,1);
Voltage = A(:,2);
figure
plot(Time,Voltage,'LineWidth',2)
title('Time Domain Function')
ylabel('Voltage (V)')
xlabel('Time (ns)')
xlim([-125 400])
ylim([-4.5 6])
%frequency domain
S=numel(Time);
FFT = fft(Voltage,S);
Pyy = FFT.*conj(Voltage)/S;
f = (1000/S)*(0:floor(S/2));
figure
plot(f,Pyy(1:floor(S/2)+1))
title('Frequency Domain')
xlabel('Frequency (Hz)')
ylabel('dB/frequency')
figure
plot(f(1:50),Pyy(1:50),'LineWidth',2)
title('Frequency Domain')
xlabel('Frequency (Hz)')
ylabel('dB/frequency')

Accepted Answer

Star Strider
Star Strider on 13 Sep 2019
Try this:
A = dlmread('F0000CH1.csv',",",0,3);
Time = 1e9.*A(:,1);
Voltage = A(:,2);
figure
plot(Time,Voltage,'LineWidth',2)
title('Time Domain Function')
ylabel('Voltage (V)')
xlabel('Time (ns)')
xlim([-125 400])
ylim([-4.5 6])
L = numel(Time); % Signal Length
Ts = mean(diff(Time)); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
FT_V = fft(Voltage)/L; % Normalised Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FT_V(Iv))*2)
grid
xlim([0 0.5])
Wp = 0.045; % Passband Frequency (Normalised)
Ws = 0.050; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 50; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Elliptic Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp); % Elliptic Filter Design: Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos, 2^16, Fs) % Filter Bode Plot
Voltage_filt = filtfilt(sos, g, Voltage); % Filter Signal
figure
plot(Time,Voltage_filt,'LineWidth',2)
title('Time Domain Function')
ylabel('Voltage (V)')
xlabel('Time (ns)')
xlim([-125 400])
ylim([-4.5 6])
I chose a passband frequency of 0.045 Hz and a stopband frequency of 0.050 Hz, based on the Fourier transform results, since it appeared to give good results. This code designs an 7-order elliptic filter, since these filters are efficient. Experiment with the filter characteristics to decide on the paramerers for your hardware filter.
  2 Comments
Star Strider
Star Strider on 13 Sep 2019
As always, my pleasure!
I very much appreciate your compliments!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!