LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Correct Way to Pass Data from Main VI to Sub VI

Highlighted

I'm currently working on a program that consists of a main VI which passes in several inputs to numerous copies of the same subVI which are displayed in subpanels. As you may know, in order to display a subVI in a subpanel, a reference to the subVI must be passed into the "Insert VI" property node of the subpanel. However, I am unsure as to what is the proper way in which I can generate this reference from the subVI block on the block diagram of the main VI. Note that in my case, it is insufficient to simply generate a reference to the subVI by pointing to the file path of the subVI and opening an instance of it, because that instance of the subVI must also receive input from the main VI. Generating a reference in this way does not, as far as I know, allow the main VI to interface with the subVI.

 

I had thought that I developed a solution to this problem by extracting a reference to the current instance of the subVI from the "Owning VI" property node of any control or display in the subVI. This works well for about 12 hours of program execution. However, after that point, the program starts highlighting the "Insert VI" property node every time the subVI is updated. Furthermore, the main VI seems to often lose the reference to the subVI and becomes unable to start, especially after the subVI has been edited. Given these two problems, this solution clearly is not a proper solution.

 

Could anybody advise on how to properly generate a reference to an instance of a subVI that receives input from a main VI?

 

Any suggestions would be appreciated.

0 Kudos
Message 1 of 13
(2,991 Views)

Use queues to pass data between a main VI and a subPanel

0 Kudos
Message 2 of 13
(2,989 Views)

Hi

 

If the inputs to be passed from the Main VI to the subVI involve control values, like, you want to pass a value to a control on the subVI, then you can use VI reference to pass data.

 

Use the invoke node for the subVI and set the Control Value. This value will then be seen when the subVI is loaded in the subpanel.

 

Post your VI so that we can have a look at it and suggest the best option. Also we can look at the issues you are facing.

Regards
Freelance_LV
Message 3 of 13
(2,972 Views)

Call by reference Node can also be used if its a one time data transfer from the Main vi to sub vi.

 

If continuous data transfer is required then use Queues,Control references

0 Kudos
Message 4 of 13
(2,965 Views)

Thanks for the responses everyone.

 

Using invoke nodes to pass control values looks promising. I should probably be embarrassed to ask this, but could somebody tell me what those converter blocks going into the control value terminals are in Freelance LV's example?

 

Thanks.

0 Kudos
Message 5 of 13
(2,929 Views)

It convertes any data type to varient data. 



------------------------------------------------------------------------------------------------------
Kudos are (always) welcome for the good post. :-)
0 Kudos
Message 6 of 13
(2,926 Views)

Thanks, I just figured that out myself. I've managed to get one instance of the subVI to display properly in a subpanel by passing control values through invoke nodes. However, Labview complains when I want multiple instances of the same subVI to display in subframes in the main VI. Each of the instances receive inputs with different values from the main VI. Any suggestions for that?

 

Thanks.

0 Kudos
Message 7 of 13
(2,917 Views)

I should also mention that the subVI has already been configured for re-entrant execution.

0 Kudos
Message 8 of 13
(2,901 Views)

I've figured that out too - set the "Option" input on the "Open VI Reference" block to 0x8. However, now I've discovered that the inputs from the main VI are not being passed to the subVI instances as the program is running. Does passing control values via invoke nodes allow for real-time data transfer?

 

Thanks.

0 Kudos
Message 9 of 13
(2,892 Views)

@Griffon2-6 wrote:

I've figured that out too - set the "Option" input on the "Open VI Reference" block to 0x8.  


Great!

 

Thats the way to go. Keep digging around and you will find solutions in the LabVIEW Help or on the forums for most of the things.

 

When you set the open VI reference option to 0x08, you can obtain reference to different instances of the same VI, so that you can pass different data and let them run separately.

 


@Griffon2-6 wrote:

However, now I've discovered that the inputs from the main VI are not being passed to the subVI instances as the program is running. Does passing control values via invoke nodes allow for real-time data transfer?

 


I have one question. You said you are calling this sub VI in a sub panel? How many subpanels do you have and why are you calling the reentrant vi in differnet sub panels?

 

Could you post your code?

 

(If a post helped you sove the problem, mark it as solution. That will help us identify and track the solutions for different issues.)

Regards
Freelance_LV
0 Kudos
Message 10 of 13
(2,869 Views)