Labview Cluster

Publisher:龙腾少年Latest update time:2015-09-18 Source: eefocusKeywords:Labview Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
cluster

A cluster is a data structure similar to an array that is used to group data. There are important differences between clusters and arrays. One important difference is that a cluster can contain different data types, while an array can only contain the same data type. For example, an array can contain 10 numeric indicators, but a cluster can contain a numeric control, a switch, and a string control.

Although the elements of clusters and arrays are stored in order, it is best to access the elements of a cluster by releasing some or all of them at the same time, rather than accessing one element at a time by index. Another difference between clusters and arrays is that clusters have a fixed size.

Clusters are often used to group related data elements that appear on a block diagram. Because clusters are represented by a single wire on a block diagram, using clusters has a positive effect on reducing wire clutter and the number of connector terminals required for subVIs. You can think of a cluster as a bundle of wires, with each wire in the cable representing a different element of the cluster. On a block diagram, you can connect sub-terminals of a cluster only if the clusters have the same type, the same number of elements, and the same order of elements. When applied to clusters, polymorphism only requires that the clusters have the same order and the same number of elements.

Next, I will introduce the creation of clusters. The cluster creation box is located in the front panel under Controls → New → Arrays, Matrices and Clusters → Clusters, as shown in the figure:

[Reprint] Labview Cluster

Then you can add various types of controls to the cluster frame. For example, now you want to create a student record, including the student's name, student number, gender and age. This requires placing two string input controls, a numeric control and a Boolean control in the cluster shell in sequence. As shown in the figure:

[Reprint] Labview Cluster

Similar to the creation of arrays, clusters can also be created from the flowchart. First, place a cluster shell on the flowchart, and then place constants of various data types in the cluster shell. As shown in the figure:

[Reprint] Labview Cluster

The size of objects within a cluster can be adjusted. Right-click the cluster border and select various adjustment operations from the pop-up shortcut menu, as shown in the figure:

[Reprint] Labview Cluster

Select Adjust to Match Size to reduce the cluster border. The following figure shows the result after adjustment:

[Reprint] Labview Cluster

The arrangement of elements in a cluster structure is based on the order in which they are placed, which has nothing to do with the position of the elements in the cluster. The first element placed in a cluster is numbered 0, the second element is numbered 1, and so on. If an element is deleted, the numbers are automatically adjusted again. The order of clusters is very important, as it directly affects the port order of the "Bundle" and "Contact Bundle" functions that will be introduced later. If you want to connect a cluster to another cluster, the order and type of the two clusters must be the same.

If you want to change the order of elements in a cluster, you can right-click the border of the cluster structure and select "Reorder Controls in Cluster" in the pop-up shortcut menu, as shown in the figure:

[Reprint] Labview Cluster

At this time, the mouse will become a handle arrow with a "#" sign, the black frame indicates the newly set arrangement number, and the white frame indicates the original arrangement number. You can change the "Click to Set" content on the title bar, and then click the cluster element to set a new number. After setting, click the " [Reprint] Labview Cluster" button on the toolbar to confirm the change. If you want to restore the original setting value, click " [Reprint] Labview Cluster" to cancel the setting.

b) Cluster functions

The template of the cluster function is as follows:

[Reprint] Labview Cluster

The most important cluster functions are the "bundle" function that constructs a packed cluster, and the "unbundle" function that extracts elements from a cluster. They operate according to the order of cluster members, which also shows the importance of the order of members within the cluster.

Cluster function examples:

  1. Create a cluster, unpack the cluster, and pack the cluster again

    The purpose of this example is to learn to use two basic functions of clusters, as shown in the figure: First, place a cluster shell on the front panel and change the label content to "Input Cluster"

    [Reprint] Labview Cluster

    In the cluster shell, put the string control "Name", the Boolean control "Sex", the numeric input control "Pay" and the string control "Address" in turn, and use these cluster elements to form the salary record of an employee in a company. As shown in the figure:

    [Reprint] Labview Cluster

    Switch to the flowchart and place an "Unbundle" cluster unpacking function. When the function is first placed, it has only two output ports on the right. When the input port is connected to the "Input Cluster" terminal, the right port will automatically increase to the number of cluster elements. The order of the ports from top to bottom corresponds to the order of placement of the elements in the cluster, and the data type also corresponds to the data type of the cluster element. As shown in the figure:

    [Reprint] Labview Cluster

    Similarly, place a "bundle" packed cluster function, use the positioning tool to increase the number of input ports to 4, and connect them to the 4 unpacked cluster elements in turn, indicating that they are packed again to generate a new cluster. Create a cluster display at the output port and change the label to "Output Cluster", as shown in the figure:

    [Reprint] Labview Cluster

  2. Replacing a Cluster Member

    The purpose of this example is to learn how to use the Bundle by Name [Reprint] Labview Clusterfunction to replace certain elements within a cluster.

    1. Create a new VI, create a cluster shell on the front panel, and add a numeric input control, a Boolean control, and a string input control to the cluster, as shown in the figure:

      [Reprint] Labview Cluster

    2. Open the flowchart and select the "Bundle by Name" function. Its function is to replace the value of the cluster member by name. When the function is first placed, it has only one input port on the left. After connecting the "Input Cluster" port of the function to the created cluster terminal, the left port will display the name and value of the first element in the cluster. Click it with the operation tool to select other cluster members. As shown in the figure:

      [Reprint] Labview Cluster

    3. Create an input control on the front panel, change the label to "Enter a number", and connect it to the "Value" port in the flowchart to indicate that it will be used to replace the cluster element. As shown in the figure:

      [Reprint] Labview Cluster

    4. Create an output cluster after the "Bundle by Name" function. Once completed, you can run the program, as shown in the figure:

      [Reprint] Labview Cluster

  3. Plug and Play Cluster Array

    The purpose of this example is to learn how to use the Index and Bundle Cluster Array [Reprint] Labview Clusterfunction in conjunction with the Cluster Array function to create a cluster array.

    1. Create a new VI, open the block diagram, and place this function. When it is first placed, it has only one input port. Use the positioning tool to drag it to have three input ports.
    2. Place three array shells on the block diagram, then add string constants, numeric constants, and Boolean constants to create three arrays, as shown in the figure:

      [Reprint] Labview Cluster

      Then assign them the values ​​shown in the figure, as shown in the figure:

      [Reprint] Labview Cluster

      Then connect the wires and create a display control, as shown in the figure:

      [Reprint] Labview Cluster

      Run, the result is as shown below:

      [Reprint] Labview Cluster

      Description: This function takes values ​​from the three input arrays in sequence. The data with the same index value is gathered into a cluster, and all the clusters form a one-dimensional array. The length of the concatenated array is equal to the shortest one among all the input arrays, and the redundant data is discarded.

  4. Creating an array of arrays

    This example seems to be impossible to implement, because in the study of arrays, we already know that the members of an array cannot be arrays. Here we will learn to treat a one-dimensional array as a cluster, and then create an array of clusters, because each member of a cluster array is a cluster (i.e. a one-dimensional array), thus achieving the purpose of creating an "array of arrays".

    1. First, create a new VI, open the flowchart, and place a "Create Cluster Array" [Reprint] Labview Cluster function. The function of this function is to create an array of clusters. Each member of the cluster array is a cluster. When it is first placed in the flowchart, the function has only one input port. Use the positioning tool to drag its border so that it has three input ports.
    2. Create three numeric arrays on the program flowchart and assign values ​​to them respectively. Set the length of the first and third arrays to 5, and the length of the second array to 4. Create a cluster display at the output port of the "Create Cluster Array" function and change the label content of the cluster display to "Array of Arrays", as shown in the figure:

      [Reprint] Labview Cluster

    3. Run the program and you can see the results on the front panel, as shown in the figure:

      [Reprint] Labview Cluster

Error Cluster

The Error cluster is a very important cluster. Many controls have two cluster ports, "Error In" and "Error Out". Generally speaking, when an error occurs in a VI and it cannot run, you can create a display control at the "Error Out" terminal of the error control, so that the program can continue to run. As shown in the figure, this is the Error cluster:

[Reprint] Labview Cluster

The more important application of the Error cluster is that it can control the order in which controls are executed, and can also control the termination of a loop through the Error cluster. As shown in the figure:

[Reprint] Labview Cluster

When an error occurs in the signal generation, the loop can be stopped.

Keywords:Labview Reference address:Labview Cluster

Previous article:The main data storage methods of LabVIEW
Next article:Labview string and file I/O

Recommended ReadingLatest update time:2024-11-16 13:56

The whole process of implementing PCI-1714 acquisition card based on LabVIEW language
1 Overview Laboratory Virtual Instrument Engineering Platform (LabVIEW) is a graphical software specifically used for data acquisition, analysis and instrument control. The virtual instruments it develops combine the powerful data processing capabilities of computers with the hardware test control capabilities
[Test Measurement]
The whole process of implementing PCI-1714 acquisition card based on LabVIEW language
Research on Timing in LabVIEW
The two most commonly used VIs for timing in LabVIEW are Wait (ms).vi and Wait Until Next ms Multiple. This article will use actual examples to explain the difference between these two VIs. If you don't want to read the detailed discussion below, you can just read the following conclusions: If you want to imp
[Test Measurement]
Research on Timing in LabVIEW
Creating a Block Diagram in LabVIEW
  After creating the front panel, the controls in the front panel window correspond to terminals in the block diagram window. Select "Window → Show Block Diagram" (shortcut key: ) in the main menu of the front panel window, or double-click the added block diagram object to switch the front panel design interface to the
[Test Measurement]
Creating a Block Diagram in LabVIEW
Design of real-time monitoring system for photovoltaic power generation based on LabVIEW and RS485 communication
    A photovoltaic power generation monitoring system based on LabVIEW data acquisition and RS485 communication is designed, which can monitor the operating electrical parameters and environmental parameters of the photovoltaic power generation system in real time and count the power generation information. The system
[Microcontroller]
Design of real-time monitoring system for photovoltaic power generation based on LabVIEW and RS485 communication
Aircraft Jet Noise Measurements Using NI LabVIEW Software and PXI Hardware
Aircraft Jet Noise Measurements Using NI LabVIEW Software and PXI Hardware Figure 1: Near-field acoustic holography and scanning measurement system with reference microphone Challenge: Develop a portable near-field acoustic holography (NAH) system to measure high-amplitude jet noise from current
[Test Measurement]
Aircraft Jet Noise Measurements Using NI LabVIEW Software and PXI Hardware
LabView Learning Notes (3) Temperature Monitoring
Use the random number generator to generate temperature values, set the upper limit of the temperature alarm, and use the Boolean switch to switch the temperature alarm function. When the current temperature value exceeds the set upper limit, the Boolean indicator lights up. The program flowchart is as follows:    
[Test Measurement]
Analysis of the method of naming files by time in LabVIEW
    I spent a long time this morning naming the collected data files using the system time, so I am going to organize them now, both for future use and to provide a reference for colleagues who have the same problem!     The screenshot of the program is as follows:    In the figure, "Basic Path" is used to
[Test Measurement]
Analysis of the method of naming files by time in LabVIEW
Application of Virtual Instruments in Digital Control of Magnetic Bearings
1 Introduction to Virtual Instruments Virtual Instrument (VI) refers to the combination of general-purpose computers and instrument hardware through application programs. Users operate the computer through a friendly graphical interface (i.e., virtual front panel), just like operating a customized tradition
[Test Measurement]
Application of Virtual Instruments in Digital Control of Magnetic Bearings
Latest Test Measurement Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号