2B-use of subvi
2B-use of subvi
B
USE OF SUB VI
22.07.2014
AIM
SOFTWARE USED
THEORY
The power of LabVIEW lies in the hierarchical nature of the VI. After we create a VI,
we can use it on the block diagram of another VI. There is no limit on the number of layers in
the hierarchy. Using modular programming helps us manage changes and debug the block
diagram quickly.
Every VI displays an icon in the upper right corner of the front panel and block
diagrams windows. An icon is a graphical representation of a VI. It may contain text, images
or a combination of both. If we use VI as a sub VI the icon identifies the sub VI or the block
diagram of the VI.
CREATING AN ICON
Right click in the upper right corner at the front panel or block diagram. Select edit
icon from the short cut menu to display the icon editor dialog box.
Use the tools on the left side of the icon editor dialog box to create the icon design in
the editing area.
CONNECTOR PANE
We also need to build a connector pane to use VI as sub VI. The connector pane is a
set of terminals that corresponds to control and indicator of that VI, similar to the parameter
list of function call in text based programming languages. The connector pane defines inputs
and outputs that you can wire to the VI. So we can use as a sub VI. The connector pane
receives data at input terminals and passes the data to block diagram code to the front panel
controls or receives the results at its output terminals from the front panel indicators.
PLACING SUB VI
After we built VI and creates icon and connect pane we can use the vi in another VI.
The VI use of another VI is called a sub VI. A sub VI mode corresponds to the subroutine
call VI the text based programming language.
PROCEDURE
Open a blank VI
MAIN VI
FRONT PANEL
Select controls >> numeric control
Select controls >> numeric indicator
BLOCK DIAGRAM
Right click multiplier icon >> create >> indicator.
Select >> functions >> all functions >> select a VI and select sub VI
Give output of multiplier to sub VI.
Complete wiring and save VI.
SUB VI
FRONT PANEL
The values are then compared by giving the value to the comparator.
The compared value is given to the selector which satisfies a true or false condition.
If the value is true, the function returns the value wired to true else returns to false.
This value is given to the square root block which is displays it on the numeric
indicator.
SUB VI
FRONT PANEL
BLOCK DIAGRAM
ICON EDITOR
Shows how to edit the icon of subVI
CREATING AN ICON
Right click the icon in the upper right corner of the front panel or block diagram and
select edit icon from the shortcut menu to display icon editor dialog box.
Click 16 colors or 256 colors box to select which icon we want to create.
Use the tools on the left side of the icon editor dialog box to create the icon design in
the editing area.
Right click on the icon, click connector.
Select patterns for the connector pane.
Click the input and first half of the connector pane to wire to the input.
Click the output and second half of the connector pane to wire to the output.
MAIN VI
FRONT PANEL
BLOCK DIAGRAM
DESCRIPTION
The Sub VI thus created is placed inside the main VI before the VI is run. When the
VI is run, only the positive values (greater than 0) are given as an input. Then the square root
of the given value is displayed on the numeric indicator. This condition works true for values
that are greater than 0 and does not go true if in case the given values are negative i.e., the
values are below 0.
RESULT
Thus a VI is created using sub VI.