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
(326 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
(318 Views)
Solution
Accepted by 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
(295 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
(271 Views)

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

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 6
(244 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
(194 Views)