LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Organizing While Loops

Solved!
Go to solution

Hello guys,

 

I'm working on a project that I have to use lots of While Loops since I have lots of parallel stuff going on. However I feel that it is a little disorganized since my program got too big and it's somewhat hard to find specific things.

 

Are there any main tips to organize a big program with lots of while loops? Is it bad to have many parallel loops? Is there a general way to reduce them?

 

Thanks. Best regards,

 

William Kiyoji Ariyoshi (LV8.5)

0 Kudos
Message 1 of 5
(2,442 Views)
Solution
Accepted by topic author WKAriyoshi

I would start wrapping up while loops and putting them in subVI's, that way the top level only shows a subVI, and the details of the while loop are within the subVI.  Of course you will need a communication mechanism such as queues to communicate between while loops, but since you have so many parallel while loops, you probably have that in your architecture already.

Message 2 of 5
(2,432 Views)

It's not bad at all to have a large number of while loops - if all of them are really needed. LabVIEW plays very well with multiple parallel processes. I, too recommend putting your loops in subvi's and utilize the synchronization pallet to pass data around.

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
Message 3 of 5
(2,419 Views)

Thanks for your answers. Good to know that it isn't a problem to use many while loops.

 

So I will try putting the while loops in subvi's. I don't have much practice using queues, but I will manage somehow.

0 Kudos
Message 4 of 5
(2,405 Views)

Hi,

 

You can also organize your loops by its functions. Using SubVIs, will help you with that. Here are some materials about Queues:

 

What is Queue?

Application Design Patterns: Producer/Consumer

 

If you are using the same data inside 2 loops or more, you will have some problems with your queue, because, once an element was dequeued in one loop, it will not be available in the queue in another loop. You will have to enqueue this element again or use another queue.

 

Regards,

Pedro Ivo da Cruz
Engenharia de Aplicações
0 Kudos
Message 5 of 5
(2,356 Views)