LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use subvi?

need help in using a subvi. I've already read the tutorial on labview but i cant understand it.

need simpler explanation and steps in how to use it

thanks for those who would advice
0 Kudos
Message 1 of 3
(2,578 Views)
The first thing to understand is that any VI can be a subVI. You create a VI and then if you put that on the diagram of another VI, the first VI is a subVI to the second.
 
Open a new, blank VI. Go to the diagram and put the add function onto the diagram (Numeric palette). Right click on both inputs and select Create>Control. Right click on the output of the function and select Create>Indicator. Go to the front panel. You should controls labeled x and y and an output labeled x+y. Go to the VI's icon in the upper right corner and select Show Connector. Click on one of the connectors on the left side and then click on one of the inputs (controls). Click on another connector on the left side and then click the other input. Click on one of the connectors on the right side and then click on the indicator. You should now have all of your controls and indicator defined as connections to this VI. Save this VI - call it adder. Open a new blank VI and go to the diagram. Go back to the Adder VI and drag it's icon to the new VI's diagram. On this diagram, as you move your mouse over the icon, you should see the names of the inputs and outputs of the now subVI pop up. On each of the inputs, right click and select Create>Control. On the output, right click and select Create>Indicator. You can now go to the front panel. Enter some values into the two different controls. Run the VI. The indicator should show the result of the addition of the two controls. It's really pretty simple. The one other thing you have to remember is that if you create a subVI with a while loop that gets terminated with front panel control, you have to make the subVIs panel visible when you run it. Otherwise, there is no way to stop it. Actually, there is but starting and stopping it without having the subVI's panel visible is an advanced technique and that lessopn should be saved for a later date.
 
If you get stuck, post your work and add some details on exactly what you're confused about.
Message 2 of 3
(2,575 Views)
Dennis,

As always, thank you for your thorough and careful explanations. We appreciate you making life easier for us and especially for our customers!

Oh, and congratulations on your 8000 posts!
Sarah K.
Search PME
National Instruments
0 Kudos
Message 3 of 3
(2,537 Views)