LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a simple way to generate a certain number of clones

I'm trying to make n clones of a VI. For example, I might want to plot n histograms (3 shown below)

desired cloning.PNG

I tried to use a parallel for loop but the output wasn't right

nanocyte_0-1713560080324.png

 

0 Kudos
Message 1 of 4
(434 Views)

The problem is that you are using the "point by point" histogram VI.  This accumulates data until you wire in a True to the "initialize" input.  The only way it can distinguish one data set from another is by having different copies on your block diagram.

 

If you change to the "standard" version, then you can just have one VI in a loop.  However, you will have to actively maintain your complete data set yourself in an external array instead of having it be cached inside the histogram VI.

0 Kudos
Message 2 of 4
(411 Views)

Here's an alternative I came up with some years ago.  I also found a later thread that addresses a method for parallelizing the For loop that executes the clones.  I linked directly to the "most relevant" posts, but I'd recommend going back to the top of both threads to get the context.

 

Both methods will require some extra work surrounding the calls to run the clones.  Since my alternative method relies on VI Server calls, I'd guess (but do not know) that the method Kyle97330 described would tend to be a better choice for high-performance needs.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 3 of 4
(103 Views)

My use case was that I was generating throw away analysis code so I wasn't looking so much for performance or even scalability, I was looking to save myself from having to drop a bunch of histogram VIs on the block diagram and wiring them all up. I'm thinking that maybe VI scripting might be the way. Maybe the user right clicks the "tried" structure and it gets replaced with a script-created subVI. My next thought is maybe I can adapt your VI server example to a VIM that takes in a vi reference to the reentrant VI. This VIM would replace your top left for loop where you setup all the VI references. That would make it so that the user could just focus on the bottom right logic. 

0 Kudos
Message 4 of 4
(91 Views)