|
When creating a program, you may run into errors or incorrect data. NI LabVIEW software provides a variety of troubleshooting tools to help you learn which tasks different parts of your program are implementing and to save your team time and frustration during your robot-building process. Instead of spending time to track down a minor programming error, you can use these troubleshooting tools to narrow it down quickly and efficiently and resolve it before moving forward with your robot challenges. Applications engineers, who provide the technical support for National Instruments products, use these tools in every support-related question they receive, and you have them at your fingertips.
View an animation of the execution of the block diagram by clicking the Highlight Execution button.
Execution highlighting shows the movement of data on the block diagram from one node to another using bubbles that move along the wires. Use execution highlighting with single stepping to see how data values move from node to node through a VI.
Note: Execution highlighting greatly reduces the speed at which the VI runs. Be sure to turn this off when not debugging.
Single-step through a VI to view each action of the VI on the block diagram as the VI runs. The single-stepping buttons affect execution only in a VI or subVI in single-step mode.
Enter single-step mode by clicking the Step Into or Step Over button on the block diagram toolbar. Move the cursor over the Step Into, Step Over, or Step Out button to view a tip strip that describes the next step if you click that button. You can single-step through subVIs or run them normally.
If you single-step through a VI with execution highlighting on, an execution glyph, shown as follows, appears on the icons of the subVIs that are currently running.
Use the Probe tool, shown as follows, to check intermediate values on a wire as a VI runs.
Take advantage of the Probe tool if you have a complicated block diagram with a series of operations, any one of which might return incorrect data. Use the Probe tool with execution highlighting, single stepping, and breakpoints to determine if and where data is incorrect. If data is available, the probe immediately updates during single stepping or when you pause at a breakpoint. When execution pauses at a node because of single stepping or a breakpoint, you also can probe the wire that just executed to see the value that flowed through that wire.
You can check intermediate values on a wire when a VI runs by using a generic probe, an indicator on the Controls palette to view the data, a supplied probe, or a customized supplied probe, or by creating a new probe.
Generic
Use the generic probe to view the data that passes through a wire by right-clicking a wire and selecting Custom Probe >> Generic Probe from the shortcut menu. The generic probe displays the data, but you cannot configure this probe to respond to the data.
LabVIEW displays the generic probe when you right-click a wire and select Probe, unless you have already specified a custom or supplied probe for the data type.
You can debug a custom probe like you debug a VI. However, a probe cannot probe its own block diagram or the block diagram of any of its subVIs. When debugging probes, use the generic probe.
Custom
Use the Create New Probe box to create a probe based on an existing probe or to create a new probe. Right-click a wire and select Custom Probe >> New from the shortcut menu to display the Create New Probe dialog box. A custom probe is useful when you want to have more control over how LabVIEW probes the data that flows through a wire. When you create a new probe, the data type of the probe matches the data type of the wire you right-clicked. If you want to edit the probe you created, you must open it from the directory where you saved it.
After you select a probe from the Custom Probe shortcut menu, navigate to it using the Select a Control palette option, or create a new probe using the Create New Probe dialog box. That probe becomes the default probe for that data type, and LabVIEW loads that probe when you right-click a wire and select Probe from the shortcut menu. LabVIEW loads only probes that exactly match the data type of the wire you right-click. That is, a double-precision floating-point numeric probe cannot probe a 32-bit unsigned integer wire even though LabVIEW can convert the data.
You also can use an indicator to view the data that passes through a wire. For example, if you view numeric data, you can use a chart within the probe to view the data. Right-click a wire, select Custom Probe >> Controls from the shortcut menu, and select the indicator you want to use. You also can click the Select a Control icon on the Controls palette and choose any custom control or type definition saved on the computer.
If the data type of the indicator you select does not match the data type of the wire you right-clicked, LabVIEW does not place the indicator on the wire.
Use the Breakpoint tool, shown as follows, to place a breakpoint on a VI, node, or wire on the block diagram and pause execution at that location.
When you set a breakpoint on a wire, execution pauses after data passes through the wire and the Pause button appears red. Place a breakpoint on the block diagram to pause execution after all nodes on the block diagram execute. The block diagram border appears red and flashes to reflect the placement of a breakpoint.
When a VI pauses at a breakpoint, LabVIEW brings the block diagram to the front and uses a marquee to highlight the node or wire that contains the breakpoint. When you move the cursor over an existing breakpoint, the black area of the Breakpoint tool cursor appears white.
When you reach a breakpoint during execution, the VI pauses and the Pause button appears red. You can take the following actions:
Single-step through execution using the single-stepping buttons
Probe wires to check intermediate values
Change values of front panel controls
Click the Pause button to continue running to the next breakpoint or until the VI finishes running.
LabVIEW saves breakpoints with a VI, but they are active only when you run the VI. You can view all breakpoints by selecting Operate >> Breakpoints and clicking the Find button.
You can remove breakpoints individually or throughout the entire VI hierarchy by selecting the breakpoint and right clicking. Then choose Clear Breakpoint.
You can select the block diagram and go to Edit >> Remove Breakpoints from Hierarchy.
Suspend execution of a subVI to edit values of controls and indicators, to control the number of times the subVI runs before returning to the caller, or to go back to the beginning of the execution of the subVI. You can cause all calls to a subVI to start with execution suspended, or you can suspend a specific call to a subVI.
To suspend all calls to a subVI, open the subVI and select Operate >> Suspend when Called. The subVI automatically suspends when another VI calls it. If you select this menu item when single stepping, the subVI does not suspend immediately. The subVI suspends when it is called.
To suspend a specific subVI call, right-click the subVI node on the block diagram and select SubVI Node Setup from the shortcut menu. Place a checkmark in the Suspend when Called checkbox to suspend execution only at that instance of the subVI.
The VI Hierarchy window, which you display by selecting View >> VI Hierarchy, indicates whether a VI is paused or suspended. An arrow glyph, shown as follows, indicates a VI that is running regularly or single stepping.
A pause glyph, shown as follows, indicates a paused or suspended VI.
A green pause glyph, or a hollow glyph in black and white, indicates a VI that pauses when called. A red pause glyph, or a solid glyph in black and white, indicates a VI that is currently paused. An exclamation point glyph, shown as follows, indicates that the subVI is suspended.
You can suspend and pause a VI at the same time.
When you pause a subVI, the Call list pull-down menu on the toolbar lists the chain of callers from the top-level VI down to the subVI. This list is not the same list you see when you select Browse >> This VI's Callers, which lists all calling VIs regardless of whether they are currently running. Use the Call list menu to determine the current instance of the subVI if the block diagram contains more than one instance. When you select a VI from the Call list menu, its block diagram opens, and LabVIEW highlights the current instance of the subVI.
You can run a VI with a section of the block diagram disabled, similar to commenting out a section of code in a text-based programming language. Disable a section of the block diagram to determine if the VI performs better without it. Place the section you want to disable inside a Diagram Disable Structure.
If a VI is not broken, but you get unexpected data, you can use the following techniques to identify and correct problems with the VI or the block diagram data flow.
Wire the error in and error out parameters at the bottom of most built-in VIs and functions. These parameters detect errors encountered in each node on the block diagram and indicate if and where an error occurred. You also can use these parameters in the VIs you build.
To eliminate all VI warnings, select View » Error List and place a checkmark in the Show Warnings checkbox to see all warnings for the VI. Determine the causes and correct them in the VI. Remember that these warnings could be notifying you of other problems that may occur.
Use the Positioning tool to triple-click a wire to highlight its entire path and to ensure that the wires connect to the proper terminals.
Select View >> VI Hierarchy to find unwired subVIs. Unlike unwired functions, unwired VIs do not always generate errors unless you configure an input to be required. If you mistakenly place an unwired subVI on the block diagram, it executes when the block diagram does. Consequently, the VI might perform extra actions.
Use the Context Help window to check the default values for each function and subVI on the block diagram. VIs and functions pass default values if recommended or optional inputs are unwired. For example, a Boolean input might be set to TRUE if unwired.
Click the Retain Wire Values button on the block diagram toolbar to retain wire values for use with probes. With this feature, you can easily check values of data that last passed through any wire.
Note: This option uses more memory and the VI will run quite a bit slower, so be sure to take this into consideration when debugging with this tool.
Determine if the data that one function or subVI passes is undefined. This often happens with numbers. For example, at one point in the VI, an operation could have divided a number by zero, thus returning Inf (infinity), whereas subsequent functions or subVIs were expecting numbers.
Determine if any for loops inadvertently execute zero iterations and produce empty arrays.
If the VI runs more slowly than expected, confirm that you turned off execution highlighting in subVIs. Also, close subVI front panels and block diagrams when you are not using them because open windows can affect execution speed.
Verify you initialized shift registers properly unless you intend for them to save data from one execution of the loop to another.
Check that the VI does not contain hidden subVIs. You inadvertently might have hidden a subVI by placing one directly on top of another node or by decreasing the size of a structure without keeping the subVI in view.
There are no comments on this document