LabVIEW is termed as Laboratory Virtual Instrument Engineering Workbench. It is a visual/graphical programming language used by engineers, scientists and professionals to build the systems faster. It is developed by National Instruments to verify instruments. However, scope of LabVIEW has spread well across system design and operations as well. To use LabVIEW, you need license, although trial and student packages are there for free use.
Applications built using LabVIEW are also known as VI (Virtual Instrument). These application files have *.vi as their extension. LabVIEW provides in-built development, test and run environment for applications to be developed, tested and run. LabVIEW’s graphical data flow language is sometimes referred as “G” as well. In LabVIEW, applications are developed using icons instead of lines of codes. Here, dataflow will determine execution sequence of VIs and functions. LabVIEW acquires, analyze, stores, displays and troubleshoots the data as and when required.
Modular programming is a process of dividing a program or a module into separate and small sub-modules. Here a sub-module is a independent software code or function which can be used and integrated within various other applications with other different system components. Due to this, a module can be re-used wherever required.
Let us explore few examples to understand the need of modular programming approach.
[Related Article:-Labview Structure ]
While implementing module approach in your applications, you should consider below points to have a perfect architecture for your application.
Almost all the programming languages prefer modular approach while using it. Do you want to know why? Below are the advantages of using it.
LabVIEW implements modular approach in programs by using subVI.
A VI is a LabVIEW program. A VI which is used in another VI is called subVI. A subVI is nothing but the reusable code. The subVI will be inserted into the block diagram of another VI. For feeding data to subVI, icon for subVI uses terminals for their corresponding inputs and outputs. Block diagram and front panel of subVI can be accessed by double-clicking on the subVI icon.
[Related Article:- LabView Basics]
Let us see how can create and use subVI in another VI. Below are some mandatory things to check while working with subVI.
Below is the sample diagram which depicts how subVI is a life savior for LabVIEW. We can simplify different sections into a subVI and use it instead of mentioning all the sections in the single VI.
We can choose sections of the block diagram which we want to convert and then click on Edit????Create subVI from Tools menu. The selected section of diagrams will be replaced with subVI icon. LabVIEW itself generates indicators and controls for subVI. It automatically configures the connector pane based on the number of control and indicator terminals you selected and wires the SubVI to the existing wires.
To differentiate subVI from other icons, it is advisable to change the icon for subVI. We can change the icon for subVI with whatever custom icon we want to use. For example, subVI icon is changed to below customized icon.
For reusing the subVI, you need to save this subVI. To add this subVI in another VI, right click on the block diagram of VI and click “Select a VI”. Browse to the folder where you have saved the subVI file and select the same. It will add subVI into your VI’s block diagram. Configure the way you want to use it.
Below are some generic steps to create subVI and use it in another VI.
LabVIEW is an interactive, easy-to-use graphical programming language which is ideal for engineers and scientists. Whether you are a professional or a student, LabVIEW programming is valuable and must to have skill with many benefits. Applying modular programming in LabVIEW makes programming very easy and fast for beginners.
Free Demo for Corporate & Online Trainings.