From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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
(4,024 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
(4,012 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,995 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,990 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,983 Views)
Solution
Accepted by topic author 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,980 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,967 Views)

Thanks for all the help

0 Kudos
Message 8 of 13
(3,940 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,925 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,906 Views)