LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Making the program inside case structure run only once

Solved!
Go to solution

Hello

So i need to create a program where if a condition were true, then the program inside the case structure run but only once, and won't run again until the condition were false and true again.

For example the condition is x>20, and the program inside the case structure is y=y+1, when the x value are set to be 23, the y value is now 1, and it wont increase eventhough x value are still 23 or change to any number greater than 20, but when it is drop to 15, and up again to 34, the y value is now 2.

I dont know how to make the program inside the case structure run only once, so any help is appreciated.

0 Kudos
Message 1 of 3
(1,991 Views)
Solution
Accepted by topic author stefanusadrian

Lookup the Boolean Crossing PtByPt.vi.  It is buried in the Signal Processing->Point By Point->Other Functions PtByPt palette.  That VI detects when a Boolean value has changed.  You can set it up to only output a TRUE when the input changes from a FALSE to a TRUE.  So just put this in line with your current case structure logic so that the case structure only runs when the logic changes from FALSE to TRUE.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 3
(1,981 Views)
Solution
Accepted by topic author stefanusadrian

Use shift registers or feedback nodes to remember the last comparison result. Perform code only if the current comparison is True and the last comparison is False.

Case One Execute.png

Feel free. Contact me for anything more,
    Pang

You too can be LabVIEW Awesome!
Message 3 of 3
(1,969 Views)