A Few More Utilities in LabVIEW


Custom Probes

In Chapter 5, "Yet More Foundations," you learned about probes, which allow you to peek inside the value of a wire while a VI is executing. If you remember, you can right-click on a wire and select Probe to get a floating window that displays this value.

LabVIEW allows you to take this debugging tool one step further with custom probes. You can probe using any conventional indicator by selecting Custom Probe> from the wire's pop-up menu, and then choosing the desired indicator with which to probe. For example, you could use a chart to show the progress of a variable in a loop, because it displays past values as well as current ones (see Figure 15.81). LabVIEW won't let you select an indicator of a different data type than the wire.

Figure 15.81. Custom probe with a chart


Remembering Probe Values

Retain Wire Values Button

Normally when you first use a probe, it will not display any data until you run the VI and data flows through the wire you are probing. However, sometimes you may want to immediately obtain the most recent value of the data that passed through the wire without having to run the VI.

This is called "retaining wire values" and you can enable this easily by pressing the Retain Wire Values button on the VI's toolbar. You'll need to have this option turned on before you run the VI for the probe to be able to display data from the last time the VI ran. But be aware that this option will cause your VI to require more memory in order to hold data for all of the wires.

Using and Creating Custom Probes

Custom probes are a powerful debugging toolthey act as both probes and conditional breakpoints (allowing you to choose the condition that suspends VI execution). You can use custom probes by right-clicking on a wire and selecting Custom Probe> from the shortcut menu, as shown in Figure 15.82. The list of items at the top of the Custom Probe> submenu (above the first divider) are all custom probes. LabVIEW only displays the custom probes that will work with the data type of the wire that you right-clicked on. LabVIEW ships with some useful custom probes for most LabVIEW data types. As you can see in Figure 15.82, the Conditional Double Probe can be placed on a wire that is a DBL type.

Figure 15.82. Inserting a Conditional Double Probe onto a DBL numeric wire


After we select Conditional Double Probe, a probe instance will be created in a new floating window, as shown in Figures 15.83 and 15.84. The Conditional Double Probe has a tab control with a Data tab and a Condition tab. The Data tab displays data as it passes through the wire, just like a regular probe. The Condition tab allows you to specify a condition that will cause the VI to be suspendedthus becoming a conditional breakpoint. This is a very powerful feature.

Figure 15.83. Data tab of the Conditional Double Probe


Figure 15.84. Condition tab of the Conditional Double Probe


Other data types have equally useful custom probes. For example, the Conditional Error Probe (shown in Figure 15.85) allows you to probe error clusters and suspend execution when certain errors occur. The Conditional String Probe (shown in Figure 15.86) allows you to probe strings and suspend execution under a variety of possible conditions.

Figure 15.85. Conditional Error Probe


Figure 15.86. Conditional String Probe


While extremely powerful, custom probes are nothing fancy. They are regular LabVIEW VIs having one input for the probed wire's data, one Boolean output for the conditional breakpoint, and a connector pane with only two terminals, as shown in Figure 15.87. For LabVIEW to find your custom probes and make them available from the Custom Probe> submenu, you must place them inside the Probes directory beneath the Default Data Directory. (The Default Data Directory may be set in the Paths section of the LabVIEW options dialog.)

Figure 15.87. Connector pane of a custom probe VI


When placed on a wire, LabVIEW creates a separate instance of the custom probe VI. Each time data flows through the wire, the custom probe VI instance is run. If the custom probe VI instance returns a Boolean value of TRUE, then execution will be suspended, just as if there were a breakpoint on the wire.


A custom probe should (in nearly all circumstances) execute and then return immediately. It should not have a while loop, or other code that could take a long time to execute. Rememberyour main code is not running while the custom probe is running.


When LabVIEW populates the Custom Probe> submenu with the list of custom probes inside the Probes folder, it only shows the custom probes with an input data type that exactly matches the data type of the wire.


To create a new custom probe, right-click on a wire and select Custom Probe>>New from the shortcut menu. LabVIEW will present you with the Create New Probe dialog. From here, you can choose to Create a probe from an existing probe or Create a new probe. Make sure that you save the new custom probe VI in the suggested location, so that LabVIEW can find it later, when you right-click on wires.

When you open the new custom probe VI, you will see a block diagram that looks similar to Figure 15.88. Do not delete these controls. These are necessary for the proper operation of your custom probe. In the block diagram, you can perform any operations that you wish. You can customize the front panel to display the data, and provide the user with choices about how to control the conditional breakpoint.

Figure 15.88. Block diagram of a newly created custom probe


To get a good understanding of what is possible with custom probes, take a look at the existing custom probes that ship with LabVIEW by choosing Create a probe from an existing probe from the Create New Probe dialog.


The VI Hierarchy Window

Generally, you will find the VI Hierarchy window useful when you are working on a VI of fair to high complexitysuch as one that contains 10 or more subVIs. The VI Hierarchy window can help keep track of where subVIs are called and who calls them.

With a VI's front panel open, select View>>VI Hierarchy to bring up the VI Hierarchy window for that VI. The VI Hierarchy window displays a graphical representation of the calling hierarchy for all VIs in memory, including type definitions and globals (see Figure 15.89).

Figure 15.89. VI Hierarchy window


The buttons in the VI Hierarchy window's toolbar let you configure a number of aspects of the display. For example, the layout can be displayed horizontally or vertically; you can hide or show as many levels of hierarchy as you wish; and you can include or exclude globals or type definitions. A nice feature in this window is the one that allows you to double-click on a subVI icon to open its front panel.

Searching for Objects in the Virtual Haystack

LabVIEW has a good search engine that you can use to quickly find and replace text, objects, or VIs in your project. LabVIEW's Find dialog, available by selecting Edit>>Find . . . from the menu, can quickly locate any LabVIEW function, subVI, global variable, attribute node, or text in your VIs. You can limit your search scope to a single VI, a VI and its subVIs, or a set of VIs, or include all VIs in memory (see Figure 15.90).

Figure 15.90. The Select Object button on the Find dialog allows you to search for any LabVIEW function or VI.


You can choose to search for objects or text by clicking in one of the Search for checkboxes. If you select Objects, click on the Select Object button to access the Select Object pop-up menu that allows you to choose the type of object you want to search for. If you select Text, you can type in the text, and click on the More Options . . . button to further limit the scope of the search to sections of VIs and object labels.

After you press the Find button, LabVIEW will display the Search Results dialog box, as shown in Figure 15.91.

Figure 15.91. The Search Results dialog shows a list of items that were found during the search.


You can double-click on any item displayed in the Search Results window to have LabVIEW show you where that item resides or use <ctrl-G> (Windows), <command-G> (Mac OS X), or <meta-G> (Linux) to view each one in order (<ctrl-shift-G> (Windows), <command-shift-G> (Mac OS X), or <meta-shift-G> (Linux) to view in reverse order).

A very fast way to use the search tool is to pop up on a VI's icon and select Find All Instances. This will initiate a search and the Search Results window (shown in Figure 15.91) will appear with the list of found items. Note that you can access the Find All Instances option from the pop-up menu of subVIs, VIs shown in the VI Hierarchy window, and the VI icons located in the upper-right corner of VI front panels and block diagrams.


Replacing Search Result Items

You can choose to replace individual or all search result items. For object searches, you can replace result items with functions or VIs that you can select from the Replace With: pop-up menu (see Figure 15.92). For text searches, Replace with: is a text box, where you can specify the text with which to replace the search result items. Pressing the Replace Selected button will replace the selected item in the results list, and pressing the Replace All button will replace all items in the results list.

Figure 15.92. The Replace with button on the Search Results dialog allows you to specify a function or VI that you wish to replace for the items found in the search.


Find VIs on Disk

The Find VIs on Disk dialog is available by selecting Tools>>Find VIs on Disk . . . from the menu (see Figure 15.93). This provides a very nice way to search for VIs beneath a directory on disk. The main advantage of this tool over the file search tools built into your operating system is that it has the ability to search for VI inside LabVIEW LLB filesthe operating system cannot see inside LLB files.

Figure 15.93. Find VIs on Disk dialog


More Tools

Under the Tools menu, you will find an assortment of other LabVIEW utilities, such as the Web Publishing Tool (which creates static or interactive web pages from your VI), a VI Profiler (which measures the time and memory a VI consumes), and more. We'll discuss some of these tools in the upcoming chapters.

Depending on the version of LabVIEW you have installed (evaluation, basic, professional, full development) and any add-on toolkits you may have (Internet Toolkit, Database Connectivity Toolkit, etc.), you will see the corresponding utilities in this menu.




LabVIEW for Everyone. Graphical Programming Made Easy and Fun
LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd Edition)
ISBN: 0131856723
EAN: 2147483647
Year: 2006
Pages: 294

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net