Creating Sub VIs in NI LabVIEW
Summary
TLDRIn this LabVIEW tutorial, the user demonstrates how to simplify and modularize code by creating sub-VIs. Starting with a basic temperature conversion program, the process of turning a section of the block diagram into a sub-VI is shown. The sub-VI can be modified to include new functionality, such as a toggle switch that allows users to enable or disable the conversion. The tutorial also covers customizing the sub-VI’s icon and linking it to the main VI. By the end, viewers learn how to use the sub-VI to efficiently manage temperature conversions with additional options.
Takeaways
- 😀 SubVIs in LabVIEW are a great way to modularize code, making it more manageable and reusable across applications.
- 😀 Creating a SubVI involves selecting a block of code, then using the 'Create SubVI' option to simplify it into a single icon.
- 😀 Once a SubVI is created, you can double-click on it to edit the internal block diagram and adjust its functionality.
- 😀 SubVIs can be modified to add new features, such as enabling or disabling parts of the code based on user input, like a toggle switch.
- 😀 The Case Structure in LabVIEW allows you to control different behaviors within a SubVI, based on boolean conditions.
- 😀 You can add input and output terminals to a SubVI's icon, enabling communication between the SubVI and the larger application.
- 😀 SubVIs can be customized with graphical icons to make them more intuitive and meaningful to the user, enhancing usability.
- 😀 The 'Show Connector' option in a SubVI's icon enables you to reveal or add terminals that connect the SubVI to the calling program.
- 😀 After modifying a SubVI, it's important to relink its icon to ensure that the updated terminals and functionality are reflected in the calling VI.
- 😀 Testing a SubVI involves using the updated functionality in a larger application, ensuring that the SubVI works as intended, including the toggle switch feature.
Q & A
What is the purpose of using a sub-VI in LabVIEW?
-A sub-VI in LabVIEW is used to simplify block diagrams, modularize code, and make it easier to reuse in other applications.
How does the program in the script convert from Fahrenheit to Celsius?
-The program uses a slider for inputting Fahrenheit values, and it displays the corresponding Celsius value on a thermometer based on the conversion formula.
What happens when you create a sub-VI from a selected section of code?
-When you create a sub-VI from a section of code, the selected code is wrapped in a single icon with one input and one output, making it more compact and reusable.
What is the role of the Boolean toggle switch in the example?
-The Boolean toggle switch allows the user to enable or disable the temperature conversion. When disabled, the Fahrenheit value is passed directly through without conversion.
How is the case structure used in the example to handle the toggle switch?
-A case structure is used around the conversion code. If the toggle switch is true, the conversion code runs; if false, the Fahrenheit value is passed directly to the output.
How do you add an additional terminal to the sub-VI in LabVIEW?
-To add an additional terminal, right-click on the sub-VI icon, select 'Show Connector', then right-click on the connector and choose 'Add Terminal'. You can then wire the new terminal to the corresponding control or indicator.
What is the purpose of customizing the sub-VI icon in LabVIEW?
-Customizing the sub-VI icon makes the sub-VI more meaningful and visually identifiable, helping users understand its purpose at a glance.
How can the sub-VI be relinked after modifying its terminals?
-After modifying the terminals, you can relink the sub-VI by right-clicking on the icon and selecting 'Relink to Sub-VI'. This ensures that the updated terminal configuration is reflected in the calling application.
What happens when you create a control for the Boolean toggle switch?
-Creating a control for the Boolean toggle switch allows it to appear on the front panel of the calling VI, enabling the user to control whether the conversion is enabled or not.
How does the toggle switch affect the output when it is turned on or off?
-When the toggle switch is turned off, the output directly passes the Fahrenheit value. When turned on, the Celsius conversion is performed, and the corresponding Celsius value is displayed.
Outlines

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowMindmap

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowKeywords

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowHighlights

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowTranscripts

This section is available to paid users only. Please upgrade to access this part.
Upgrade Now5.0 / 5 (0 votes)