03-25-2018 06:37 PM
Dear friends,
A simple question here, why the lower while loop (state machine) never run? I know the reason is because of the wire from "test" to "test3", but I don't understand the data flow here. Someone plz give me some details ?
My original thought is, the lower loop will run, but it may wait or pause at its frame "2", because it will for the data of "test", but I didn't expect the lower loop will not start at all...... Thank you. Please check the attachment vi or the picture below.
03-25-2018 07:15 PM
You created a data dependency by the connecting wire. The lower loop can only start after the upper loop has completed. Dataflow!
03-25-2018 07:26 PM
To expand on that a little bit, data won't leave a For/While loop until the loop finishes - your wire exits from the top loop, and so won't be available until the Stop button is pressed.
Likewise, a loop (or any other structure) won't start until all of the wires connecting to it are available. In your case, this means that the bottom loop can't start until both the "999" constant (available from the beginning) and the "14" constant (available after the top loop ends) are passed to it.
03-25-2018 07:39 PM
Hi, Thanks for your answer.
Have a quick following question: you said "bottom loop can't start until both the "999" constant (available from the beginning) and the "14" constant (available after the top loop ends) are passed to it.".
Why the 999? I thought only 14, The 999 will never go to bottom loop, and bottom loop doesnt need anything from upper loop, but only 14. Right?
03-25-2018 07:54 PM
03-25-2018 07:56 PM
sorry, you are right. I was talking about the upper 999.
I just want to confirm this, the bottom loop wont need the upper 999, right? In other words, the upper 999 will do nothing to bottom loop. Thank you
03-25-2018 08:42 PM
@sunson29 wrote:
sorry, you are right. I was talking about the upper 999.
I just want to confirm this, the bottom loop wont need the upper 999, right? In other words, the upper 999 will do nothing to bottom loop. Thank you
Right! Only the things that are connected to the loop. Dataflow means that all the inputs for a node or structure, like a loop, need to be available before it can start. Even if it doesn't need it straight away (or even if it doesn't use it at all!), it still has to be ready.
03-25-2018 08:50 PM
@sunson29 wrote:I just want to confirm this, the bottom loop wont need the upper 999, right? In other words, the upper 999 will do nothing to bottom loop. Thank you
Sorry, I was a little brief earlier. Was posting by phone.
You only need a single 999. Just branch the wire. If both loops need the same constant, it is a really bad idea to have multiple instances of the same value. Imagine a year from now your are expanding the program where you need a 9999 instead. It is much safer if it is sufficient to make the change only in one place.
Maybe you should explain to us what the "state machine" is actually supposed to do. Seems very convoluted and full of other problems.
03-28-2018 11:55 AM
thank you sir!
03-28-2018 11:55 AM
it' all good now. thank you!