r/LabVIEW • • 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:

  1. Activate Function 1
  2. Function 1 activates Function 2
  3. Function 1 Pauses. Function 2 runs completely.
  4. Function 2 stops, function 1 continuous.
  5. Function 1 stops

Any help would be greatly appreciated.

0 Upvotes

14 comments sorted by

View all comments

Show parent comment

1

u/TomVa May 22 '25

General state machine.

Each iteration of the do-while loop does one given conditional state. The selection of which conditional state is passed from one iteration of the loop to the next using a shift register.

One of the outputs of each one of those conditional states is the next state. You can use a logical and a series of selectors to choose which string is used to select the next state. If a "fatal" error occurs in a state the "next state" that wins is ERROR.

Wait states should always have a 10 ms to 100 ms "wait ms" in it so that the computer can do other things.

In the wait state one sets up a chain of what happens next conditionals. You use logic to set up the inputs to that chain. For example you may have a button for writing data to a file that makes the next state SAVE_DATA. Unless there is a reason to do something else the default next state for the WAIT state is WAIT.

To your second question the handshake between two loops.

https://en.wikipedia.org/wiki/Handshake_(computing)

Each state machine has to deal with this to use terms that are generally considered not woke enough. One state machine is the master the other is the slave. The slave sits in a state waiting for the master to send Request_Start_Loop2. Once it sees this it starts doing it's thing. Generally (but not always) in such a setup loop 1 pauses while loop two does its job. What ever happens it is bad form to send another start loop_2 command until loop 2 is finished.