Virtual Instruments (Vis) : Back To Top
Virtual Instruments (Vis) : Back To Top
LabVIEW programs are called virtual instruments, or VIs, because their appearance and operation imitate physical instruments, such as oscilloscopes and multimeters. LabVIEW contains a comprehensive set of tools for acquiring, analyzing, displaying, and storing data as well as tools to help you troubleshoot the code you write. When you create a new VI, you see two windows: the front panel window and the block diagram.
Back to top
Front Panel
When you open a new or existing VI, the front panel window of the VI appears. The front panel window is the user interface for the VI. Figure 1 shows an example of a front panel window.
Controls Palette
The Controls palette contains the controls and indicators you use to create the front panel. You access the Controls palette from the front panel window by selecting ViewControls Palette or by right-clicking on any empty space in the front panel window. The Controls palette is broken into various categories; you can expose some or all of these categories to suit your needs. Figure 2 shows a Controls palette with all of the categories exposed and the Modern category expanded.
Figure 2. Controls Palette To view or hide categories (subpalettes), select the View button on the palette and select or deselect in the Always Visible Categories option.
Back to top
Figure 3. Numeric Control Increment/Decrement, Control, Indicator To enter or change values in a numeric control, click the increment and decrement or double-click the number, enter a new number, and press the <Enter> key.
Block Diagram
Block diagram objects include terminals, subVIs, functions, constants, structures, and wires, which transfer data among other block diagram objects.
the Add and Subtract functions complete their calculations, they produce new data values. The data values flow to the indicator terminals, where they update the front panel indicators (a+b and ab in the previous front panel).
Figure 8. Area of a Triangle Front Panel The user does not change or access the constant .5, so it does not appear on the front panel unless included as documentation of the algorithm. Figure 9 shows a possible implementation of this algorithm on a LabVIEW block diagram. This block diagram has four different terminals created by two controls, one constant, and one indicator.
Figure 9. Control, Indicator, Constant Notice that the Base (cm) and Height (cm) block diagram terminals have a different appearance from the Area (cm2) terminal. There are two distinguishing characteristics between a control and an indicator on the block diagram. The first is an arrow on the terminal that indicates the direction of data flow. The controls have arrows showing the data leaving the terminal, whereas the indicator has an arrow showing the data entering the terminal. The second
distinguishing characteristic is the border around the terminal. Controls have a thick border and indicators have a thin border. You can view terminals with or without icon view. Figure 10 shows the same block diagram without using the icon view of the terminals; however, the same distinguishing characteristics between controls and indicators exist.
Figure 10. Area of a Triangle Block Diagram Without Icon Terminal View
Back to top
Functions
Functions are the fundamental operating elements of LabVIEW. They do not have front panel windows or block diagram windows but they do have connector panes. Double-clicking a function only selects the function. A function has a pale yellow background on its icon.
SubVIs
SubVIs are VIs that you create to use inside another VI or that you access on the Functions palette. A subVI is similar to a function in a text-based programming language. Any VI has the potential to be used as a subVI. When you double-click a subVI on the block diagram, its front panel window appears. The front panel includes controls and indicators. The block diagram includes wires, icons, functions, possibly subVIs, and other LabVIEW objects.
Every VI displays an icon in the upper right corner of the front panel window and block diagram window. An example of the default icon is shown above. An icon is a graphical representation of a VI. The icon can contain both text and images. If you use a VI as a subVI, the icon identifies the subVI on the block diagram of the VI. The default icon contains a number that indicates how many new VIs you opened after launching LabVIEW.
To use a VI as a subVI, you need to build a connector pane, shown above. The connector pane is a set of terminals on the icon that corresponds to the controls and indicators of that VI, similar to the parameter list of a function call in text-based programming languages. Access the connector pane by right-clicking the icon in the upper right corner of the front panel window. You cannot access the connector pane from the icon in the block diagram window. SubVIs also can be Express VIs. Express VIs are nodes that require minimal wiring because you configure them with dialog boxes. Use Express VIs for common measurement tasks. You can save the configuration of an Express VI as a subVI. Refer to the Express VIs topic of the LabVIEW Help for more information about creating a subVI from an Express VI configuration. LabVIEW uses colored icons to distinguish between Express VIs and other VIs on the block diagram. Icons for Express VIs appear on the block diagram as icons surrounded by a blue field, whereas subVI icons have a yellow field.
Back to top
Functions Palette
The Functions palette contains the VIs, functions, and constants you use to create the block diagram. You access the Functions palette from the block diagram by selecting ViewFunctions Palette. The palette is broken into various categories; you can show and hide categories to suit your needs. Figure 11 shows a Functions palette with all of the categories exposed and the Programming category expanded.
Figure 11. Functions Palette To view or hide categories, click the View button on the palette and select or deselect the Change Visible Categories option.
Back to top
The Search button changes the palette to search mode so you can perform text-based searches to locate controls, VIs, or functions on the palettes. While a palette is in search mode, click the Return button to exit search mode and return to the palette.
The Customize button provides options for selecting a format for the current palette, showing and hiding categories for all palettes, and sorting items in the Text and Tree formats alphabetically. Select Options from the shortcut menu to display the Controls/Functions palettes page of the Options dialog box, in which you can select a format for all palettes. This button appears only if you click the thumbtack in the upper left corner of a palette to pin the palette. Until you are familiar with the location of VIs and functions, search for the function or VI using the Search button. For example, if you want to find the Random Number function, click the Search button on the Functions palette toolbar and start typing Random Number in the text box at the top of the palette. LabVIEW lists all matching items that either
start with or contain the text you typed. You can click one of the search results and drag it to the block diagram, as shown in Figure 12. Double-click the search result to highlight its location on the palette.