20
Debugging in LabVIEW Hans-Pe3er Halvorsen

Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Debugging in LabVIEW

Hans-Pe3er Halvorsen

Page 2: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

What is “Debugging”?

Debugging is the process of locating and fixing or bugs (errors) in your computer program code, in this case your LabVIEW program

Page 3: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Debugging in LabVIEWLabVIEW has powerful features for Debugging your Code, such as:• Broken Run Arrow• Highlight Execution• Probes• Breakpoints

Page 4: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Broken Run Arrow• Click the broken Run button to display the

Error list window, which lists all the errors. • Double-click an error description to display

the relevant block diagram or front panel and highlight the object that contains the error.

Page 5: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Broken Run Arrow - Example

Double-click

Page 6: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting
Page 7: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Highlight Execution• View an animation of the execution of the block

diagram by clicking the Highlight Execution button.

• Execution highlighting shows the flow of data on the block diagram from one node to another using bubbles that move along the wires.

• Note! Execution highlighting greatly reduces the speed at which the VI runs.

Page 8: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Highlight Execution

Page 9: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting
Page 10: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Probes• Use the Probe tool to check intermediate

values on a wire as a VI runs.

• Probe Watch Window

Page 11: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Probes

Page 12: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Probe Watch Window

Page 13: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting
Page 14: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Breakpoints• Use the Breakpoint tool 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 pass through the wire.

Page 15: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

BreakpointsSet/Clear Breakpoint

Tools Palette:

Breakpoint Toolbar

Page 16: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Breakpoint Manager

Enable/DisableBreakpoints

Page 17: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting
Page 18: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

How To Avoid Bugs• Structure your Code properly, i.e., avoid socalled

«Spaghetti Code»• Flow from left to right• Use SubVIs• Use the State Machine Programming teqnique• Make it simple• Keep in mind that others should understand your

Program• ..

Page 19: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Bad vs. Good Code

Use SubVIs!!!

Avoid Spaghetti Code!

The Flow should go from left to right

Make your code readable for others!

Use Labels and Comment your Code

This is a comment

Page 20: Debugging in LabVIEW · 2019-01-16 · Highlight Execution •View an animation of the execution of the block diagram by clicking the Highlight Execution button. •Execution highlighting

Hans-Petter Halvorsen

University of South-Eastern Norwaywww.usn.no

E-mail: [email protected]: https://www.halvorsen.blog