Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Debugging Techniques

LabVIEW 8.2 Help
August 2006

NI Part Number:
371361B-01

»View Product Info

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.
  • 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.
  • 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.
  • Use the Find dialog box to search for subVIs, text, and other objects to correct throughout the VI.
  • 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 execution highlighting to watch the data move through the block diagram.
  • Single-step through the VI to view each action of the VI on the block diagram.
  • Use the Probe tool to observe intermediate data values and to check the error output of VIs and functions, especially those performing I/O.
  • Click the Retain Wire Values button on the block diagram toolbar to retain wire values for use with probes. This feature allows you to easily check values of data that last passed through any wire.
  • Use breakpoints to pause execution, so you can single-step or insert probes.
  • Suspend the execution of a subVI to edit values of controls and indicators, to control the number of times it runs, or to go back to the beginning of the execution of the subVI.
  • Comment out a section of the block diagram to determine if the VI performs better without it.
  • 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.
  • 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.
  • Check the representation of controls and indicators to see if you are receiving overflow because you converted a floating-point number to an integer or an integer to a smaller integer. For example, you might wire a 16-bit integer to a function that only accepts 8-bit integers. This causes the function to convert the 16-bit integer to an 8-bit representation, potentially causing a loss of data. Refer to Preventing Undefined Data for more information.
  • Determine if any For Loops inadvertently execute zero iterations and produce empty arrays. Refer to Execution Highlighting and Preventing Undefined Data for more information.
  • Verify you initialized shift registers properly unless you intend them to save data from one execution of the loop to another.
  • Check the cluster element order at the source and destination points. LabVIEW detects data type and cluster size mismatches at edit time, but it does not detect mismatches of elements of the same type.
  • Check the node execution order.
  • 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.

    Check the inventory of subVIs the VI uses against the results of View»Browse Relationships»This VI's SubVIs and View»Browse Relationships»Unopened SubVIs to determine if any extra subVIs exist. Also open the VI Hierarchy window to see the subVIs for a VI. To help avoid incorrect results caused by hidden VIs, specify that inputs to VIs are required.
  • If you are single-stepping through a VI that includes a structure that is constant folded, LabVIEW skips execution of the structure iterations or cases because the compiler has already calculated the output of the structure. If you want to single-step through the iterations or cases, temporarily change the input constant to a control. Right-click the input constant and select Change to Control from the shortcut menu to change the constant to a control. When you are finished single-stepping, right-click the control and select Change to Constant from the shortcut menu to change the control back to a constant.
  • Refer to Technical Support.

Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit