LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic number of parallel while loops

I have multiple sensors.  I control the sensors and read data from them via TCP/IP.  The sensors are not synchronized, meaning they send data at different times and rates.  I use parallel While Loops to read and handle the data from each sensor - one Loop for each sensor.

 

Now, the number of sensors is not fixed and I have added a "Number of Sensors" control.  Using the above logic, the number of parallel While Loops depends on the number of sensors connected.  I want to avoid multiple versions; one for each possible number of sensors.  So my question:  is there a method(s) to programmatically set a number of parallel While Loops?

0 Kudos
Message 1 of 18
(3,389 Views)

If you have a VI that does all of the processing to a single sensor, just make that VI reentrant and then dynamically call the VI as many times as you need.  No additional programming required.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 18
(3,384 Views)

What crossrulz suggests should work. 

 

The Advanced Architectures class, available online for free depending on your license, has a way to do this by launching the subVI from a template and communciating via named queues.  Each time the template is called, LV automatically assigns it a unique name and uses that name for the inter-VI messaging queue, if I remember correctly.

0 Kudos
Message 3 of 18
(3,377 Views)

@Zwired1 wrote:

What crossrulz suggests should work. 

 

The Advanced Architectures class, available online for free depending on your license, has a way to do this by launching the subVI from a template and communciating via named queues.  Each time the template is called, LV automatically assigns it a unique name and uses that name for the inter-VI messaging queue, if I remember correctly.


That shoud be considered a depreciated methodology.  The ACBR far and away out performs the vit launch and you can bury the dataspace creation in initializeation code (using pre-alocate clone pool) meaning that you no longer need to wait when you call it like you do when launching a vit.

 

Try to train yourself to only having vit's in the area you reach from File>>"New..."  There they make sense


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 18
(3,359 Views)

Jeff·Þ·Bohrer wrote:

 

Try to train yourself to only having vit's in the area you reach from File>>"New..."  There they make sense


Yup, if you are using a VIT in an application you are doing it wrong.  This is the old and busted way of doing things, now we have static VI references, nested folders in EXEs, and asyncronous calling VIs dynamically or staticly.  

 

Here is an example I made a while ago.

 

http://forums.ni.com/t5/LabVIEW/building-an-executable-with-vits-with-Labview-2011/m-p/2384984#M7404...

Message 5 of 18
(3,337 Views)

Thanks crossrulz.  I'll give it a try.

0 Kudos
Message 6 of 18
(3,292 Views)

Hi Sir,

 

I could not perform this, can you please give some example. I want to create 3 (or dynamic multiple) while loops with 1st while loop incrementing iteration at 100 ms, 2nd at at 600 ms and 3rd at 1000 ms and so on. Also one boolean control to control all these while loops sub vis.

 

I simply created one sub vi with re-entrant. The snippet of the sub vi attached. I want to create multiple dynamic while loops programmatically. Can we use for loop structure with loop iteration parallelism ? The snippet of the main vi also attached. I could not achieve and verify. Please give some hint.

Download All
0 Kudos
Message 7 of 18
(1,685 Views)

Did you get the results as expected ? Please justify with code snippet. I also need to understand.

0 Kudos
Message 8 of 18
(1,684 Views)

Your stop condition will not work since the initial value of the stop button will be passed in and the updated value will not have a chance to be passed into the subVIs.  You will need to use a Notifier or Global Variable to send the stop condition from another loop to the subVIs.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 18
(1,673 Views)

@taurus747 wrote:

 I also need to understand.


Instead if resurrecting a 7+ year old thread dealing with quite advanced (and typically unnecessary code gymnastics!), you should probably first learn the basics, such as the principles of dataflow. Try the learning resources listed at the top of the forum. You don't learn to swim by diving off a cliff into a maelstrom!

 

Once you are a bit more familiar, come back here and explain what you are trying to do, not how you are trying to do it. I am sure there are much simpler solutions.

 

 

Message 10 of 18
(1,665 Views)