LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop in a while loop

Hi all,
         I am trying to write a program with a while loop within another while loop. When I run the vi both while loops  run but then only the inner while loop seems to update, I adjust controls and they have no effect on the indicators.
 
Thanks..
0 Kudos
Message 1 of 9
(3,621 Views)
The outer while loop will not update until the inner while loop finishes, at which point the whole dance will start again
Message 2 of 9
(3,620 Views)
You need to familiarize with the concept of dataflow programming. Run your VI in "execution highligthing" mode while watching the diagram and you'll get a better feeling on how things work. 🙂
 
If both loops need to run in parallel, place them next to each other without data dependency.
 
Can you explain what you are trying to do? 🙂
Message 3 of 9
(3,616 Views)

So is it a bad idea to have one within the other if I was them to run simultaniously? Should I put the two whileloops side by side? I have attached the block diagram

Thanks

 

Message 4 of 9
(3,615 Views)


sparrowroad wrote:
So is it a bad idea to have one within the other if I was them to run simultaniously? Should I put the two whileloops side by side? I have attached the block diagram
It all depends what your program should do There are scenarios where stacked loops are appropriate. Typically, one loop is sufficient if you want to run most of the code at 500ms interval, but some parts at 2000ms interval. Just place the 2000ms parts in a case structure and activate it evey 4th iteration of the big loop, for example. 🙂
 
Please attach the real VI instead of an image. It is much easier to see what you have.
Message 5 of 9
(3,611 Views)

Hi there,

I am trying to send a boolean value from one loop to another to stop the loop also am trying to send a value form one loop to another.

Thanks.

Message 6 of 9
(3,602 Views)

Hi

If you want to send values between two loops (running in parallel), do not wire them up, instead create indicators for the values that u want to pass and use their local variable in the loop where you want to read/receive them.

Hope it helps!

Message 7 of 9
(3,544 Views)
Hi sparrow...,

do you know dctoni?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 9
(3,531 Views)


GerdW wrote:
Hi sparrow...,

do you know dctoni?




Nice answer, GerdW! Smiley Very Happy
- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 9 of 9
(3,476 Views)