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: 

Case Structures

Solved!
Go to solution

I have developed a case structure but I want to be able to reset it to its default state instantaneously. Each structure contains a while loop so I must end the loop and then use a select comparison to decide which state to go to. That part works, however it only works if I have a stop button in every while loop. Is there a way to compine multiple stop buttons into just one on the front panel while still existing in multiple states in the block diagram?

0 Kudos
Message 1 of 6
(1,243 Views)

I'd use local variable (right click on the button in block diagram -> create -> local variable).

 

edit:

alternatively you could just have the stop button outside the case structure and wire it's output to all the while loops (i'm assuming there is a larger while loop outside the case structure)

0 Kudos
Message 2 of 6
(1,235 Views)
Solution
Accepted by topic author BrassBandit

It would help if you attached a VI.  But from what you described, you either have things backwards or more complicated than they should be.

 

I would not put while loops inside of case structures.  Since you used the term "state", I assume you have a state machine.  The best structure of a state machine is a case structure inside of a while loop.  No additional while loops inside of cases.  If you need to stay in a state, then you have your state machine to decide to go back to the same state or move onto another state.

Message 3 of 6
(1,212 Views)

Unfortunately, I cannot show the VI but I agree that it is more complicated than it should be. I will attempt rebuilding the state machine. The issue i was having with local and global variables is that it would not read the value until the loop that I wanted to stop was conplete.

0 Kudos
Message 4 of 6
(1,188 Views)

Help -> Find examples -> State machine fundamentals should give you some good tips. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 6
(1,161 Views)

@BrassBandit wrote:

Unfortunately, I cannot show the VI but I agree that it is more complicated than it should be. I will attempt rebuilding the state machine. The issue i was having with local and global variables is that it would not read the value until the loop that I wanted to stop was conplete.


I agree with RavensFan. Make your state machine the loop and just repeat the state if needed. There is no need for local or global variables.

0 Kudos
Message 6 of 6
(1,111 Views)