From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding parallel loops programatically

Hi!

 

I'm building a system with some instruments and I want to use the same instrument-VI for all instruments.

 

One way is to do it set it up as 'Possible solution..' (see image).

Is there some way where I can loop through the 'hardware settings'-array and create as many as necessary? Like the 'More what I want...' (see image)?

0 Kudos
Message 1 of 9
(3,016 Views)
0 Kudos
Message 2 of 9
(3,003 Views)

Your first solution should work if you set the Run! to reentrant, in which case you'll spawn X copies.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 9
(2,990 Views)

Hmm I might have been a little confusing.

 

1. The Run!-VI is a loop that runs forever (or until the user exits it). It handles the instrument communication with that specific instrument.

 

2. I do NOT want it as 'Possible solution..'. since that means I have set up a specific number of loops and I want to be dynamic...

 

3. In the 'More what I want'- part if I do it as stated, doesn't the first iteration have to end until the next one starts?

I've never worked with 'Configure Iteration Parallelism' so I will look into that!

0 Kudos
Message 4 of 9
(2,979 Views)

Then start the VI as VI server without waiting on finish (or asynchronous call) and you can start as many as you want. 🙂

Check out the AsynchronousCallAndForget.vi example, or DataserverUsingReentrantRun on how to start VI's as free threads.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 9
(2,949 Views)

@ByDesign wrote:

 

3. In the 'More what I want'- part if I do it as stated, doesn't the first iteration have to end until the next one starts?

I've never worked with 'Configure Iteration Parallelism' so I will look into that!


If the Run! vi has no outputs wired to it's connector pane, then the For loop should start N instances independently (as long as the Run! vi is reentrant).


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 6 of 9
(2,942 Views)
Please check this link for parallelism of for loops
http://www.ni.com/white-paper/9393/en/
-When there is no dependency between iteration you can pretty much use this.
Thanks
uday
0 Kudos
Message 7 of 9
(2,869 Views)

Hello again thread!

 

So I'm back on the same problem...

 

Summary:

What I want to do is something like in the new picture 'parallel loops2.png'. Start X parallel loops that each handle the communication with a specific instrument. At the moment I have 9 instruments connected.

If I use 'Configure Iteration Parallelism' I can set the 'Number of generated parallel loop instances' to the max number (=64 for me) and then use the P terminal with the 'array size' VI to get my 9 instrumentloops running.

When reading this white paper

http://www.ni.com/white-paper/9393/en/ ('Improving Performance with Parallel For Loops')

I'm getting the feeling that the way I solved it is not the way right way. Since the P-terminal should equal the number of cores in the computer.

 

The Run! VI does not have any outputs wired to its connector pane. It is reentrant (Preallocate clones - No debugging allowed).

I havn't looked at Asyncchronous calls yet. Is that the way to go?

0 Kudos
Message 8 of 9
(2,705 Views)

I think Asynchronous calls is the easiest route, just gather up the references so you can handle the VI's when needed. (Or just send an Event refnum to them so you can easily shut them down)

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 9
(2,689 Views)