LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple while loops

Hi,
I usually don't use multiple while loops in my program. Because I feel that all loops have to race themselves for execution time. But I have seen other LabVIEW programmers using it quite often. What is the pro and con ? In which case you really need to use them ?
Please advice.
Thanks
 
0 Kudos
Message 1 of 7
(4,246 Views)

parallel while loops don't "race themselves" if you place small waits in each. Often you need to do different things at different rates, so this is an easy solution.

For example:

  1. One loop containing an event structure to handle the user interface.
  2. One (timed) loop handling the data acquisition in a strictly timed fashion.
  3. One slow loop for occasional logging or report generation.
  4. etc.

One of the great powers of LabVIEW is the easy capability of (seemingly or real) parallel execution. If you have a computer with multiple CPU cores, the advantage is even more apparent.

So, use as many loops as you need. 😄

0 Kudos
Message 2 of 7
(4,241 Views)

For some easy reading about related issues, head over to Joel's blog and browse the following articles:

Asynchronous versus Synchronous Nodes

55ms ping-pong

😄

0 Kudos
Message 3 of 7
(4,238 Views)
Thank you altenbach. Great info. I feel much better now. Smiley Happy
0 Kudos
Message 4 of 7
(4,223 Views)

Hello to all.

I am doing a vi, in which I must read the value of a sensor and depending on the out it does a process or another one. In my case the sampling of the sensor is 1 seg, and the processes are of a much greater duration.
At first I have thought to use several while loops in parallel, but this method sometimes gives problems me, some loops are not executed, I suppose that because does not exist order in execution, and loops have to race.
I have read several messages of the forum and some ones recommend to use “producer/consumer”, although I believe that for my application I do not need this method, on the other hand I have read this message with the same doubt that I have.

The answer of Altenbach, says that to use multiple loops does not have any problem, but I am not sure to do it of the correct form.
I have attached a example of my multiple loop vi, would thank much if somebody tell me the best method to do several tasks at the same time using while loops.

For example:
 1. One loop containing an event structure to handle the user interface.
 2. One (timed) loop handling the data acquisition in a strictly timed fashion.
 3. One slow loop for occasional logging or report generation.
 4. etc.
 


Greetings.

0 Kudos
Message 5 of 7
(4,161 Views)
Hi Garrigos,
In parralel loops the main task is to keep each loop independant.  The use of a Global variable is the main problem.  Each loop is polling its value in order to decide whether or not to stop. Off to lunch.. I'll respond later.
Chris
0 Kudos
Message 6 of 7
(4,144 Views)
Hello!
I have a problem using multiple While loops. For my project I have to aquire Live Videos from 4 IEEE1394 Cameras.
To get the programm work I have got a total of 10 while loops running parallel. The problem is every time I try to stop the VI Labview Crashes.
Have you got any Ideas how to solve this problem?

regards

Matthias
0 Kudos
Message 7 of 7
(4,012 Views)