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: 

How to stop queuing in case structure

Solved!
Go to solution

I am trying to find the peak and valley of the signal. I am able to find it but I dont want to get the zero's with the peak. I just want to get the peak and valley value. Is there any way to stop queuing the values in the case structure? As I have a multiple signals whose peak/valley is to be found I can't use the Library functions.

 

 

0 Kudos
Message 1 of 5
(2,486 Views)

Well, you have to output something, Outputting NaN would probably be better. Simply ignore the output in the calling program when NaN is received back.

 

Of course you might want to look into the existing Peak Detector PtByPt VI function. 😉

 

Compare your function to it! It seems pointless to return the same value as the input as you do (or zero). The calling program is fully aware of the current value because it just submitted it to the subVI. Outputting two booleans, one true for peak and one true for valley, seems more reasonable. Right?

 

0 Kudos
Message 2 of 5
(2,479 Views)

Hi Kanye,

 

You have no choice than passing a value in any case diagram.

But what you can do is to generate a boolean output and put it to True when you found a new valley or peak. Then, in your calling VI, you just have to process the data only when this boolean is True.

 

Would that do the trick?

Olivier L. | Certified LabVIEW Developer


0 Kudos
Message 3 of 5
(2,473 Views)
Solution
Accepted by topic author kanye

 


@kanye wrote:

I am trying to find the peak and valley of the signal. I am able to find it but I dont want to get the zero's with the peak.


 

First of all and in addition to what has been mentioned, there are some serious flaws, making the subVI not very universal.

 

 

  • Your subVI does NOT output the correct peak (or valley) value, but the value right after it (which is no longer a peak or a valley!)
  • Your subVI only finds positive peaks and negative valleys. This seems very restrictive. In general, you could easily have a valley even if all data is positive. Right? (Except for e.g. Death Valley, most valleys are above sea level, for example :D)
  • Your code is extremely complicated With two sets of case structures, each stacked three deep, four shift registers and tons of comparisons. Here's a simpler version. (To mimic your outputs, place a select after each comparison and output either the value or zero depending on the result of the comparison).
(You also might want to make it re-entrant so you can use it multiple times without interference.)
Download All
Message 4 of 5
(2,463 Views)

Hi altenbach,

 

Thanks for pointing out that the valley can also be positve. I didn't thought about that. I have made the VI re-entrant. I am planning to use this VI for over 100 channels to find peak/valley and log data with time stamp for each peak/valley.

 

 

0 Kudos
Message 5 of 5
(2,436 Views)