LabVIEW Info
LabView Tips
-
Double clicking an object can show where an object's location is on the block diagram or front panel.
-
Hold control key while scrolling to cycle through different cases in a case structure.
Ctrl + H for context help window.
If there is an error that prevents execution, clicking the run button will bring up the error list.
Ctrl + B deletes broken wires.
Double click to comment code.
If unsure of how to make a control or indicator for anything in LabView that needs one, right click it and look under the create menu.
What is LabVIEW?
Laboratory Virtual Instrument Engineering Workbench (LabView) is a development environment created by National Instruments, first released in 1986. LabView utilizes a visual programming language, referred to as “G”. The zero time epoch of LabView is January 1, 1904.
Benefits of LabView include interfacing to devices, large libraries, ease of parallel programming, and large user community.
Vocabulary
Front Panel: The user interface of the program
Block Diagram: The underlying “source code” of the front panel.
VI: A LabView program or subroutine. Short for “Virtual Instrument”.
Labview Tutorial
Connector Panes
The Connector Pane is used when the user wants to use a given VI as a sub-VI (i.e. use a VI as a module within another LabView program). This is similar to a function call in a text based program.
The Connector Pane is located in the upper right corner, next to the VI icon.
Each box within the connector pane is a terminal that gives input to or receives output from a front panel control or indicator.
The NI website describes the basic idea of how a connector pane works: “A connector pane receives data at its input terminals, passes the data to the block diagram code through the front panel controls, and receives the results at its output terminals from the front panel indicators.”
Wire the connector pane by clicking on a box in the connector pane, and then clicking on a front panel control or indicator.
Notes
National Instruments recommends using a cluster if more than 16 terminals are to be used.
Stylistically, inputs and outputs on the connector pane should be split consistently (e.g. left and right for input and output, respectively), and “error in clusters [should be] on the lower left corner of the front panel and the error out clusters on the lower right corner.”
Clusters
A cluster is a grouping of related items into one object.
Example: Error clusters have a true-false Boolean indicator, a integer for an error code, and a string for text code label.
Clusters may be created in two ways:
Using the Modern » Array, Matrix, & Cluster palette, and putting a cluster on the front panel. Elements of the cluster can then be dragged and dropped into the cluster.
Using the bundle function (found in the Programming » Cluster, Class, and Variant palette). Elements can be wired into it on the block diagram and a cluster wired out.
Shift Registers
Shift registers are small arrows around the edge of a loop that allow you to pass values (such as the result of arithmetic) between iterations of the loop.
To add: “Right-click the left or right border of the loop and select Add Shift Register from the shortcut menu.”
Note: If you do not wire an initial value to a shift register, then it may use the last value stored from the previous execution. If you want it to reset each time you run the program, you must set an initial value.
Feedback Nodes
When contained inside a loop, a feedback node behaves similarly to a shift register.
Feedback nodes store data from previous block diagram executions or loop iterations.
When an output of a VI is wired to its own input, a feedback node is automatically created.
An initial value may be set by wiring a value to the bottom terminal.
Property Nodes
Control References
Loops
For Loops
“N” represents number of iterations.
“I” represents current iteration.
Can set up parallel iteration, but obviously should only be done if useful.
While Loops
Timed Loops
With Frames
Sequence Structures
Should be used sparingly because they hide code.
Flat Sequence Structure
Stacked Sequence Structure
Timed Sequence Structure
Case Structures
Events
Events
Related to Event Structures (a case structure that is based on events).
Communications Ports
Classes
Classes
Classes in LabView are used to create user-defined data types by defining data associated with an object.
To create a new class, “Right-click My Computer in the Project Explorer window and select New»Class from the shortcut menu. The New Class dialog box appears.”
Data from the class is not available to VI's that are not part of the class.
Member VI's can be used to manipulate this private data, which can then be used as sub-VI's for other programs as the user chooses.
A VI can be designated as a “friend” of a class library in order to access data available only at the community level (which means a VI must be a friend or member of the class to access its member VI's).
Each class will have a Private data control, which is used to define the private data type of a LabVIEW class using a Cluster of class private data.
Right click the class and use the New menu to select new member VI's.
Inheritance
Inheritance allows a class to be used as the starting point of a new class.
The new class will have the same private data as the ancestor class, in addition to new private data for the new class.
Graphing
Difference between a graph and a chart: a graph takes in all the data and then produces a plot, while a chart creates plots one piece at a time.
Graphs and charts can be found in the graph palette, which can be found in the modern, silver, system, or classic palettes.
Graphs and Charts
Arrays
To build an array from a for loop, use the reshape array function in the array palette.
When creating a 2D array from for loops, use a nested loop and an auto-indexing tunnel. The outer for loop creates the row elements, and the inner for loop creates the column elements. An example is shown below.
Virtual Instrument Software Architecture (VISA)
Enables usage of instruments made by different companies with the same programming language and interface.
Instruments are referred to as a VISA Resource.
Specific names for an instrument are called the instrument descriptor, and include the interface type (e.g. USB), the address of the device, and the VISA session type (e.g. INSTR). A VISA alias can be used to identify an instrument more easily for the programmer.
NI states that a normal VISA application uses the following steps:
1. Open a Session to a given Resource.
2. Do any configuration on the given resource (setting baud rates, termination character, etc...).
3. Perform writes and reads to the device.
4. Close the Session to the Resource.
5. Handle any errors that may have occurred.
Miscellaneous
Using ULx USB-1608GX
Appendix
Temporary Notes