Overview
This exercise will go over dataflow within a VI. You will then go over debugging techniques and lastly how to turn your program into a subVI that you can use in alternate programs.
Goal
Understand the basic behavior of data flow and debugging in the LabVIEW environment. Modular programming using SubVIs is also explored.
Description
This exercise consists of a series of tasks in which will walk you through how data is passed from one element to another in the LabVIEW environment as well as how to debug using highlighted execution. Users will also learn how to create a SubVI for modular programming.
Data Flow, Debugging, and SubVIs
1. Launch LabVIEW and open a blank VI.
❑ Select File»New VI
2. Open the front panel.
3. Place a numeric control on the front panel.
❑ Select and place Modern»Numeric»Numeric Control on the front panel.
❑ Double click the number box of the numeric control and give it a value of 5.
❑ Right click the numeric control and navigate to Data Operation»Make Current Value Default.
4. Place a numeric control on the front panel.
❑ Select and place Modern»Numeric»Numeric Control on the front panel underneath the Numeric control.
❑ Double click the number box of the numeric control and give it a value of 10.
❑ Right click the numeric control and navigate to Data Operation»Make Current Value Default.
5. Place a numeric control on the front panel.
❑ Select and place Modern»Numeric»Numeric Control on the front panel underneath the Numer 2 control.
❑ Double click the number box of the numeric control and give it a value of 8.
❑ Right click the numeric control and navigate to Data Operation»Make Current Value Default.
6. Place a numeric indicator to the right of the numeric controls and name it “Result”.
❑ Select and place Modern»Numeric»Numeric Indicator on the front panel to the right of the numeric controls.
❑ Right click the numeric control and navigate to Data Operation»Make Current Value Default.

6. Switch to the block diagram.
❑ Select Window»Show Block Diagram.
7. Place an “Add” function
❑ Select and place Programming»Numeric»Add from the functions palette on the Block Diagram.
8. Place an “Add” function
❑ Select and place Programming»Numeric»Subtract from the functions palette on the Block Diagram.
9. Wire the block diagram as seen below.
❑ Wire the output of the Numeric control to the first input of the Add function.
❑ Wire the output of the Numeric 2 control to the second input of the Add function.
❑ Wire the output of the Add function to the first input of the Subtract function.
❑ Wire the output of the Numeric 3 control to the second input of the Subtract function.
❑ Wire the output of the Subtract function to the input of the Result indicator

10. Enable Highlight Execution by clicking the light bulb in the block diagram’s tool bar.

11. Run the VI by clicking the Run button on the block diagram.
12. Observe how the program executes and the sequential steps taken during the execution. Take note how intermediary values are also shown.
13. Save the VI as "add_subtract.vi".
14. Open the front panel.
15. Create a custom icon.
❑ Double click the VI icon in the upper right corner to open the icon editor.
![]()
❑ In the icon editor that opens, use the paint tools to create your own icon or the one below.

❑ When done click OK.
15. Configure the connector pane.
❑ Right click the VI icon in the upper right corner and select Show Connector.

❑ Click the upper left terminal of the connector pane.
❑ Click on the Numeric control on the front panel. This links the terminal with this control.
❑ Click the next terminal of the connector pane.

❑ Click on the Numeric 2 control on the front panel. This links the terminal with this control.
❑ Click the next terminal of the connector pane.

❑ Click on the Numeric 3 control on the front panel. This links the terminal with this control.
❑ Click the terminal in the upper right of the connector pane.

❑ Click on the Result indicator on the front panel. This links the terminal with this indicator.
15. Save the VI.
16. Create a blank VI.
❑ Select File»New VI.
17. Switch to the block diagram.
❑ Select Window»Show Block Diagram.
18. Add the previously created add_subtract.vi VI to the block diagram.
❑ From the functions palette navigate to and select Select a VI...

❑ Navigate to where you saved add_subtract.vi. Select this VI and press OK.

❑ Place the VI on the front panel. Notice how the inputs and outputs correspond to those defined in the previous section.

19. Create constants for the input of the add_subtract VI.
❑ Right click the Numeric input of the add_subtract VI and select Create»Constant. Give this constant a value of 10.
❑ Right click the Numeric 2 input of the add_subtract VI and select Create»Constant. Give this constant a value of 20.
❑ Right click the Numeric 3 input of the add_subtract VI and select Create»Constant. Give this constant a value of 30.

20. Create an indicator for the output of the add_subtract VI.
❑ Right click the Result output of the add_subtract VI and select Create»Indicator.

21. Switch to the front panel.
❑ Select Window»Show Front Panel.
22. Run the VI. Observe how the add_subtract VI behaves just as the VI that was created earlier in this exercise.
23. Close both VIs. Save if desired.
End of Exercise
Passing Data and Debugging Modules Home FIRST Community
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
