LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to synchronize while loops with different execution rate

Highlighted

I have added two while loops with different timing values (execution: one fast and one slow) as shown. I have been able to control both while loops at the same time using local variable as shown in the VI.

What i am unable to achieve is to synchronize both while loops in way that the execution rate of one doesnt effect the other.

 

Please see the attached VI

Thanks

0 Kudos
Message 1 of 6
(3,544 Views)
Highlighted

One while loop is inside the other while loop, creating a data depedency. The outer loop cannot proceed to the next iteration until everything in it, including the inner while loop has completed.

 

If the two loops should be completely independent, place them side-by-side.

 

If you just want certain things to happen at a slower rate (e.g. every 10th iteration), use a single while loop and a case structure that bypasses part of the code until [i] is an even multiple of some number.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 2 of 6
(3,537 Views)
Highlighted

as you might have noticed by running the VI that both my while loops are executed in parallel. That means there is no data dependancy since while loops are not waiting for the other to finish execution.  Is there a way that my inner while loop timer value does not effect the main while loop timer value.

Thanks for the reply
0 Kudos
Message 3 of 6
(3,529 Views)
Highlighted

 


@weeke wrote:

That means there is no data dependancy since while loops are not waiting for the other to finish execution. 


Of course there is a data dependency!

 

 

(Sorry I did not inspect your loop termination conditions in details.)

 

The inner loop only spins once and stops immediately so the outer loop can proceed. It is as if the inner loop werent even there.

 

Both of your time delays start executing in parallel with every new iteration of the outer loop, so only the longer one determines the total loop rate.

 

Please explain in simple words how you want the two loops to spin.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 4 of 6
(3,522 Views)
Highlighted

Thanks


In simple words, if i run my vi in the fornt panel, my random plot (Red Plot) is also represented in waveform chart (Red Plot) but the execution rate is way different. Since my random plot is executing 0.005 seconds based on timer delay 2 value
I would like to see this red plot in Waveform Chart and co-oping with the main Time Delay which is at slower rate (0.050).

 

Thanks

 

0 Kudos
Message 5 of 6
(3,516 Views)
Highlighted

I don't have the PID toolkit, so I cannot run your VI.

 

Both charts update once per iteration of the big loop (i.e. every 50ms). The one on the left only looks faster because the x-axis is much more zoomed in. The inner delay makes no difference.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 6 of 6
(3,506 Views)