Sei sulla pagina 1di 4

Descrizione

This exercise will walk you through creating subVIs and modularity. It will show
you how to create the icon and connector panes for the subVI.

Goal

Create the icon and connector pane for a VI so that you can use the VI as a
subVI.

Scenario

You have created a VI that determines a warning string based on the inputs
given. Create an icon and a connector pane so that you can use this VI as a
subVI.

Design

The subVI contains the following inputs and outputs:


Inputs Outputs
Current Temp Warning Text
Max Temp Warning?
Min Temp -

Use the standard connector pane to assure room for future expansion. Add
error clusters to the VI so that the code runs if there is no error, but does not
run if there is an error.

Implementation

1. Open the Determine Warnings VI located at the bottom of this page.


2. Add an error input cluster and an error output cluster to the VI.
❑ Add an Error In 3D.ctl to the front panel.
❑ Add an Error Out 3D.ctl to the front panel.
3. Select a connector pane pattern for the VI.
❑ Right-click the icon in the upper-right corner of the window and select
Show Connector from the shortcut menu.
❑ Right-click the connector pane in the upper-right corner of the window,
select Patterns,
❑ from the shortcut menu, and choose the pattern shown at left.
4. Connect the inputs and outputs to the connector as shown in the following
figure.

❑ Using the wiring tool, click the upper-left terminal of the connector pane.
❑ Click the corresponding front panel control, Current Temp. Notice that the
connector pane terminal fills in with a color to match the data type of the
control connected to it.
❑ Click the next terminal in the connector pane.
❑ Click the corresponding front panel control, Max Temp.
❑ Continue wiring the connector pane until all controls and indicators are
wired, and the Context Help window matches that shown in the previous
figure.
5. Create an icon.
❑ Right-click the connector pane and select Edit Icon. The Icon Editor window
opens.
❑ Use the tools in the Icon Editor window to create an icon. Make the icon as
simple or as complex as you want, however, it should be representative of
the function of the VI. The figure below shows a simple example of an icon for
this VI.

❑ Click OK when you are finished to close the Icon Editor window.
Tip: Double-click the selection tool to select the existing graphic. Press the
<Delete> key to delete the graphic. Then, double-click the rectangle tool to
automatically create a border for the icon.
Tip: Double-click the text tool to modify fonts. You can select Small Fonts to
choose fonts smaller than 9 points in size.
6. Right-click the connector pane and select Show Icon from the shortcut menu
to return to Icon view.
7. Save the VI.
8. Switch to the block diagram.
9. Set the VI to execute if no error occurs, and not execute if an error occurs.
❑ Surround the block diagram code with a Case structure as shown in the
figure below. Leave the Warning Text and Warning? indictors outside of the
Case structure.
❑ Wire the error in control to the case selector terminal.
❑ Confirm that the block diagram is in the No Error case. If it is not, switch to
the case containing the code, right-click the Case structure and select Make
this Case No Error from the shortcut menu.
❑ Wire the error cluster through the Case structure to the error out indicator
as shown in the above figure.
❑ Switch to the Error case.
❑ Wire the error cluster through the case to the error out tunnel.
❑ Right-click the Warning? tunnel and select Create»Constant from the
shortcut menu.
❑ Use the Operating tool to change the constant to True.
❑ Right-click the Warning Text tunnel and select Create»Constant from the
shortcut menu.
❑ Enter Error in the constant.
❑ Confirm that you have completed the Error case as shown in the figure
below.

If an error enters the VI, the VI outputs Error in Warning Text, and True in
Warning? and passes the error out of the VI. If an error does not enter the VI,
the VI operates as originally designed.

10. Save and close the VI.

Test

Use a blank VI to test the subVI.


1. Open a blank VI.
2. Open the block diagram.
3. Place the Determine Warnings subVI on the block diagram of the blank VI by
selecting the Select a VI option on the Functions palette and navigating to
where you saved the previous VI.
4. Create controls and indicators for each item in the subVI.
❑ Right-click the Current Temp input and select Create»Control from the
shortcut menu.
❑ Right-click the Max Temp input and select Create»Control from the
shortcut menu.
❑ Right-click the Min Temp input and select Create»Control from the shortcut
menu.
❑ Right-click the Warning Text output and select Create»Indicator from the
shortcut menu.
❑ Right-click the Warning? output and select Create»Indicator from the
shortcut menu.
5. Switch to the front panel.
6. Enter test values in Current Temp, Max Temp, and Min Temp.
7. Run the VI.
8. After you have finished testing, close the test VI. You do not need to save
the test VI.
End of Exercise

Potrebbero piacerti anche