UMB: TMPP250 Process Technology 1 (Spring 2006)

Course in LabVIEW

The text in grey is not icluded in the course.

What is LabVIEW?

LabVIEW is a development system for measurement and automation applications based on graphical programming. LabVIEW is a good tool for experimental work on the lab and for online (real-time) and offline numerical analysis and visualization of data.

LabVIEW is produced by National Instruments.

Litterature (in Norwegian): Lær LabVIEW trinn for trinn.

Launching LabVIEW

We launch LabVIEW via the Start-button on the PC desktop.

We study the buttons on the LabVIEW launch window.

Opening and running a VI

We open and run the VI Search Examples / Industrial Applications / Analysis / Temperature System Demo.vi.

The contents of a VI

Each VI has a

  • front panel (Window / Show Panel), and a
  • block diagram (Window / Show Diagram).

We study Temperature System Demo.vi.

Developing your first VI

We will together create sigtrans.vi.

During the programming we will be using the following palettes:

  • Tools palette (Window / Show Tools palette)
  • Controls palette (Window / Show Control palette) - which applies only to the front panel
  • Functions palette (Window / Show Functions palette) - which applies only to the diagram

Debugging

Errors can be

  • syntax errors, which LabVIEW will detect automatically.
  • functional errors, which we can trace using
    • probes, which can be attached to elements in the diagram from the Probe button in the Tools Palette.
    • stepwise execution, which can be performed using proper buttons in the toolbar in the VI's diagram

Let us introduce some errors in the diagram of a VI to see how LabVIEW detects the error.

Help

Help for a specific element: Right-click on the element / Help.

Help on topics: Menu-choice: Help / VI Help, Function, How-to.

Various help (technical documents, application notes tec.) can be found from http://ni.com.

LabVIEW Exercise 1: Signal Generator and analyzer


Develop a VI according to the following specification:

  1. The VI runs continuously, with a stop button on the front panel.
  2. Time step of 0.05 defined as a constant in the block diagram.
  3. The VI implements a signal generator of the resulting sum, y, of the following signals u1 and u2, thus y = u1 + u2:
    • Sinusoid u1=A*sin(2*pi*f*t) where A and f [Hz] are adjustable from the front panel. Use a proper function on Functions Palette / All Functions / Analyze / Point by Point to generate the sinusoid
    • Bias u2=B where B is adjustable from the front panel.
  4. Default values: A=2.5, f=1.0, B=0.0.
  5. A and f are not allowed to be negative. They should be adjustable in steps of 0.1 from some graphical control element (select yourself) together with a numeric display.
  6. y is shown in a vertical pointer slide with one decimal along the scale and with a numeric display also showing the value.
  7. The mean value of the last 10 values of y, m_y, is indicated in a numerical display. Use a proper function on the palette Functions Palette / All Functions / Analyze / Point By Point.
  8. If m_y is negative a lamp is lit. A proper comparator function must be used. The m_y variable should be fed to this comparator function using a local variable (of m_y).
  9. Some free text is written on the front panel.
  10. Some of the elements have some other color than the standard color(s).

Solution: solution1.vi

Data types

Special datatypes:

Text-based programming windows

Formula Node is a window where you can write programmatic expressions following the C-syntax. Using a Formula Node for mathematical expressions is often more convenient than building the expression in the ordinary graphical way in LabVIEW.

The Formula Node is available via

Functions Palette / Structures / Formula node.

You create inputs and outputs to and from the Formula Node bye right-clicking on the frame of the Formula Node.

Note: Each variable which are given a value during an expression, must have a corresponding output on the Formla Node!

Let us study sigtrans_formulanode.vi where we will remove and re-enter the Formula Node.

You can also use the Matlab-node which is a window into Matlab. The Matlab-node is programmed in the same way as the Formula-node.

Plotting

You can add plots to a front panel from the following sub-palette:

Controls Palette / Graph

There are several different plots available, e.g.:

  • Chart, which is a plot where the points are plotted continuously, as in a t-Y plot.
  • Graph, which is a plot which plots existing arrays of data, as in an X-Y plot.

Remember: You can create an array containing all data points generated during the execution of a while-loop by wiring the variable to the frame of the while-loop and choosing Enable Indexing after right-clicking on the terminal point on the while-loop frame.

Some useful techniques when generating plots:

  • Choose the update mode: Right-click on the chart / Advanced / Update Mode.
  • Grid: Right-click on the chart / X-Scale / Formatting
  • Legend: Right-click on the chart / Visible Items / Plot Legend
  • Color, line width, line type etc. for the plot line: Right-click on the legend

Let us try plott.vi.

Property Node

[Ch. 10]

Property Nodes can be used to give front panel elements certain properties, as size, visibility, color, signal range, etc. A property (appearing in the Property Node) can be set programmatically.

To create a Property Node:

Right-click on the front panel element / Property Node

We will add a Property node to plott.vi to programmatically control the start value, and the max scale value, the x (time) axis increment, and to empty the chart as the VI is started.

Local variables

A local variable is a "copy" of a terminal and it contains the same value as the "parent" terminal. A local variable can be used anywhere within the same VI (but not in another VI).

Local variables can be set as "read" or "write".

A local variable can be created (from a given variable or element) as follows:

Right-click on the element (on the front panel or in the diagram) / Create Local Variable

Let us study lokal.vi.

LabVIEW Exercise 2: Signal generator and analyzer continued

Start with the solution to LabVIEW Exercise 1: solution1.vi.

Implement the following:

  • A cluster containing the parameters A, f, and B.
  • The mathematical function y = u1 + u2 is implemented in a Formula Node.
  • A chart which plots y and its mean value m_y. Update mode is Sweep Chart. The chart must have grid. Use a property node to implement the following: The x axis covers an interval of 30s; The x axis shows real time; The chart is emptied when the VI is started.
  • Optional: Use local variables of u1 and u2 (in stead of connection with wires) as inputs to the Formula Node.

Updated Feb 11 2006 by Finn Haugen (finn.Haugen@hit.no)