User Tools

Site Tools


atmos:software:labview:home

LabVIEW Info

  • LabView 2013 SP1
  • Version 13.0.1
  • Located on Windows lab computer in CH 423

LabView Tips

  • LabView Makerhub has several useful tutorials.
  • 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:
    1. 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.
    2. 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

Property Nodes

  • Implicitly links data from a front panel control.

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

  • Run until a condition is met.
  • This condition may be set in the block diagram or can be the provided stop button.

Timed Loops

  • Allow you to set a time in milliseconds for the program to run.
With Frames
  • Right click on the border of time loop and click add frame to add a frame.

Sequence Structures

Should be used sparingly because they hide code.

Flat Sequence Structure

  • A flat sequence structure has several frames all visible, and executes from left to right.

Stacked Sequence Structure

  • Similar to a flat sequence, but conserves space by only showing one frame at a time.

Timed Sequence Structure

  • A sequence structure that allows for setting start times.

Case Structures

  • Similar to text switch statement, has multiple cases in a structure. Only one case executes when the structure executes.

Events

Events

Related to Event Structures (a case structure that is based on events).

Communications Ports

  • Set up a communication port by searching for Instrument I/O in the functions palette and opening the Serial sub-palette, and select VISA Configure Serial Port.

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.

2D Array with 4 Rows and 6 Columns

  • To convert the 2D array to a 1D array, use the reshape function.
    • Alternatively, if only a 1D array is desired, you can use just one for loop with an auto-indexed tunnel, where the number of times the loop executes is the number of elements in the array.

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.
  • An example program is shown below (mouse over for explanation).

Example Program that "opens a session to a GPIB Instrument, performs a write of "*IDN?\n" and then queries the device for its response."

Miscellaneous

Using ULx USB-1608GX

  • In the block diagram, open the functions palette and select User Libraries » ULx for NI LabVIEW

ULx for NI LabView

Appendix

Temporary Notes
  • Search “advanced labview tutorials”
atmos/software/labview/home.txt · Last modified: 2020/01/29 17:25 by 127.0.0.1