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 execute the last active case when the case selector switches to default ?

I have attached the vi which I am working on. I want to achieve the following behaviour: Let's say for example that at a certain moment the case number 2 is active and then sometime the case selector switches to case 0. When the case selector is 0, I want practically to execute the last active case, case 2 for the example I mentioned. If case 1 is active and then the selector switches to case 0, I want to continue execute case 1 until case 2 is triggered. I hope I explained it as clear as possible. Looking forward to any help! 

0 Kudos
Message 1 of 3
(1,879 Views)

Why is it when I I go restore your front panel from the maximized state, it just disappears off the screen?

 

There is no such thing as a "last active case".

 

What you can do is keep track of the selection in a shift register.  And when you detect you have that a selector of 0, you wire in the value from the shift register to select your case rather than the 0.

0 Kudos
Message 2 of 3
(1,818 Views)

 

As a first step, do a few more tutorials. You VI is full of race conditions and unnecessary local variables. For example there is no guarantee that the two "position" local variables are only read after the terminal has been written. The correct way would be to just use a wire and eliminate the locals. why are instances of the "input voltage" local variable in all cases? Only things that actually differ between the cases belong inside. A shift register would seem more appropriate to hold the value.

 

To implement your desired logic, look into state machines and keep track of the relevant conditions to decide what should happen.

0 Kudos
Message 3 of 3
(1,817 Views)