How to find the fall time of a voltage pulse.
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Share a link to this question
I have a waveforn captured using an osciloscope and saved in a csv file. I am trying to find the 20% to 80% fall time value and plot the waveform with markers. Column 4 is the time (x axis) and column 5 is the voltage data (y axis) .
Accepted Answer
BP
on 27 Aug 2021
0 votes
The csv file is attached.
10 Comments
Star Strider
on 27 Aug 2021
See my Comment to my Answer.
.
BP
on 31 Aug 2021
I am trying to find the 20% to 80% fall time as shown in the graph in the attached spreadsheet.
BP
on 2 Sep 2021
When I run this section of code below, I get the error :
Error using +
Arrays have incompatible sizes for this operation.
Error in VPlot_9_2_r1 (line 104)
xm(k1) = interp1(y(idxrng2+(-3:3)), x(idxrng2+(-3:3)), hafmax(k1));
Line 104 is the last line of the above code.
Any suggestions?
for k1 = 1:numel(hafmax)
% idxrng1 = find(y(1:idx)<hafmax(:,k1), 1, 'last')
idxrng2 = find(y(idx:numel(x))<hafmax(:,k1),1,'first')+idx;
% xm(k1) = interp1(y(idxrng1+(-3:3)), x(idxrng1+(-3:3)), hafmax(k1));
xm(k1) = interp1(y(idxrng2+(-3:3)), x(idxrng2+(-3:3)), hafmax(k1));
end
Star Strider
on 2 Sep 2021
My code runs without error, so I have no idea what the problem could be.
Check to see what ‘idxrng2’ returns in your code. It should have only one (scalar) value. If it has more than one value or is empty, either of those conditions could throw that error. (I assume you are using a different data set from the one posted that I am using.)
The data you are using could be too noisy. In that situation, increase the window size (third argument) to the sgolayfillt call:
y = sgolayfilt(y, 3, 121); % Filter Out Some Of The Noise
It might be necessary to experiment with it until there is no long a problem with what the find call returns.
.
BP
on 2 Sep 2021
It showes the following
idxrng2 =
1×0 empty double row vector
What is this telling me?
Star Strider
on 2 Sep 2021
It is telling you generally that no values in the data meet that criterion, or more specifically, that on the descending limb of the curve (governed by ‘idxrng2’) there are no values less than ‘hafmax’.
Be certain that you defined ‘hafmax’ in the context of the data.
If you are using the same data I use in my Answer, there should be no problems. If you are using different data, post it and I willl see what I can do so that my code will work with it.
.
BP
on 2 Sep 2021
I am using the same data and the same code you used. and it's giving the following error.
Error using +
Arrays have incompatible sizes for this operation.
Error in Diff_Mode_Voltage_1kVPlot_BFP_9_2_r1 (line 43)
xm(k1) = interp1(y(idxrng2+(-3:3)), x(idxrng2+(-3:3)), hafmax(k1));
Below is the code i am using
T1 = readtable('v pulse1 with chart.xlsx');
t = T1.Var4;
y = T1.Var5;
figure
plot(t, y)
grid
% LD = load('filtered_abp[1].mat');
% y = LD.filtered_abp;
% t = linspace(0, numel(y)-1, numel(y));
x = t(:).'; % Force Row Vectors
y = y(:).'; % Force Row Vectors
y = sgolayfilt(y, 3, 121); % Filter Out Some Of The Noise
figure
plot(t, y)
grid
xlabel('t')
ylabel('Pressure')
title('Original Signal')
% y = detrend(y, 15);
[ymx,idx] = findpeaks(y, 'MinPeakProminence',100);
vals = [0.8 0.2];
hafmax = vals*ymx
hafmax = [1 2]
for k1 = 1:numel(hafmax)
% idxrng1 = find(y(1:idx)<hafmax(:,k1), 1, 'last')
idxrng2 = find(y(idx:numel(x))<hafmax(:,k1),1,'first')+idx;
% xm(k1) = interp1(y(idxrng1+(-3:3)), x(idxrng1+(-3:3)), hafmax(k1));
xm(k1) = interp1(y(idxrng2+(-3:3)), x(idxrng2+(-3:3)), hafmax(k1));
end
format short g
xm = xm
xm = [1 2]
% wp = diff(xm,[],2);
% wpmtx = buffer(wp,7) % Show All Values
format short
figure
plot(x, y)
hold on
for k = 1:numel(hafmax)
plot([min(xlim) xm(k)], [1 1]*hafmax(k), '--r', 'LineWidth',1.5)
plot([1 1]*xm(k), [min(ylim) hafmax(k)], '--r', 'LineWidth',1.5)
end
hold off
grid
text(xm, hafmax, compose(' \\leftarrow %2.0f%% = %.5f \\mus',[80 20; xm*1E+6].'), 'Horiz','left', 'Vert','middle', 'FontSize',8)
xlabel('t')
ylabel('Pressure')
title('Detrended Signal With Data')
Star Strider
on 2 Sep 2021
hafmax = [1 2]
and
xm = [1 2]
and it works. Those lines were never in any code I posted here. I have no idea where they came from.
.
BP
on 2 Sep 2021
That worked
Star Strider
on 2 Sep 2021
If it worked, please Accept my answer.
I made no changes in my code, and simply corrected your changed copy of it.
.
More Answers (1)
BP
on 7 Sep 2021
0 votes
It prints the correct data in the following form.
hafmax =
722.4474 180.6118
xm =
-2.2256e-06 9.72e-05
xm =
1.0e-04 *
-0.0223 0.9720
I think hefmax is the 20% and 80% points =180.61 volts and 722.45 volts.
I think 1.0e-4* is the time between the rising edge and fallowing edge which occures at t=-0.0223 and t=0.9720.
Is this correct?
--------------------
With the code as writen, is there any way to make it print out the values as shown below?
20% point= 180.61 volts
80% point =722.45 volts
FWHM time= 1.0e-04
X t1=-0.0223
X t2=0.9720
------------------------
So far, this is all i've been ably to get the data to displat which is not what I need it to look like. Please give me help and suggestions.
hafmax =
722.4474 180.6118
xm =
-2.2256e-06 9.72e-05
xm =
1.0e-04 *
-0.0223 0.9720
Full Width Half riseing edge/ falling edge) = -0.000002 u sec.
Full Width Half riseing edge/ falling edge) = 0.000097 u sec.
Hafmax points high/ low) = 722.447381 Volts.
Hafmax points high/ low) = 180.611845 Volts.
Categories
Find more on Waveform Generation in Help Center and File Exchange
Tags
See Also
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)