NI Home
Cart Cart | Help
Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Tutorial and Video: Dataflow, SubVI, and Parallelism in NI LabVIEW

VERSION 1 Published

Created on: May 27, 2008 2:29 PM by NI FIRST - Last Modified:  Jun 12, 2008 9:26 AM by NI FIRST

 

 

NI LabVIEW software follows the dataflow model for running VIs. A block diagram node executes when all of its inputs are available. When a node completes execution, it supplies data to its output terminals and passes the output data to the next node in the dataflow path. The data transfers between inputs and outputs through wires. This is an important concept to understand before you develop your application. You should know how the data flows through the program so you can ensure that the proper functions are executing in the correct order.

 

This tutorial examines how to wire inputs and outputs and demonstrates the concept of data flow. It also covers subVIs and how to create them as well as discusses parallelism and how you can read data, make decisions, and write data at the same time. In addition, the tutorial explores the following topics:

 

  • Wiring Objects

  • Undoing Wires

  • Routing Wires

  • Selecting Wires

  • Correcting Broken Wires

  • SubVIs

  • Creating SubVIs from Sections of a VI

  • Creating an Icon

  • Connector Pane

  • Connector Pane: Setting Required, Recommended, and Optional Inputs and Outputs

  • Parallelism

 

 

Wiring Objects

 

 

 

The cursor point of the tool is the tip of the unwound wire spool. When you move the Wiring tool over a terminal, the terminal blinks. When you move the Wiring tool over a VI or function terminal, a tip strip also appears, listing the name of the terminal.

 

 

 

 

Use the Context Help window to determine exactly where to connect wires. When you move the cursor over a VI or function, the Context Help window lists each terminal of the VI or function.

 

Undoing Wires

To undo the last point where you set the wire, press the <Shift> key and click anywhere on the block diagram. To abort the entire wiring operation, right-click anywhere on the block diagram or press the <Esc> key.

 

Routing Wires

LabVIEW automatically finds a route for a wire as you wire it. LabVIEW routes a wire around existing objects on the block diagram, such as loops and structures. It also routes a wire to decrease the number of bends in the wire. When possible, automatically routed wires from control terminals exit the right side of the terminal, and automatically routed wires to indicator terminals enter the left side of the terminal.

 

To automatically route an existing wire, right-click the wire and select Clean Up from the shortcut menu.

 

Selecting Wires

Select wires by using the Positioning tool to single-click, double-click, or triple-click them. Single-clicking a wire selects one segment of the wire. Double-clicking a wire selects a wire branch. Triple-clicking a wire selects the entire wire.

 

Correcting Broken Wires

Wiring to the terminal might create a broken wire. You must correct the broken wire before you can run the VI.

 

A broken wire appears as a dashed black line with a red X in the middle. Broken wires occur for a variety of reasons, such as trying to wire two objects with incompatible data types. Move the Wiring tool over a broken wire to display a tip strip that describes why the wire is broken.

 

 

This information also appears in the Context Help window when you move the Wiring tool over a broken wire. Right-click the wire and select List Errors from the shortcut menu to display the Error list window.

 

Click the Help button to display more information about why the wire is broken.

 

Triple-click the wire with the Positioning tool and press the <Delete> key to remove a broken wire. You also can right-click the wire and select from shortcut menu options such as Delete Wire Branch, Create Wire Branch, Remove Loose Ends, Clean Up Wire, Change to Control, Change to Indicator, Enable Indexing at Source, and Disable Indexing at Source. These options change depending on the reason for the broken wire.

 

You can remove all broken wires by selecting Edit >> Remove Broken Wires or by pressing <Ctrl-B>.

 

Caution: Be careful when removing all broken wires. Sometimes a wire appears broken because you are not finished wiring the block diagram.

 

SubVIs

 

To place a subVI on your block diagram, display the block diagram of a new or existing VI by selecting Window >> Show Block Diagram. If necessary, display the Functions palette by selecting View >> Functions Palette. Click the Select a VI icon or text on the Functions palette.

 

 

 

Navigate to and double-click the VI you want to use as a subVI, and place it on the block diagram.

Wire the subVI terminals to other nodes on the block diagram.

 

Note: If the subVI does not have a connector pane, you cannot wire the subVI to other nodes.

 

You can double-click the subVI node to display the front panel of the subVI.

 

You also can place an open VI on the block diagram of another open VI. Use the Positioning tool to select the icon in the upper right corner of the front panel or block diagram of the VI you want to use as a subVI, and drag it to the block diagram of the other VI.

 

Tip: In Windows, drag a VI or control from the file system to a LabVIEW block diagram to create a subVI call to that VI.

 

Creating SubVIs from Sections of a VI

Convert a section of a VI into a subVI by using the Positioning tool to choose the section of the block diagram you want to reuse and by selecting Edit >> Create SubVI. An icon for the new subVI replaces the selected section of the block diagram. LabVIEW creates controls and indicators for the new subVI, automatically configures the connector pane based on the number of control and indicator terminals you selected, and wires the subVI to the existing wires.

 

Creating an Icon

Every VI displays an icon, shown as follows, in the upper right-hand corner of the front panel and block diagram windows.

 

 

 

A VI icon is a graphical representation of a VI that appears on the block diagram and the Functions palette. It can contain text, images, or a combination of both. If you use a VI as a subVI, the icon identifies the subVI on the block diagram of the VI.

 

The default icon contains the number of new VIs you have opened since launching LabVIEW. Create custom icons to replace the default icon by right-clicking the icon in the upper right-hand corner of the front panel or block diagram and selecting Edit Icon from the shortcut menu or by double-clicking the icon in the upper right-hand corner of the front panel.

 

 

 

You also can drag a graphic from anywhere in your file system and drop it in the upper right-hand corner of the front panel or block diagram. LabVIEW converts the graphic into a 32 × 32 pixel icon.

 

 

Connector Pane

To use a VI as a subVI, you need to build a connector pane, shown as follows.

 

 

The connector pane is a set of terminals that corresponds to the controls and indicators of that VI, similar to the parameter list of a function call in text-based programming languages. The connector pane defines the inputs and outputs you can wire to the VI so you can use it as a subVI. A connector pane receives data at its input terminals, passes the data to the block diagram code through the front panel controls, and receives the results at its output terminals from the front panel indicators.

 

You can define connections by assigning a front panel control or indicator to each of the connector pane terminals. To define a connector pane, right-click the icon in the upper right-hand corner of the front panel and select Show Connector from the shortcut menu to display the connector pane. The connector pane appears in place of the icon. When you view the connector pane for the first time, you see a connector pattern. You can select a different pattern by right-clicking the connector pane and selecting Patterns from the shortcut menu.

 

Each rectangle on the connector pane represents a terminal. Use the rectangles to assign inputs and outputs. The default connector pane pattern is 4 × 2 × 2 × 4. If you anticipate changes to the VI that require a new input or output, keep the default connector pane pattern to leave extra terminals unassigned.

 

Connector Pane: Setting Required, Recommended, and Optional Inputs and Outputs

You can designate which inputs and outputs are required, recommended, and optional to prevent yourself or other members of your team from forgetting to wire subVI terminals.

 

Right-click a terminal in the connector pane and select This Connection Is from the shortcut menu. A checkmark indicates the terminal setting. Select Required, Recommended, or Optional. You also can select Tools >> Options >> Front Panel and put a checkmark in the Connector pane terminals default to required checkbox. This option sets terminals on the connector pane to Required instead of Recommended. This applies to connections made using the Wiring tool and to subVIs created using Create SubVI.

 

Inputs and outputs of VIs in vi.lib are already marked as Required, Recommended, or Optional. LabVIEW sets inputs and outputs of VIs you create to Recommended by default. Set a terminal setting to Required only if the VI must have the input or output to run properly.

 

In the Context Help window, the labels of required terminals appear bold, recommended terminals appear as plain text, and optional terminals appear dimmed. The labels of optional terminals do not appear if you click the Hide Optional Terminals and Full Path button, shown as follows, in the Context Help window.

 

Parallelism

Many of the programs you will create to control your robot may need to take in data, analyze the data, make a decision, and send out data at the same time. With LabVIEW, you can have this functionality without losing any performance.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Average User Rating
(1 rating)




There are no comments on this document

More Like This

  • Retrieving data ...