Virtual Instrumentation Systems Lab Record
Exp No:5
Date:19-02-2015
Programming Exercises for Arrays and Clusters
Aim:
To understand the principles of Virtual Instrumentation Programming and learn the basics of
arrays and clusters.
1) Multiplication of two matrices.
2) Cluster comparision blinking the LEDs if the clusters are same.
Tools Required:
National Instruments LabVIEW.
1)Multiplication of two matrices
Array:
An array, which consists of elements and dimensions, is either a control or an indicator it
cannot contain a mixture of controls and indicators. Elements are the data or values contained in
the array. A dimension is the length, height, or depth of an array. Arrays are very helpful when
you are working with a collection of similar data and when you want to store a history of
repetitive computations.
Array elements are ordered. Each element in an array has a corresponding index value, and you
can use the array index to access a specific element in that array. In NI LabVIEW software, the
array index is zero-based. This means that if a one-dimensional (1D) array contains n elements,
the index range is from 0 to n 1, where index 0 points to the first element in the array and
index n 1 points to the last element in the array.
Procedure:
Open NI LabVIEW and press <Ctrl_N> to open a blank VI.
Press <Ctrl_T> to tile front panel and block diagram windows.
Right click on block diagram panel.
Select Programming>>Array>>Build Array and drop in the Front panel.
Give the different cases to the selector.
Add three numerical indicators and give them to Build Array which appends the array and
give it to array to 1D matrix convertor by selecting array to matrix convertor.
Its becomes as a column vector.
Add an Array by Programming>>Array and give to array to 1D matrix convertor.
Provide the link to transpose matrix by right clicking on the matrix.
Multiply both the matrices by selecting multiply symbol and right click on the output side of
the multiply symbol and select create an indicator to show the output.
Save the file with extension .vi, a virtual instrument.
Give the respective inputs and check the output.
Now click Run from front panel or block diagram and observe the result
By using highlight mode run the program and check the output in front panel.
Output:
2)Cluster comparision blinking the LEDs if the clusters are same.
Clusters:
Clusters group data elements of mixed types. An example of a cluster is the LabVIEW
error cluster, which combines a Boolean value, a numeric value, and a string. A cluster is similar
to a record or a struct in text-based programming languages.
Similar to arrays, a cluster is either a control or an indicator and cannot contain a
mixture of controls and indicators. The difference between clusters and arrays is that a
particular cluster has a fixed size, where a particular array can vary in size. Also, a cluster can
contain mixed data types, but an array can contain only one data type.
Clusters are built by bundling up a collection of inputs and they are complied into a
cluster which can then be manipulated to your liking.They are perfect for organization and
complying data in a neat and uniform way that is easily represented in the front
panel.Assembles a cluster from individual elementsTo do so, wire the cluster you want to
change to the middle cluster terminal of this function. When you wire a cluster to this function,
the function resizes automatically to display inputs for each element in the cluster. Also when
you wire to the middle terminal, all other inputs are optional.Indexes a set of arrays and creates
a cluster array in which matches the value of each element to a corresponding location.
Procedure:
Open NI LabVIEW and press <Ctrl_N> to open a blank VI.
Press <Ctrl_T> to tile front panel and block diagram windows.
Right click on block diagram panel.
Select Programming>>cluster and drop in the Block diagram.
Give the different cases to the selector.
Add an numerical indicator and string indicator and a Boolean to compare and bundle the
cluster
Add another numerical indicator and string indicator and a Boolean to compare and bundle
the cluster.
Add not equal to and create an indicator for it.
Save the file with extension .vi, a virtual instrument.
Give the respective inputs and check the output.
Now click Run from front panel or block diagram and observe the result
By using highlight mode run the program and check the output in front panel.
Output:
Result:
Hence the matrices multiplication and comparision of arrays has been done successfully.