LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to dynamically start an x amount of shared-clone reentrant VI's?

My situation is this. This is on a compactrio 9053 or 9056. I have made a subVI that can communicate with/control a device. Depending on the system, there can be an x amount of these devices. There could be 1, or there could be 3.

 

My plan was to have my controller read from a config ini file at startup. It would have a key in that file that states the amount of devices in the system. It would then create/start that number of subVI's and apply the appropriate ip addresses and whatnot and do its thing.

 

Does anyone have a link/direction I can head in? I have seen an article from NI on dynamically loading VIs but after reading it I'm not 100% sure it's what I need. Thanks in advance!

0 Kudos
Message 1 of 15
(1,371 Views)

Unfortunately, I am not able to figure out the path to the dynamically called VI. I'm assuming the subVI I want to call is going to be stored somewhere on the cRIO-9053's file system.

 

I did create a build specification and added my subVI to the Always Included portion.

 

Any hints on how to get the path to the subVI?

0 Kudos
Message 3 of 15
(1,334 Views)

I attached my test project to this post. I also don't see how you're supposed to access data from the subVI based on that example.

0 Kudos
Message 4 of 15
(1,330 Views)

Static VI References can help with this.  Here is an example.

 

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

 

Then you can reference the VI by name, which will be in memory, and be included in any built applications.  

Message 5 of 15
(1,323 Views)

The VI path doesn't actually have to be the path, it can just be the VI name.  If you put the VI name in there it will work fine.  You do have to make sure to include the name of any library or class that the VI is a member of, if it's in one of those.

 

Alternately, you can put down a static VI reference to the VI you want to use and then use a property node to get the "VI path" property from it and get the path from there.  It can be even more helpful, because if you right click it and enable the "strictly typed" option, you can use that same static VI reference for the input to the type specifier on the top of the Open VI reference node (the one with the connection pane constant).

0 Kudos
Message 6 of 15
(1,319 Views)

Big big thank you to you guys for the help so far. I feel like I'm about to level up big time in my abilities. It's running the subVI and I'm pulling the value.

main vi.PNG

 

But now I feel like all I've done is call the subVI in a fancy matter. How do I apply this to calling multiples of this subVI at the same time? Right now it seems I'm only calling one "instance" of the subVI.

 

I want these subVIs to run continuously so I'm using while loops.

0 Kudos
Message 7 of 15
(1,306 Views)

I just tried this out for the heck of it, and it seems to be working? But it was just a guess, I have no idea if this is right

main 2.PNG

0 Kudos
Message 8 of 15
(1,302 Views)

Well you will likely need to make it more complex than that:

 

  • Add code to do something in the event of an error
  • Add code to do something in the event the "Wait on asynchronous call" nodes time out
    • You can right click these nodes to set the timeout
  • Add code to make sure you don't call "Wait on asynchronous call" more times than you start up a VI
  • Add some addressing of some kind so you can see which device out of your X devices the data comes from

That sort of stuff.  But I think you have enough to get going.

Message 9 of 15
(1,284 Views)

I suggest you start thinking in terms of arrays.  You have an Array of VI references, and you start them with a for loop.  Set to the for loop to for the number of instances you want.  In there you might pass in a user event, or queue references to each instance (so an array of references).  Then when you want to talk to a specific instance, you can use the reference you sent into that VI.

0 Kudos
Message 10 of 15
(1,271 Views)