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: 

Multiple instances of the same VI?

Hi all,
I had read the disscussion so far happen on this topic. I had tried out using the VIT to run the multiple instance of the same vi. I had put the VIT by dragging teh icon also but still it stops when vit called and run the main program after completion of the vit. I want to run multiple instance of the same vi at a time. Plz let me know if any one has the solution.
Some suggsted to visit SearchVIEW.net and find Kyle Gupton note on that. I also tried it out but not get any such note. Plz guide me how to solve the problem.
Here with attaching a vi with vit file.

Thanks.
Vishal
0 Kudos
Message 1 of 7
(8,537 Views)
Vishal,

The use of the VIT method (though I don't know WHY its called that, it's actually a call by prototype) is really easy, and you may be making a simple mistake.

First, the VI you are calling has to work itself. Second, the VI has to be opened by reference. Use an "Open VI Reference" function with the name of the VI wired to it.

If you are still having trouble, post your code, and we will see if we can figure out what's going wrong.
0 Kudos
Message 2 of 7
(8,537 Views)
There are two ways:
1. If you do not need the front panel for user interaction, make the VI reentrant in the execution options. Everywhere you put this VI on a diagram, a new instance is created. There is only one VI in memory but they have different data space for controls and shift registers.
2. If you need the front panel for user interaction, save the VI with the VIT extension. To create new instance of this VI, open a VI reference to the VI and invoke the Run method. LabVIEW will create uniquely named VI instance for each reference ("VIname 1.vi", "VIname 2.vi", etc). The user can interact with each of them independently.


LabVIEW, C'est LabVIEW

Message 3 of 7
(8,537 Views)
This is an excelent answer. It is organized, concise and complete.
0 Kudos
Message 4 of 7
(8,537 Views)
Thank you very much for this brilliant answer. It showed me new ways.
0 Kudos
Message 5 of 7
(8,537 Views)

How the fucntional global effects when i try to run multiple instance of same VI?

0 Kudos
Message 6 of 7
(7,189 Views)

A lots changed in LabVIEW in 13 years.  One of them is the improvement in calling reentrant and asynchronous VIs.  Here is an example I did a while ago that demonstrates some of the more scalable, and manageable ways of doing this.

 

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

 

But to answer your question directly.  A VIG in every normal situation is non reentrant.  So if you call a write in one VI, but also call write in another VI in parallel, they will share the same memory space which is generally not what you want.  There are several solutions but the best in my mind, is to create a unique reference to memory for each clone VI ran.  And the easiest way to do that is with a Data Value Reference or DVR.  You can pass in a reference to a DVR to each clone VI ran, and they can use that as their private data space.  You can also create the DVR in the clone, but I like to create it outside, and then periodically check to see if it is no longer valid, and to close my clone if that happens.  A reference will get cleaned up if the VI that made it goes idle, so this can help clean up running code if you used the Abort button during development.

0 Kudos
Message 7 of 7
(7,185 Views)