Create an Array control or indicator on the Front Panel by placing an array shell on the front panel as shown in below Figure (a), and dragging a data object or element, which can be a numeric, Boolean, string, path, refnum, or cluster control or indicator, into the array shell. The array shell automatically resizes to accommodate the new object. The array shell can be selected from Controls >> Modern >> Arrays, Matrix & Clusters palette. The array elements must be Controls or Indicators. You must insert an object in the array shell before you use the array on the Block diagram. Otherwise, the array terminal appears black with an empty bracket. After placing an element in the array shell, you can expand the array either horizontally or vertically to see more number of elements. Once a data type is assigned to the array shell, the block diagram takes the color and lettering (In [ ] brackets) of the data type. For example, if the data type is a numeric indicator, the color will be orange with [DBL] written inside the terminal. Arrays can be identified easily by their thicker (or double) wires. The below Figure (b) shows an array of numeric controls and the array has four elements. The below Figure (c) shows an array of numeric indicators.
The index ranges from 0 to 3. The first element in the array (9) is at index 0, the second element (7) is at index 1, the third element (3) is at index 2 and the fourth element (5) is at index 3. In an array the element selected in the index display always refers to the element shown in the upper-left corner of the element display. In below Figure, the element (9) at index 0 is not shown in the array, because index 1 is selected in the index display. If you want to see the element 9 again, the index value in the index display should be changed to 0.
You can create an array constant on the Block Diagram by combining an array with a valid constant, which can be a numeric, Boolean, string, path, refnum, or cluster constant. The element cannot be another array. Following are the steps for creating an array constant in the block diagram.
You can use an array constant to store constant data or as a basis for comparison with another array. Array constants are also useful for passing data into a subVI. The above Figure (d) shows an array of Boolean constants.
A two-dimensional array is analogous to a spreadsheet or table. A two-dimensional array stores elements in a grid. It requires a column index and a row index to locate an element, both of which are zero-based. Two-dimensional arrays are very commonly used in data acquisition applications. For example, when waveforms from several channels are read from a data acquisition (DAQ) board, the data is stored in a two-dimensional array where each column in the array corresponds to data from one channel. To create a two-dimensional array on the front panel, right-click the index display of the array and select Add Dimension from the shortcut menu. You also can use the Positioning tool to resize the index display to have one more dimension. The below Figure shows a two-dimensional array.
To create a multidimensional array on the Front Panel, right-click the index display of the array and select Add Dimension from the shortcut menu. You also can use the Positioning tool to resize the index display until you have as many dimensions as you want. To delete dimensions one at a time, right-click the index display and select Remove Dimension from the shortcut menu. You can also resize the index display to delete dimensions. Use the Positioning tool to resize the array to show more than one row or column at a time. To display a particular element on the front panel, either type the index number in the index display or use the arrows on the index display to navigate to that number. You can also use the scroll bars of an array to navigate to a particular element. Right-click the array and select Visible Items»Vertical Scrollbar or Visible Items»Horizontal Scrollbar from the shortcut menu to display scroll bars for the array as shown in below Figure .
Free Demo for Corporate & Online Trainings.