LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find rising, or falling, edge in data set

This one has to be so simple I hesitate to ask.  I must not be using the correct search terms.  I have two sets of data, previously stored in TDMS files.  They represent the signals from two laser proximity sensors.  They are a known distance apart.  They could be watching items on an assembly line (but they aren't).  At some point an object passes by the lasers.  As it does, the signal from first laser goes low for a period of time, then the signal from the second goes low.  These signals are captured for later analysis.  I need to calculate the velocity of the object.   I can do all the math (including using only one laser if the size of the object is known).  What I cannot seem to find is a simple example of an edge detector.  All I need is something to return the index of when the signal passes through a threshold value.  It would be nice to be able to reject transients of specified width.  I could figure this out, given time, but was hoping to find a 'canned' solution.  All I need is the index of the edge, I know the dt and can calculate the rest.

All of the examples I am finding operate 'real time' (not RT) using counters to measure.  I do not need this.

 

Thanks for any assistance.

 

Roy

0 Kudos
Message 1 of 6
(6,334 Views)

HI

I think first you need to convert TDMS data in waveform data, then you can use "Transition Measurement.vi"

This will help you to find Rising/falling edges on mentioned threshold

 

Hope this helps

Regards

Santosh

Message 2 of 6
(6,313 Views)

TDMS data comes out as Waveform.

 

Thanks for the suggestion.  I tried that.  However, that vi (and every other example I seem to find) needs a periodic signal.  In my case the data set contains a single pulse.  When I run the example I get an error message telling me that there are not enough edges in the signal.

 

Any other suggestions?

 

Roy

0 Kudos
Message 3 of 6
(6,292 Views)

Roy,

 

If you know that every data set has a single pulse, find the minimum and maximum values in the data set, calculate the midpoint between them.  Compare the data to the midpoint.  The edges are the two points where the data changes from < to > and > to <.  If the data is noisy near the threshold, some smoothing may be required.

 

Lynn

 

Pulse Edge Finder.png 

Message 4 of 6
(6,281 Views)

Thanks, johnsold.  While there is only a single pulse in each data set, there is the real possibility of transient spikes that will cross the threashold.  I guess I could wrap your example in a loop and reject any set where the two edges are too close together.

 

Roy

0 Kudos
Message 5 of 6
(6,270 Views)

Roy,

 

That should work.  You could also use a smoothing filter to get rid of the spikes.  If you get multiple samples during the transitions, fitting a straight line to segments about as long as the transitions and looking for large slopes can help.  The best choice will depend on the nature of the data and the noise.

 

Lynn 

0 Kudos
Message 6 of 6
(6,263 Views)