LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to name elements and create cluster of named elements

I wanted to detail the steps I found, so that others could more easily follow what I found going through these discussions.  While there are numerous examples, they lack details such as function names and how to achieve the steps.  Most of them seem to cover only arrays.  I welcome corrections.  I'm not saying this is the best way; it is, however, a simple detailed description of one way to do it.

 

I wanted to create a cluster of various data types that could then be manipulated by name.  Unfortunately, simply wiring an existing cluster to a Bundle by Name.vi does not assign the existing labels of the elements to the name field of the cluster.  I don't know why.

 

1.  Create an input cluster with dummy constants of the proper data type for each element.

How do you create an input cluster?  Searching functions finds no "Input Cluster" function.

        The only way I found was to place a dummy Bundle by Name.vi , right-click at the top of the leftmost of the two rectangles and select Create, then Constant. The result looks like the attached Creating Input Cluster.PNG

         You might as well delete the Bundle by Name.vi at this point, because the changes make to the input cluster will only be reflected when it is connected to a NEW Bundle by Name.vi

         Next, for my purposes, I needed constants for DBL numeric, string, and array of strings.  I started by placing  one DBL and one string constant on the block diagram.  I copied these to create the ones I needed. Make the labels visible and type in the names corresponding the Bundle Names desired.  

         Since there is no function called "String Array constant", it is necessary to place the "Array Constant" function on the Block Diagram, then drag a string constant into the empty right hand square of the Array Constant.  It immediately changes color to show it is a string array.

          Drag each of these constants into the input cluster so that they appear in the order desired.  It is a bit of a pain because the square resizes tightly around the existing elements after each insertion.  You have to keep expanding the box at the bottom by dragging its sizing handles, so you can be sure each item is added to the bottom of the list.  When done, my input cluster looks like Completed Input Cluster.png attached.

 

2.  Place a NEW Bundle by Name.vi on the Block Diagram.  Wire the input cluster to the top of the left rectangle of the function. Drag the down sizing handle of the Bundle by Name.vi until all the elements of the cluster are visible.  You will see the names and it will look like Bundle by Name with assigned names.png attached.

 

3.  All that remains is to connect the data wires for the individual elements to the left side of each named block and wire the output cluster.  The result is shown in Complete design producing cluster of named elements.PNG attached. (Since only three attachments seem to be allowed, this last will be in a follow-up post.)

Message 1 of 10
(38,321 Views)

The final result is shown as Complete design producing cluster of named elements.PNG, which is attached.

Message 2 of 10
(38,320 Views)

Thses may be of interest to you.

 

http://forums.ni.com/t5/LabVIEW/Mini-Nugget-Create-cluster-def-using-bundle-middle-input/m-p/641508

 

http://forums.ni.com/t5/LabVIEW/Community-Nugget-5-Mar-2007/m-p/486100

 

One describes a short-cut similar to your write-up and the other one tells how to be dangerous.

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 10
(38,308 Views)

I know this is over 6 months old but...nice job!!  Exactly what I was looking for..  Maybe "bundle by name" is a misnomer.  More like "replace by name".

0 Kudos
Message 4 of 10
(37,791 Views)

I wanted to add a brief statement about EDITING cluster controls because newcomers to cluster usage (like myself).  The HELP is good on creation but says nothing about modification.  While it has been posted other places, I think a "newbie" might appreciate getting this info here.

 

To edit a cluster control, open the CTL file, then

 

Add a control by creating the control on the front panel, then save the control.

 

To remove a a control, delete the control, then save the control file.

 

(Simple enough)

 

To modify an existing control

1.  Move the control out of the cluster into a blank VI.  

2.  SAVE the cluster control file (CTL).  

3.  Modify the control in the blank VI.

4.  Drag the modified control back into the cluster control.

5.  SAVE the cluster control file (CTL)

 

NOTE WELL: don't skip step 2. 

0 Kudos
Message 5 of 10
(36,295 Views)

"because newcomers to cluster usage (like myself)" should have been "for newcombers to cluster usage".

0 Kudos
Message 6 of 10
(36,292 Views)

When creating clusters you should always work with typedefs. It makes maintaining them much easier since copies of a typedef will get updated to reflect canges to the cluster definition.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 7 of 10
(36,269 Views)

I find it interesting that the process for creating clusters of names elements hasn't been improved since you wrote this.  Unless it's been updated in very recent versions...

Your process makes perfect, logical sense and helped me greatly.  Thanks.

0 Kudos
Message 8 of 10
(15,620 Views)

@jmizener wrote:

I find it interesting that the process for creating clusters of names elements hasn't been improved since you wrote this.  Unless it's been updated in very recent versions...

Your process makes perfect, logical sense and helped me greatly.  Thanks.


Yes' it is an old post, but the described method is a bit circuitous. Several of the points can be streamlined. For example an empty cluster constant container is in the palettes, no need to create a constant on a dummy cluster function. The resizing can be turned off and there is no ("... bit of a pain ...") left. 😄

 

Often, you already have a cluster control or indicator with the correctly named elements, so all you need to do is right-click the terminal and "create constant". It is actually much easier to first create an indicator (or even typdef), because (unlike for diagram constants), the labels show by default.

0 Kudos
Message 9 of 10
(15,612 Views)

Why I didn't see the AutoSizing when I was doing this is a mystery to me. And yes, the steps you mention (such as start with an indicator) will make it easier next time.  If I could find a property that puts the label to the left instead of above, my life would be complete.  But then, I just re-formatted my cluster after turning AutoSizing off and the rest was easy. Instead of a tall, thin cluster of nameless U16s, I have a labeled column of U16s that makes sense when you look at it.

 

You learn something new every day.

 

Thanks!

0 Kudos
Message 10 of 10
(15,602 Views)