LabVIEW Cluster Basics: Grouping Mixed Data Types

Clusters in LabVIEW group data elements of mixed types, similar to a bundle of wires in a telephone cable, where each wire represents a different element. Think of a cluster like a “record” or a “struct” in text-based programming languages.

Bundling several data elements into clusters helps keep your block diagram tidy by reducing wire clutter and minimizing the number of connector pane terminals needed for subVIs. Like an array, a cluster is either a control or an indicator, but importantly, it cannot contain a mix of both controls and indicators.

cluster labview fig1

Cluster Functions

On the Block Diagram, within the “Cluster, Class & Variant” subpalette, you’ll find functions for manipulating and accessing data within clusters. Let’s explore creating clusters and using some of these functions with an example.

cluster labview fig2

Unbundle/Unbundle By Name

Use the “Unbundle” functions to break a cluster down into its individual elements. The “Unbundle by Name” function lets you retrieve specific cluster elements by their name. You can resize these functions to access multiple elements at once using your mouse.

Here’s an example:

cluster labview fig3

Bundle/Bundle By Name

The “Bundle” function is used to assemble a cluster from individual elements. You can resize the function by dragging its corner with your mouse to add more elements.

Here’s how you might use it:

cluster labview fig4

Cluster Order

The order of elements within a cluster is logical and isn’t tied to their physical position in the shell. The first element you place into the cluster is element 0, the second is element 1, and so on. If you delete an element, the numbering adjusts automatically. This cluster order dictates the order in which the elements appear as terminals on the “Bundle” and “Unbundle” functions on the block diagram.

You can view and modify the cluster order by right clicking the cluster border and selecting “Reorder Controls in Cluster” from the context menu.