LabVIEW: Managing Interactive SubVIs

I do a lot of LabVIEW programming. Quite a lot, in fact. Fortunately, I rather enjoy a good block diagram. Plus, the ability to work with virtual instruments (VIs) for control and data acquisition seems highly prized at RPI. Either that, or nobody else wants to do it.

When building programs with LabVIEW, I often find it convenient to group code into subVIs. This can really help clean up a messy block diagram. Occasionally I’ll employ a subVI for user interaction of some type – a sophisticated dialog box, or perhaps a sub-application of sorts. But just how is this done? By default, a when you drag a subVI onto your block diagram, its front panel won’t show when executed. To force the front panel to display when called, first right-click on your subVI, then select “SubVI Node Setup.” Then simply check the following:

SubVI Node Setup

If checked, the option to “Close afterwards if originally closed” will close your subVI once it’s finished executing, if it started closed. This is typically my preference, but there may be a time when you want your subVI to stay open after it stops.

Of course, there are a few other tricks you may wish to employ. Perhaps you’d like your application to be reset its subVI’s values to defaults. Or maybe you’d like to run the subVI, but only display its front panel when certain conditions are true. All this and more is possible with the “Static VI Reference” block, found under “Programming” → “Application Control” and shown here:

Static VI Reference

Place this block on your diagram. Now drag your subVI onto the “Static VI Reference” block you’ve just created. You’ll notice it takes on the same icon as your subVI. From here there are a world of possibilities. To see what I mean, move your cursor over the reference output of this block (as if you were wiring it) and right-click. Next, select “Create” and then “Method for VI Class.”

VI Methods

From here, you can choose to run the subVI, show or hide its front panel, reset its values to default and more. If you back up a step on this menu tree and select “Property for VI Class,” you can further alter the appearance of the subVI window, including hiding buttons (abort, run, etc.) from the toolbar and changing the window title.

Hopefully you’ve found these tricks helpful! I’ll try to post more from time to time.

This entry was posted in Hobbies, Work and tagged , , . Bookmark the permalink.

One Response to LabVIEW: Managing Interactive SubVIs

  1. Pingback: LabVIEW: Managing Interactive SubVIs | mumorais

Leave a Reply

Your email address will not be published. Required fields are marked *