LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Question, why lower state_machine never runs ? Vi attached.

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.   

1.png

0 Kudos
Message 1 of 10
(3,771 Views)

You created a data dependency by the connecting wire. The lower loop can only start after the upper loop has completed. Dataflow!

Message 2 of 10
(3,764 Views)

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.


GCentral
0 Kudos
Message 3 of 10
(3,757 Views)

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?  

0 Kudos
Message 4 of 10
(3,753 Views)

Oops. You have two 999 constants. I just meant, anything that connects to the outside of the loop needs to be available, including the 999 constant wired to the shift register for that loop. Of course, it is immediately available.


GCentral
0 Kudos
Message 5 of 10
(3,750 Views)

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 

0 Kudos
Message 6 of 10
(3,748 Views)

@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.


GCentral
0 Kudos
Message 7 of 10
(3,737 Views)

@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.

0 Kudos
Message 8 of 10
(3,733 Views)

thank you sir!

0 Kudos
Message 9 of 10
(3,613 Views)

it' all good now. thank you!  

0 Kudos
Message 10 of 10
(3,612 Views)