LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how does cluster work?

Solved!
Go to solution

Hi all,

  I am following the help to learn how to use cluster to reduce the number of input/output but it is pretty confusing that how to tell which element is which. Does it follow the order we added to the cluster or not? I set a cluster contains 4 DBL numbers  as a input to my subvi. I name the elements of each DBL as A, B, C, D. In the main code, I create a cluster contains 4 DBL and trying to feed that cluster into the subvi. But how can I tell which number I feed in the main code is A, B, C and D?

 

For example, I create a subvi with only one cluster input. The cluster has 4 DBL numbers named A, B, C and D.

 

T2p.png

 

Now if want to feed a cluster into that subvi, I have to create a cluster and link the 4 numbers into that cluster. But if I use bundle cluster, I have to link the number in order so to fill A, B, C and D. But if that subVI was created by someone else, how can one tell the order of elements in the expected cluster?

0 Kudos
Message 1 of 7
(2,875 Views)
Solution
Accepted by topic author dragondriver

First of all, you should give the cluster elements in the subVI control the same names (A,B,C,D) as used in the calling VI and also ensure that the cluster order is the same. If you are unsure bout the cluster order, you can reorder the elements (right-click) and select the desired order. And yes, the initial cluster order is the order in which you added the elements.

Typically it is best to make the cluster a typedef and re-used it everywhere. This way changes to the typdef are propagated to all places where it is used.

 

It is often more self-documenting and cleaner to use bundle and unbundle by name. Wire a typedef diagram constant to the top of "bundle by name" to make the labels available.

0 Kudos
Message 2 of 7
(2,861 Views)

@altenbach wrote:

First of all, you should give the cluster elements in the subVI control the same names (A,B,C,D) as used in the calling VI and also ensure that the cluster order is the same. If you are unsure bout the cluster order, you can reorder the elements (right-click) and select the desired order. And yes, the initial cluster order is the order in which you added the elements.

Typically it is best to make the cluster a typedef and re-used it everywhere. This way changes to the typdef are propagated to all places where it is used.

 

It is often more self-documenting and cleaner to use bundle and unbundle by name. Wire a typedef diagram constant to the top of "bundle by name" to make the labels available.


Thanks for your quick reply. What do you mean to make the cluster a typedef?

0 Kudos
Message 3 of 7
(2,858 Views)

@dragondriver wrote:

Now if want to feed a cluster into that subvi, I have to create a cluster and link the 4 numbers into that cluster. But if I use bundle cluster, I have to link the number in order so to fill A, B, C and D. But if that subVI was created by someone else, how can one tell the order of elements in the expected cluster?


Easiest would be to place the subVI first, then right-click the cluste connector and "create constant". Now insert a "bundle by name" into the new wire and pick the desired cluster inputs.

 

Here's how it would look like for the termination cluster input of nonlinear fit.

 

0 Kudos
Message 4 of 7
(2,848 Views)

@altenbach wrote:

@dragondriver wrote:

Now if want to feed a cluster into that subvi, I have to create a cluster and link the 4 numbers into that cluster. But if I use bundle cluster, I have to link the number in order so to fill A, B, C and D. But if that subVI was created by someone else, how can one tell the order of elements in the expected cluster?


Easiest would be to place the subVI first, then right-click the cluste connector and "create constant". Now insert a "bundle by name" into the new wire and plick the desired cluster inputs.

 

Here's how it would look like for the termination cluster input of nonlinear fit.

 


Thanks. using typedef is a good idea 🙂

0 Kudos
Message 5 of 7
(2,843 Views)

dragondriver wrote:  What do you mean to make the cluster a typedef?

This will of course only work for your own subVIs, but learn about type definition here

0 Kudos
Message 6 of 7
(2,842 Views)

@dragondriver wrote:
Easiest would be to place the subVI first, then right-click the cluste connector and "create constant". Now insert a "bundle by name" into the new wire and plick the desired cluster inputs.

 

Here's how it would look like for the termination cluster input of nonlinear fit.

 


Thanks. using typedef is a good idea 🙂


the above has nothing to do with typedefs. 😉

0 Kudos
Message 7 of 7
(2,824 Views)