LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding tunnels

Solved!
Go to solution

I thought I understood tunnels but it turns out I don't.

Watch thise 2 small programs for elapsed time. In the first case the timer counts up to 5 and wait for 1000 sec and restart the timer. In second case the timer count up to 5 sec and don't wait but instantly restarts the timer. Why have the wait object no effect in the second case?

snip 1.pngsnip 2.png

 

 

Download All
0 Kudos
Message 1 of 7
(5,277 Views)
Solution
Accepted by JÞB

This is a question of DATA FLOW.  In your first set of code, the Wait ms cannot start until the inner loop has ended.  In the second, the Wait ms does not have to wait and runs in parallel of the inner loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 7
(5,268 Views)
Solution
Accepted by topic author Michael.Koppelgaard
The thing to remember is that there are exactly 2 rules governing dataflow:

1. Any node with all its inputs satisfied will begin executing
2. A node will only output data when it finishes executing

So what is a node? Just about anything on a block diagram. VIs, constants, loops, terminals -- they are all nodes.

So to take your example: in the top case, the Wait node gets its delay value from a constant node. But that constant is inside a while loop node so it only becomes available when the loop finishes. So the inner loop will run, then the Wait will run. In LabVIEW terminology, this is called a "data dependency" because the Wait is dependent upon the data from the loop.

In the second diagram the constant node is outside the inner loop so there is no data dependency. Consequently, the loop node and the Wait node both have all the data that they need so they both begin executing irrespective of anything else -- including where they are located relative to each other.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 7
(5,241 Views)

@mikeporter wrote:
1. Any node with all its inputs satisfied will begin executing (as soon as it actually can :D)
2. A node will only output data when it finishes executing

Important to note is that dataflow is not a problem or necessary evil of LabVIEW, but a very powerful tool to write code that does not have race conditions, but still can take advantage of all available computing resources, such a multiple CPU cores.

 

It is one of the greatest features of LabVIEW compared to conventional text programming. Text is always linear, while a block diagram directly shows parallelism without the need for any complicated sytax.

 

Message 4 of 7
(5,207 Views)

Just to be sure that I understand.

In the second case the wait object and the inner loop will execute parallel - upper sit the first one where execution is after each other

 

0 Kudos
Message 5 of 7
(5,188 Views)

Correct.

0 Kudos
Message 6 of 7
(5,179 Views)

This

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 7 of 7
(5,131 Views)