In this tutorial you will learn about the debugging tool. How to use it and what are its benefits in LabView. At the start you are provided with an introduction including the explanation of debugging then debugging tool and after that what is the purpose of debugging tool in LabView ad how to use it. After that a VI explaining the use of debugging tools is designed, which explains the concept of debugging tool more clearly. At the end of the tutorial you are provided with an exercise to do it by yourself, and in the next tutorials I will assume that you have done those exercises and I will not explain the concept regarding them.
Introduction to debugging and debugging tools in labview
In computer programming and engineering, debugging is defined as a multistep process that involves identifying a problem. Not only determining the problem but isolation the source of the problem and also correcting the problem or finding out a method to correct the problem or error in a program is also included in debugging of a program. Testing the correction of the program and to make sure that it works properly is the final step of debugging procedure..
A computer program that is used to test the working and to remove errors from other computer programs is known as a debugger or debugging tool
In LabVIEW software a powerful debugging toll is already available that helps to identify problem areas and determines the exact location of error in your code and also guides you what is the problem or error in your VI so you can correct the error and make specific changes for your VI to work around. LabView can help you to identify and troubleshoot all types of errors in your program i.e. those which prevents the program from running and also the one which generate erroneous results at the output after running the program.
If the run arrow of the LabVIEW block diagram window is broken this implies that the program contains error or multiple errors and clicking on the arrow will display the error list, because of which the error is broken. From the type of bugs we discuss above the later one is harder to track down an debug but LabView has numerous tools i.e. highlight execution through which you can actually watch the code as it executes and makes the process much easier.
How to debug programs in labview and exmaples
- I will now use a VI to explain the working of debugging tools in LabView. Create a VI as we have been doing from tutorial 1 and save it for future use by pressing <Ctrl+S>.
- To understand the use of debugging tool we must create a program first with errors in it. For the sake of it create a simple control indicator VI and connect them, but, the control and indicator must be of different types as shown in the figure below,
Figure 1: VI with errors
- When there is an error in the VI you will not be able to run the VI, as is the case with any other text based programming language.
- Even the run arrow on the block diagram window will not remain solid if the VI has errors in it, it will convert into a broken arrow as show in the figure below,
Figure 2: Broken errors
- If you now hover over the arrow then instead of run it will say list of errors, which implies that the VI is erroneous and clicking on the run arrow now will show you a dialog box displaying all the errors currently present in the VI as shown in the figure below,
Figure 3: List of errors
- This window will show all the errors currently present in a VI. In the above VI only one error is present thus the window shows only one error. You can see the error in the block diagram or front panel by clicking on the show error button in the error list window as shown in the figure below,
Figure 4: Showing errors in Block diagram
Figure 5: Highlighted error
- Now if you change the type of the indicator from string data type to numeric you can see that the error will be removed as shown in the figure below,
Figure 6: Type changed
- The arrow will also be changed from broken arrow to a solid one and you can also run the program now as shown in the figure below,
Figure 7: No error arrow representation
- Now for an example consider another VI as shown in the figure below, this VI already have errors in it and our task here is to resolve the errors in the VI using the debugging method we just discussed. See the figure below,
Figure 8: Sample VI with errors
- In the above VI the broken arrow shows that there are errors in the VI, clicking on the arrow will display the list of errors as shown in the figure below,
Figure 9: Error list
- This window shows that there are 3 errors in the VI and when you select an error as we have selected wait(ms) error in this case and click on show error the VI will show that where is the error located.
- This window also describe the proble at that point which needs to be fixed, refer to the figure below,
Figure 10: 1st error indicated
- This indicated that our wait is not given a time or constant to which it has to wait before moving to the next iteration. Create a constant here and specify a value in it.
- Now move to the next error which says that two different data types are connected as shown in the figure below,
Figure 11: Second error
- Clicking on the show error button will display the error in the block diagram as shown in the figure below,
Figure 12: 2nd error indication
- We have connected a double type control to a string type indicator, change the indicator type to double and the error will be removed. Now lets’ move forward to the 3rd error which states that the for loop termination condition is not specified as shown in the figure below,
Figure 13: Third error
- Number of loops to be covered by the VI before termination of the code is not specified in the VI. If we click on the show error button it will display the exact location of the error as shown in the figure below,
Figure 14: 3rd error indication
- Specify the number of iterations i.e. N by creating a constant with N and specifying an integer in it and the third error will also be removed. The VI with all the errors removed from it is shown in the figure below,
Figure 15: Non erroneous VI
You can see from the above figure that the arrow is changed from the broken one to the solid one and there are no errors remaining in it. You can also use the highlighting tool to see the flow of data in the VI.
- Turn on the highlight execution and run the VI from which we just remove the errors (temp_conv.vi) and see the flow of data in the VI as we have done in the tutorial explaining dataflow.