LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How and when to use arrays and clusters

I am still learning the basics of LabView and I was wondering how and when you would use Arrays and clusters.
0 Kudos
Message 1 of 6
(3,170 Views)

There is no easy all encompassing answer to your question. Clusters are used when you need or want to pass a number of values of different types (char, int, real, etc.) together, possibly to form an association between them, sometimes just for the convenience (a cluster only needs one terminal on a connector pane). Arrays can be thought of similarly, grouping a variable number of values together, but they must all be the same type (char OR int OR real, etc.). Arrays frequently occur "naturally", for example the output of a data acquisition frequently is an array of numbers, representing the individual or multiple readings from a single or multiple channels.  This doesn't really begin to describe when, where and why you would use these constructs, that will be something you will discover as you develop your LabVIEW programs.  Keep asking questions, none of us was born knowing LabVIEW (with the exception of a few contributors here that seem to have!)

 

P.M.

 

 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 6
(3,164 Views)

Arrays are a set of elements defined by element type and number of dimensions. (e.g. a 2D boolean array or a 1D array of DBLs or a 3D array of a cluster).

Clusters are a collection of obects that can be of different type. You could e.g. have a cluster containing a string, a boolean, and an array of numbers. Clusters are fixed, you cannot add or remove elements at runtime.

Typically, clusters are used to simplify wiring by keeping related objects together.

You would use arrays e.g. for your measurment data. You can directly operate on them, e.g.  add a constant, multiply with another array or take the fourier transform to calculate a new array. And so on ....

0 Kudos
Message 3 of 6
(3,163 Views)
Thank you.
0 Kudos
Message 4 of 6
(3,146 Views)
Thank you.
0 Kudos
Message 5 of 6
(3,145 Views)
If you are familiar with c programming you can view a cluster as a "Struct", an advanced data type comprising a collection of other defined data types.  Structures are nice because it allows you to pass a collection of data in one neat package.  One thing when using a cluster as a struct for passing data among many vi is to define the struct as a typedef (right click>> advanced  >> customize)  this will keep a master copy of the structure and share/update it throughout a project.  To set a member of the cluster, use bundle by name, and to get data out of a cluster unbundle it.  One caution is that clusters and bundle/unbundle do cause some overhead so keep your clusters simple and as flat as possible (I tend to abuse clusters but it makes programs much more maintainable).  Arrays are used when passing data of the same type just like in c but arrays are much more dynamic and can change size and type if needed.  Hope this helps, using structures really allow for programs to be organized better but do add some overhead, arrays are used as storage for a set of same-type data.
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 6 of 6
(3,139 Views)