05-06-2021 08:01 AM
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?
Solved! Go to Solution.
05-06-2021 08:10 AM - edited 05-06-2021 08:13 AM
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)
05-06-2021 08:24 AM
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.
05-06-2021 09:13 AM
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.
05-06-2021 10:40 AM
Help -> Find examples -> State machine fundamentals should give you some good tips. 🙂
05-06-2021 03:57 PM
@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.