Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here





Modular programming refers to the idea that programs are easier to read, to write, to debug, and to maintain if they are divided into smaller subprograms. The benefits of modular programming are several. First of all, it makes our programs easier to write because individual components can be independently written and tested. Second, it makes the “main’’ part of the code easier to read since long code sections are replaced with simple functions (whose internal code is hidden in another file). This also makes our programs simpler to modify. Third, individual components can be reused in other programs. For example, suppose you write a program that accepts data from the keyboard and calculates the average, standard deviation and so on. If the part of the program that calculates the standard deviation is contained inside a separate function, you could reuse that function in another program that needed to calculate the standard deviation.

Even though the simple program structure works well for simple example, it is counter-productive for longer programs, leading to lack of clarity and slowing code maintenance and modification. Each well-defined task in a program should be placed in its own program unit. Here you will execute the tasks in program units called subroutines. The main program simply acts as an outline or driver, triggering execution of the program units that accomplish the tasks. Figure 3.1 shows the modular programming approach. This chapter describes modular programming approach in LabVIEW software.


The power of LabVIEW lies in the hierarchical nature of the VI. After you create a VI, you can use it on the block diagram of another VI. There is no limit on the number of layers in the hierarchy. Modular programming helps manage changes and debug the block diagram quickly. Modularity defines the degree to which your VI is composed of discrete components such that a change to one component has minimal impact on other components. These components are called modules or subVIs. Modularity increases the readability and reusability of your VIs. As you create VIs, you might find that you perform a certain operation frequently. Consider using subVIs or loops to perform that operation repetitively. In Figure 3.2 the block diagram contains two identical operations to convert temperature in Celsius to Fahrenheit inside and outside the loop. You can create a subVI that performs that operation and call the subVI twice. The example in Figure 3.3 calls this temperature VI as a subVI twice on its block diagram and functions the same as the previous block diagram. You also can reuse the subVI in other VIs.

A VI within another VI is called a subVI. A subVI corresponds to a subroutine in text-based programming languages. You can reuse a subVI in other VIs. If you use a VI as a subVI, the icon identifies the subVI when it is called from the block diagram of another VI. Windows Explorer also uses the icon to identify the .vi file if you enable this feature. The steps to create a subVI is, first build a VI front panel and block diagram, next build the icon and the connector pane and then you can use the VI as a subVI.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close