Lecture notes
Download
Report
Transcript Lecture notes
CS320n –Visual Programming
More LabVIEW Foundations
What We Will Do Today
• Look at some more features of LabVIEW
• Work on exercises involving debugging
and creating sub VIs
Visual Programming
LabVIEW Foundations
2
VI Libraries
• VIs can be saved as
individual programs
• A group of VIs can be
saved together as a VI
library
• creating -> an option in
the save window
• opening -> open as
regular file, then select
which VI to open from
library
Visual Programming
LabVIEW Foundations
3
From Last Time
• Some functions have a variable
number of inputs
• The string concatenation function
• When opened notice blue dots on
top and bottom
• function can be expanded for
more inputs
– note visual cue on order of inputs in
result for three input function
Visual Programming
LabVIEW Foundations
4
Debugging
• VIs that are broken cannot be run
– analogous to syntax error in text based programming
languages
• Most common mistakes
– required input missing on function terminals (for
example, add)
– type mismatch on data (wire double when integer was
expected
– loose, unconnected wires
– sub VI is broken
– multiple inputs into a single indicator
Visual Programming
LabVIEW Foundations
5
Broken Programs
• Clicking on the broken arrow brings
up a list of errors
• Clicking on an error displays more
information about the error
Visual Programming
LabVIEW Foundations
6
Stepping Through a Program
• Sometimes you want to observe a program step
by step, not all at once
• Click on the single set button instead of the run
button
• Press the single step button to see the flow of
the program
Visual Programming
LabVIEW Foundations
7
Execution Highlighting
• Another excellent debugging tool is Execution
Highlighting
– aside: why no debugging tools in Alice?
• Select “Highlight Execution” and data values and
movement shown as program runs. Very useful
• Can be used as program runs or combined with
stepping through program
Visual Programming
LabVIEW Foundations
8
Probes
• To view the value on a wire or result of
a function you can either set up an
indicator or use a probe
• With a running program, probe is auto
selected when putting the cursor near
a wire
• When the program is not running
probes can be added.
–
–
–
–
choose the “Window” menu
select “Show Tools Palette”
click on the probe tool to add probes
be sure to change Tool back to auto select
when finished
Visual Programming
LabVIEW Foundations
probe
9
Breakpoints
• Suppose you want to stop the
program at a single point,
deep into the execution
• using the step by step control
is a pain
• set a breakpoint
– right click or use breakpoint tool
– program will run normally until it
hits that point
Visual Programming
LabVIEW Foundations
break point on wire
and function
10
Creating sub VIs
• If you create a program and want to use
that in other program you can create a
Sub VIs
• steps in creating a sub VI
– assign VI controls and indicators to wire
terminals on its connector pane so that data
can be passed into and out of the VI
– create an icon for the VI
Visual Programming
LabVIEW Foundations
11
C to F
• Create icon
– right click on icon in
upper right corner and
select “Edit Icon”
Visual Programming
LabVIEW Foundations
12
Assign Connectors
• Defining parameters
– like in Alice
• Right click icon on the front panel. (Not
the block diagram.)
• Select “Show Connector”
– two terminals
– input / control on left
– output / indicator on right
• click in left hand terminal / box on icon
and select front panel control to set
• repeat for right hand side terminal
Visual Programming
LabVIEW Foundations
13