LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing cluster to subVI

Solved!
Go to solution

Hi all,

 

I have tried searching everywhere for solutions, but have not been successful.

I am trying to use clusters and subVI’s for the first time and I am fairly new to labview.

Instead of wiring individual elements to a subvi, I have come to learn that it is easier to pass clusters to my subVI.  I have attached a screenshot of a simple example.

 

Suppose that I have the variables, x,y,z & a, I bundle these controls in the main VI but would like to pass them into the subVI. I know that I can create an identical input cluster in the subVI, and then wire that to the subVI pattern.  I  have two problems with this:

 

1)      If I am passing different clusters of 10 or so elements to different subVI’s, it gets annoying creating an identical cluster in each subVI

2)      If I rename one of the variables in the main VI eg. x becomes t, then wouldn’t that mess up the subVI?

I am sure that this is a basic concept, but I have not found any info.

 

Thanks in advance for your help.

0 Kudos
Message 1 of 9
(10,130 Views)

You need to look into strict typ defs. This will fix your update problem. They are easy to use and will make your life easier.

 

When you make a cluster save it as a control only make it a strict type def. Then you just add this to your sub vi and you are set. If you decide to make a change on the strict type def and save then it saves it every where you used it.

Tim
GHSP
Message 2 of 9
(10,113 Views)

Hi Dnesci,

 

"1)      If I am passing different clusters of 10 or so elements to different subVI’s, it gets annoying creating an identical cluster in each subVI

2)      If I rename one of the variables in the main VI eg. x becomes t, then wouldn’t that mess up the subVI?"

Well, and here comes the magic "type definition" and all your problems are gone...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 9
(10,109 Views)

Search LV Help for "Creating custom controls indicators type definitions"

Message 4 of 9
(10,107 Views)

To expand on that, when you make a change to a type def, you will notice the control in your sub-VI will be grayed out.  You will need to select File>>Apply changes from your .ctl file to update the control in your sub-VIs.  Type defs are very useful for this reason, get used to using them.  To add this to a fp of a VI, just drag the .ctl icon over to your fp.  You can switch back (open) your type def from any control linked to it by right clicking the control and selecting Open Type Def.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
Message 5 of 9
(10,097 Views)

Thank you so much everyone! Just a bit confused on the process if I am wrong

 

Here is what I am doing, where am I going wrong?

 

(1) I have bundled various data that I will be using, using the bundle function (as per the attached image).

(2) I right click this bundle function and go Create --> Indicator, then the second attached figure appears

(3) I right click this new indicator and go Advanced --> Customize

(4) Save it as a typedef

(5) then it asks me if I want to replace the original cluster with the new typedef (ctl file), I say yes

(6) then the indicator icon changes, but there is a red dot (picture attached).

(7) If I add another line to the bundle function the line between the indicator and the bundle function breaks

 

Download All
0 Kudos
Message 6 of 9
(10,087 Views)
Solution
Accepted by topic author Dnesci11

Hi Densci,

 

6) The Bundle function doesn't output a typedef'd datatype so the indicator will show a red coercion dot. Nothing wrong here.

7) You change the datatype. Now the bundle outputs a datatype completely different than the indicator. Change the indicator too - but only in one place (the typedef) instead of every place you use that indicator...

 

General line:

First you should design your data structures, then start the programming...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 9
(10,078 Views)

Thank you GerdW, I am truly grateful. I got it working, you have saved me soo much time.

 

Appreciate everyones input and help

0 Kudos
Message 8 of 9
(10,072 Views)

To get rid of the coercion dot, wire a constant of the typedef cluster into the input terminal at the top of the bundle function.

0 Kudos
Message 9 of 9
(10,057 Views)