LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

detect where a threshold crosses a peak

Solved!
Go to solution

I want to be able to detect the point at which a threshold crosses a peak as shown in the figure, I know that the threshold VI will give me the point A but I also want to be able to get the point B, any ideas?

image of peaks.jpg

 

0 Kudos
Message 1 of 13
(3,932 Views)

Hi cconormac,

 

so you want to compare a waveform with a fixed value?

 

Such a comparison will give you a boolean signal (aka array) and now you need to detect rising and falling edges in this boolean signal. Sounds like a good example to actually learn to code in LabVIEW…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(3,920 Views)

You could also make some Rube Goldberg code to reverse the the 1D array, find the threshold there and subtract it from the array size to figure out B if you really wanted to use the threshold function again.

 

GerdW's suggestion is infinitely better though.

Matt J | National Instruments | CLA
0 Kudos
Message 3 of 13
(3,903 Views)

You don't need to reverse the 1D array, just negate it.  Then falling becomes rising and vice versa but the indexes don't change.

 

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
0 Kudos
Message 4 of 13
(3,898 Views)

Good point, although you then would need to round the first threshold's index towards positive infinity and use that as the starting index for the threshold of the negated array.  If you didn't do that then it would always return 0 as the first element is already above the threshold.

Matt J | National Instruments | CLA
0 Kudos
Message 5 of 13
(3,891 Views)
Solution
Accepted by cconormac

I would use two arrays, the original and the negated.  Search (or threshold) the original array for the threshold value until the threshold is found then search (or thershold) the negated array for the negated fhreshold value starting from the index where the first threshold was found.  Both indexes will be correct and the values are correct except that the value of the second one will need to be negated to give the correct value.

 

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
0 Kudos
Message 6 of 13
(3,888 Views)

And here we have arrived at a solution way more complicated than it needs to be that will only solve this one particular problem but will, in fact, work.  Well done team.

Matt J | National Instruments | CLA
0 Kudos
Message 7 of 13
(3,875 Views)

Thanks for all the help

0 Kudos
Message 8 of 13
(3,848 Views)

you could use the "threshold point-by-point.vi" instead of the "threshold.vi"

 

2015-01-21_threshold-pt-by-pt.png

 

 

Regards,
Alex

0 Kudos
Message 9 of 13
(3,833 Views)

@cconormac wrote:

Thanks for all the help


Please do not do what you marked as a solution in your program.  If you do this it will only work for a continuous function that starts below the threshold, goes above it and then dips back down. This will also only return you the first and last time it crosses that threshold.

 

I would STRONGLY suggest you take GerdW or Alex's approach.  They are both much better, I wish sarcasm showed through the internet better.

 

Matt J | National Instruments | CLA
0 Kudos
Message 10 of 13
(3,814 Views)