LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading only first value once condition is true

Hi,

 

We have written a data aqcuisiton programme to continuously acquire the pressure measured by one of our ion gauges. We are differentiating the signal in real-time and want to integrate any large peaks in the signal (ie not background fluctuations). To achieve this, we only want to turn on the integrator once the derivative of the signal exceeds a user-defined value- this has been achieved simply by using the comparison pallette and a case structure.

 

However, for use in another part of our VI, we want to extract the first point (time and pressure) for which the condition (dP/dt) > (user-defined set-point) is true. Is there a straight-forward way to do this?

 

All the (working) options we have tried so far cycle through ALL of the time/pressure values for which the condition is true. Putting a while loop inside the case structure and specifying "loop index > 0, stop if true" still reads all the values because the whole thing is enclosed in a while loop to enable the continuous data acquisition and differentiation/integration. Therefore the loop index is re-set with each iteration of the larger while loop and the condition loop index>0 is never met.

 

I suppose it would be possible to use shift registers to place all of the read values in to an array and then extract the first set of points from this array, but basically we were wondering if there is an easier way to read only the first value once a given condition is true

 

Thank you in advance,

A

0 Kudos
Message 1 of 4
(3,628 Views)

Hi Alice,

 

use the BooleanCrossing function to detect rising edges of your signal…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(3,616 Views)

This is an interesting (and slightly confusing) problem, one that can probably be solved by a Producer/Consumer architecture.

 

As I understand your situation, you want to start processing a signal once some property of the signal (in your case, its derivative, computed "in real-time" somehow, exceeds a threshold) becomes true.  In order to analyze your signal for a "Start Flag", you obviously need, say, N points of the signal.  [In the case of wanting to know about derivatives, you need to know not only the signal now, but also in the future, an interesting trick that LabVIEW can accomplish for you].  Once the Start criterion is met, you can do whatever you need with the signal (I'm uncertain what you want to do, as you talk about "Reading only first value once condition is true", which doesn't make so much sense to me).

 

You can use an N-Element Lossy Queue to create a "Memory" of the last N points (a trick to "predict the Future" is to cheat and "remember the Past").  As each new point comes in, Lossy-Enqueue it, followed by Get Queue Status with Return Elements = True.  This gives you the Last N Points, in order.  Do whatever computation ("real-time derivative") you want and determine if these points meet criteria.  If so, then these N points and future points are the "post-criteria" points you want to consider.  What I would do (and, in fact, have done) is to now play "Producer/Consumer", enqueuing first the N "immediate-past" points and then all future points (the logic is a little complex -- draw some pictures), sending to the Consumer the initial N points used to determine that "Criteria have been met" and subsequent points.

 

 

Bob Schor

0 Kudos
Message 3 of 4
(3,593 Views)

Rather than use 'Index > 0', which as you mentioned is reset each time the outer loop increments, use a boolean shift register in the outer loop, with a case that only executes if the boolean is false to strip the first item and set the boolean to true (This way the case only executes once, since the boolean is set inside it.) In the True case, do your analysis, and reset the First value if you want.

Example here.

 

LabVIEW First Value example.png

 

Hope that I understood your question, and this helps.

Jon D
Certified LabVIEW Developer.
0 Kudos
Message 4 of 4
(3,575 Views)