Using Function Blocks (Real-Time Module)

LabVIEW 2017 Real-Time Module Help

Edition Date: March 2017

Part Number: 370622R-01

»View Product Info
Download Help (Windows Only)

The LabVIEW function blocks conform to the function block programming paradigm defined in the IEC 1131-3 specification. The functionality of the LabVIEW function blocks partially overlaps with functionality provided by LabVIEW VIs and functions. Use function blocks if you want to publish parameter values with shared variables or if you want to use the IEC 1131-3 function block programming paradigm.

By default, each function block you place on the block diagram includes a set of variables corresponding to the function block input and output terminals. Therefore, you must place function blocks in a VI that is part of a LabVIEW project. You can right-click a function block on the block diagram and select Show Function Block in Project to highlight the function block item in the Project Explorer window. You also can right-click a function block item in the Project Explorer window and select Find on Diagram to highlight the function block on the block diagram.

Function Block Instance Configuration

You can configure the appearance and terminals of each function block instance in the application.

Appearance

Each function block instance on the block diagram displays two names: an instance name and a type name. The instance name appears at the top of the function block. You can click and change the instance name to distinguish between multiple instances of the same function block.

To minimize the size of a function block instance on the block diagram, use the Compact View. The Compact View of a function block instance displays abbreviated input and output terminal names. To switch to Compact View, right-click the function block instance on the block diagram and select Icon Style»Compact View. To switch back to the full-sized view, right-click the function block instance on the block diagram and select Icon Style»Full View.

Terminals

To configure input and output options for a function block instance, right-click the function block instance on the block diagram and select Properties from the shortcut menu to display the configuration page for the function block instance. You also can display the configuration page of a function block instance by double-clicking the function block instance on the block diagram.

You can use the Visible checkboxes for each terminal on the configuration page of a function block instance to show and hide function block terminals. If you hide a function block input terminal, LabVIEW automatically sets the Data Source of the terminal to the Default value of the data type. If you subsequently re-enable the Visible checkbox, the Data Source does not return to its previous value but remains the Default value until you specify a new value.

You can configure the data source of a function block terminal to use the block diagram terminal, the terminal variable, or the default value. If you select a data source other than Terminal, LabVIEW disables the block diagram terminal.

You can invert the value of a Boolean input or output terminal. Right-click a Boolean terminal on the function block instance and select Invert to toggle terminal inversion.

You can reorder function block input terminals and output terminals. However, to conform to dataflow standards, input terminals always appear on the left side of the function block and output terminals always appear on the right side of the function block. To switch the order of two terminals, right-click one of the terminals and select Select Input from the shortcut menu, then select the name of the other terminal.

Function Block Terminal Variables

By default, LabVIEW creates a single-process shared variable for each input and output terminal of each function block instance you use in the application. The function block terminal variables appear under the function block in the Project Explorer window. You can use function block terminal variables to access the inputs and outputs of a function block without block diagram wires. LabVIEW uses the Default value you specify on the function block instance configuration page as the initial value for the terminal variable.

Note  You can change the scope of a function block terminal variable to network-published. However, you cannot rename or change the data type of a function block terminal variable. You also cannot remove a function block terminal variable directly from the Project Explorer window.
Note  (Real-Time Module) Function block terminal variables have the RT FIFO enabled by default.

Avoiding Variable Overhead

Variables add overhead to the application, so you should include a function block terminal variable only if you plan to use it. To remove a function block terminal variable, select No Variable under Variable Scope on the configuration page for the function block instance. To display the configuration page for a function block instance, right-click the function block instance on the block diagram and select Properties from the shortcut menu.

Input Variables

You can use a function block input terminal variable to read the value of an input terminal from a location elsewhere in the application. LabVIEW writes the value of a function block input terminal to the corresponding variable, unless you have removed the variable by selecting No Variable under Variable scope on the function block instance configuration page.

If you select Variable as the Data source for a function block input, the function block uses the value of the variable as the input value. By default, the data source of all function block inputs is Terminal, in which case you can still use the variable to read the input value, but you cannot use the variable to write the input value of the function block.

Note  When you select a data source other than Terminal, LabVIEW disables the input terminal on the block diagram.

Output Variables

You can use a function block output terminal variable to read the value of an output terminal from a location elsewhere in the application. LabVIEW writes the value of a function block output terminal to the corresponding variable, unless you have removed the variable by selecting No Variable under Variable scope on the function block instance configuration page.

WAS THIS ARTICLE HELPFUL?

Not Helpful