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: 

Condition reset after data goes below a certain value

I'm developing a peak detection algorithm. I was wondering is it possible to create a condition such that when one point is detected, the data must  go below a certain value before another point can be detected?

0 Kudos
Message 1 of 8
(3,377 Views)

Yes, it is possible.

 

(Keep the condition in a shift register or feedback node.)

 

Have you tried the built-in peak detector?

0 Kudos
Message 2 of 8
(3,362 Views)

I have attempted the peak detection, but it picks up a larger peak twice which I would like to stop by saying that the value has to drop below a certain point so it moves to the next peak. I have tried other methods which would also benefit from this condition.

I need to develop another form of algorithm to the built-in vi as I would like to compare different methods and their effectiveness to the built-in detector.

 

Thank you

Download All
0 Kudos
Message 3 of 8
(3,345 Views)

Can you comment on the VI you have attached, because it seems extremely convoluted. What is the purpose of showing us this? Is it your attempt at "peak detection"?

 

  • The leftmost FOR loop does not need anything orange. What's the purpose of creating an array when you never use the output?
  • Wiring an array to a Waveform attribute makes no sense unless you are using something undocumented. can you explain.
  • Your small loop with the conditional tunnel removes data from the y-array but not from the x-array. Seems lossy.
  • Your boxcar averager could be simplified dramatically (image).
  • Shouldn't your pbbypt min&max be initialize on the first iteration?
  • It seems unlikely that your (large) boolean array to number ever results in a 1. What's the logic behind that?
  • Your loop to "remove duplicates" will be inefficient for large arrays. The resulting array of amplitudes with probably have a very different size than the x-array created and the positions are unrelated to the x-values. 
  • Why are front panel and diagram maximized to the screen?
  • ...

Again, why do you show us this VI. It seems quite unrelated to the problem and looks completely broken in functionality..

 

CarBox.png

0 Kudos
Message 4 of 8
(3,336 Views)

@swilson8 wrote:

I have attempted the peak detection, but it picks up a larger peak twice which I would like to stop by saying that the value has to drop below a certain point so it moves to the next peak.


It seems to pick exactly 6 peaks. looks fine to me. 😄

 

Peaks.png

Message 5 of 8
(3,329 Views)

Sorry for the slow response and the state of the vi. I've been testing lots of things at a time so the vi is rather experimental as I was trying to see what would solve the problem.

The Boolean section was an attempt to create a condition that would mean that only values where dx/dt = 0 and d(^2)x/dt(^2) < 0 would be detected. It kept throwing out an issue where the source was Boolean and the sink was Boolean but it wouldn't accept it for the case structure, I was trying to (but failing) to overcome this.

Your peak detection does appear to give nice values, but it still uses the vi which I am unable to for the purposes of this. This is why I was trying to create this new condition where a peak is detected and then the data must drop below a value before a new peak is then detected.

 

Thank you

0 Kudos
Message 6 of 8
(3,294 Views)

Every derivative emphasizes noise and your first and second derivative criteria are not suitable for noisy and spaced data.

 

NI has worked hard developing a robust peak detector and I seriously doubt that you could do better. Unless you only have LabVIEW base, that's what should be used. What's the reason you don't?

0 Kudos
Message 7 of 8
(3,281 Views)

Well if you aren't going to use the NI built-in VIs then you should poke around the web for pre-existing solutions.  There are many available in many languages you could translate and test.  One popular one is by Eli Billauer - http://billauer.co.il/peakdet.html

 

Its quite a clever simple solution to finding peaks/valleys but I haven't tested it on real data to compare to NI VIs.  It works for your data, but probably not all data.

 

Here's a LabVIEW version of Eli's code, added to altenbach's tidy code for comparison. 

0 Kudos
Message 8 of 8
(3,266 Views)