LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain duration of a waveform above a certain threshold?

Solved!
Go to solution

A simple problem..I acquire data from DAQ assist and am reading it back to plot using read from measurement file.

 

My signal will be with just one peak (see attached fig) 

 

I need to find the time duration for which my waveform value is greater than 150. 

I'm able to find the time waveform first crosses threshold...however the second point where waveform comes below the threshold..i'm not able to find

 

second attachement is part of the vi created..

 

If I can find the second time where waveform goes below the threshold, I can calculate the time using dt..

Download All
0 Kudos
Message 1 of 13
(5,657 Views)
one way - Start a counter (a while loop ) when the value is 150 stop the while loop when the value goes below 150.
0 Kudos
Message 2 of 13
(5,649 Views)

Hi Palkin,

 

Like mentioned here, you can use the Threshold Peak detector.vi function. Get its indices or count, use dt of you waveform to find the time duration of the threshold.

 

Another solution which I donot recommend but since you have already started off with express VIs, use the Mask and Limit Testing function, and set it for Lower limit masking  with lower limit constant=150. 

 

I still recommend  you to use the first method.:smileywink:

Message 3 of 13
(5,639 Views)

Vsh,

With threshold peak detector, I can get the first point... But second point where signal goes below threshold is not given by indicies.. 

 

I was thinking of what muks has suggested... wanted to see if there's any other easier way to get the second point..

0 Kudos
Message 4 of 13
(5,630 Views)

Palkin,

 

Have you tried reversing the array and repeating threshold 1D array?

 

After that you will have two 1D array thresholds and you know the size of the array. Subtract the two threshold values from the size of the array. The remainder is the size of the pulse in terms of array elements then multiply that with your dt to get the pulse width.

 

cheers

 

David

 

 

Message 5 of 13
(5,614 Views)

Hi palkin,

   Actually you can achive your program by making use of event structure.Here i had done small program where i simulated one sine signal and compared with a threshold of 1.5.Now whenever the sinesignal crosses 1.5 ,an event will be generated and i am catching that event and calculating the time at which that event has been generated and next again ,i am waiting for the sine to come down below 1.5 and it again generated another event and time,so i am taking the difference of both of those times.I am attaching the VI,please let me know if i had mistaken.

 

 

Thanks and regards,

srikrishnaNF

Regards,
Srikrishna


Message 6 of 13
(5,611 Views)

Your graph was showing the threshold cross only once for one set of data. So the last indice of threshold peak detector.vi is your below crossing point right?

 

If your one span of data goes multiple times above 150 (threshold limit) after it has fallen below, lets say in your previous attachment of graph.jpg, T is between 20-22.5, if the same T also occurs in between lets say 30- 32.5, then u might want to look into other solutions. (Probably masking).

0 Kudos
Message 7 of 13
(5,608 Views)

This actually turned out to be simpler than i thought..Thanks to srikrishnaNF...I started using his suggested way and found that 'Read from measurement file' doesn't need a while loop!! it reads the whole file in one shot...All I had to do is search the array of Y for value 150 twice and then multiply the indices with dt..attached is the modified version..

 

thankyou all...

 

 

Vsh, the threshold peak detector only gives -quote from help "Indices contains the beginning index of all valid peaks" So i could get the begining point where the waveform crossed the 150 value but it does not recod when the peak comes down below 150.. 

0 Kudos
Message 8 of 13
(5,577 Views)
Then can you mark srikrishna's post as the solution instead of yours?
0 Kudos
Message 9 of 13
(5,556 Views)
Solution
Accepted by topic author palkin

As David and VSH have hinted at, you can use threshold peaks.  I've done this on multiple occasions..  See the attached VI.

 

 

--
Tim Elsey
Certified LabVIEW Architect
Message 10 of 13
(5,549 Views)