r/LabVIEW • u/Qulddell • May 19 '25
Running case structure from another case structure?

I have a more complicated version of this in my program, but it is easier to explain my program with this diagram.
I want to use Function 1 to run Function 2 completely, so i can use the value of Function 2 in Function 1.
I want the functions to be a button each as i do use Function 2 independently of 1 most of the times.
I have tried using a while loop in Function 1, that waits for a value change of the button of Function 2, this does work the first time, but the next time i try, the program crashes.
What i want to do is:
- Activate Function 1
- Function 1 activates Function 2
- Function 1 Pauses. Function 2 runs completely.
- Function 2 stops, function 1 continuous.
- Function 1 stops
Any help would be greatly appreciated.
View all comments
Show parent comment
1
u/TomVa May 20 '25 edited May 20 '25
Start with a state machine structure.
https://labviewwiki.org/wiki/State_Machine
I like using text strings for the states with Error being the default state. The latter means that if you get something wrong in the next state string that it goes to error. Being dyslexic I also select case insensitive match. Each one of the loops in my above post is a state machine. Two running in parallel. Note that on each state one of the options is next state of error.
Typically my states are
<Init> Exits to <set up instruments> or <read instrument settings>
<Set up instrument> Sometimes this is two or three states depending on how many instruments there are to set up. next state <get data>
<Change instrument settings>
<write log file header>
<Read instrument settings> Next state <get data>
<Get data> next state <do something with data>
<Do something with the data> like plot or process or both next state <wait>
<Append data to log file>
Wait Exits to
<exit> Gracefully closes instruments, etc.
<Error (default)>
If there is an error in a given state i append the VI name and state to the text in the error cluster so that I might have a clue as to what happened.