LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How many while loops in an application is appropriate?

Hi,

I am writing an application that is growing and now I'm about to add the 5th while loop on the root level. So far, I have loops for:

1. Receiving data
2. Transmitting data
3. Processing commands
4. Handling front panel events
5. (about to be added) background timed events

My question is this - is there any "recommended" maximum number of while loops in the base VI or is it purely up to the application? I am wondering if it matters, or if I can simply add loops as needed. Other than combining the transmit and receive data which I don't want to do due to speed, there's not much else to combine.

Any comments?

Thanks,

Jason
0 Kudos
Message 1 of 4
(2,505 Views)
If your diagram is getting too complicated, you might try running your loops in sub-VIs. We are running code here that has over 2 dozen processes running simultaneously, so I don't think that you're anywhere near the limit (I think it's only limited by memory space and processor speed). Just make sure that each of your loops has a delay in it somewhere to allow processor time for the other loops to run.

Rob
Message 2 of 4
(2,498 Views)
Isn't LabVIEW wonderful? 🙂 It is so easy to write applications that do many things seemingly at the same time in paralell.

I would not worry too much about the number of loops. Make sure that each loop is well behaved and only spins if there is really something to do. A single empty loop without any wait statement can be very taxing for the CPU and hurt responsiveness in all other loops.

As long as the UI is nicely responsive and the CPU is not pegged at 100% you're fine.
Message 3 of 4
(2,496 Views)
Just make sure to put appropriate delays within the loops so CPU cycles are not hogged. For high priority loops, use a delay of 0.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
Message 4 of 4
(2,482 Views)