User:Brian P. Josey/Notebook/2010/08/06

From OpenWetWare
Jump to navigationJump to search
Project name Main project page
Previous entry      Next entry

LabVIEW Continued

I am taking today to continue working through the LabVIEW manual and learn some more basic programming paths. I would like to finish the debugging section, the section on modular programming, and begin the section on repetition and loops.

Debugging

Breakpoint a breakpoint can be placed onto the back panel on a wire, node or the white workspace behind it. When the VI is executed, LabVIEW will run normally until it comes to the breakpoint, at which point the execution will be paused and the back panel will be brought forward with either a red box, or bullets highlighting the node or wire the breakpoint was placed on. If it was placed on the white workspace, then the VI will pause execution after the VI has ran.

On the back panel, there is a function that highlights the execution of the VI simply called highlight execution. It slows down the execution of the VI to a speed that a human can track, and illustrates how the VI is being executed by having little balls trace along the wires. There are three other buttons that do this process, but break it down. The firs is Start Single Stepping which allows you to observe each step, one by one. Step over... executes the next step in the sequence, and Finish Block Diagram exits the single stepping and executes the whole VI. When you come to a subVI in the program, you can press Step into SubVI to enter single stepping on the subVI to ensure that it is doing what you want it to do.

Some important shortcuts to remember:

  • CRTL-R runs VI
  • CRTL-E toggles between the front and back panels
  • CRTL-H displays context help window
  • CRTL-S universal save function
  • CRTL-B Removes all broken wires
  • CRTL-F find function

While in the single stepping mode:

  • CRTL-down arrow steps into a node
  • CRTL-right arrow steps over a node
  • CTRL-up arrow steps out of a node

Modular Programming

Any VI can be used on the block diagram of another VI, and when this happens, it is used as a subVI, and there is no limit to the number of levels of subVI’s in a program. This is similar to creating functions in MATLAB to do some common application, and calling it up in another piece of code.

To make a subVI more useful and simple, it is possible to create an icon for the subVI by selecting ‘’VI properties’’ from the file menu. One of the options pulls up a simple paint like program that you can create the icon in. Then with the subVI, you also want to set up a connector pane, which is how the wires are connected to the subVI. To do this, right click the icon on the upper right corner of the front panel, and select ‘’Show Connector’’, and then select an appropriate pattern, that represents the right number of inputs and outputs. Then left click on each of the possible blocks on the connector, and click on the desired input or output. This will wire in the appropriate ones, and the subVI will act identically to the subVI’s that come with LabVIEW.

Repetition and Loops

While Loops

While loops work in LabVIEW essentially the same way they do in MATLAB, the execute a series of code until some condition is met. For each iteration of the code, if the condition is not met, the code will re-execute until it is met, at which point it will end. A while loop will always execute at least once.

For Loops

For loops are similar to while loops in that they will run the same piece of code repetitively, but they are different in that for loops will run the code for a set number of iterations, and then complete, while a while loop will only complete if it is able to satisfy some condition specified by the programer. The two can be interchanged on LabVIEW by right clicking on the while loop, and selecting convert to for loop.