You are on page 1of 47

Getting started First Steps Programming Examples and Tasks

Labview Introduction in 3 hours

Volkmar Zabel
Maik Brehm
Daniel Arnold

Institute of Structural Mechanics


Bauhaus University Weimar
Weimar, Germany

2010

Zabel/Brehm/Arnold 2010 1 / 47 ,
Getting started First Steps Programming Examples and Tasks

Outline

1 Getting started

2 First Steps

3 Introduction to LabVIEW Programming

4 Examples and Tasks

Zabel/Brehm/Arnold 2010 2 / 47 ,
Getting started First Steps Programming Examples and Tasks

Start LabVIEW
start from terminal with:
user@computer > /parrot/apps/natinst/LabVIEW-2009/labview

Zabel/Brehm/Arnold 2010 3 / 47 ,
Getting started First Steps Programming Examples and Tasks

Virtual instruments (VIs)


LabVIEW programs are called virtual instruments (VIs),
containing 2 Windows: Front Panel and Block Diagram
Front Panel = Front End

User Interface
Controls = inputs
Indicators = outputs

Block Diagram = Back End

Graphical code
Data flow trough wires
from controls over functions to
indicators
Blocks executes by data flow
Zabel/Brehm/Arnold 2010 4 / 47 ,
Getting started First Steps Programming Examples and Tasks

Controls Palette
Control: Numeric

Indicator: Numeric slide

Controls Palette
Use the Controls palette to place controls and indicators on the front
panel. You can display the Controls palette by right-clicking an open area
on the front panel.
Zabel/Brehm/Arnold 2010 5 / 47 ,
Getting started First Steps Programming Examples and Tasks

Functions Palette

Structure: While loop

Functions Palette
The Functions palette is available only on the block diagram. You can
display the Functions palette by right-clicking an open area on the block
diagram.

Zabel/Brehm/Arnold 2010 6 / 47 ,
Getting started First Steps Programming Examples and Tasks

Status Toolbar

Status Toolbar Buttons


Run button Run the VI once.
Countinuous Run button Run the VI until you abort it.
Abort button Stop the VI immediately.

Additional Buttons on the Diagram Toolbar


Execution highlight button
Retain wire value button
Step function button

Zabel/Brehm/Arnold 2010 7 / 47 ,
Getting started First Steps Programming Examples and Tasks

Data Types

LabVIEW uses many common data types


Boolean, numeric, strings, clusters, . . .

The color and symbol of each terminal indicate the data type of the
control or indicator. Control terminals have a thicker border than indicator
terminals. Also, arrows appear on front panel terminals to indicate whether
the terminal is a control or an indicator. An arrow appears on the right if
the terminal is a control and on the left if the terminal is an indicator.

Zabel/Brehm/Arnold 2010 8 / 47 ,
Getting started First Steps Programming Examples and Tasks

Data Flow

LabVIEW Data Flow


Block diagram execution
Dependend on the flow of data
Block diagram does NOT execute
from left to right
Node executes when ALL input data are
available
Nodes supply to all output terminals
when done

Zabel/Brehm/Arnold 2010 9 / 47 ,
Getting started First Steps Programming Examples and Tasks

Debugging Techniques
Finding Errors
Click on the broken arrow button, LabVIEW will show an error list.

Execution Highlight
Click on Execution Highlight button;
Data flow will be visualized with bubbles and values.

Probe Values
Toggle On/Off Probe values.
Right-click on the wire of interest → context menu
→ Probe will display a probe window.

Breakpoint
Set pauses at different locations on the diagram.
Click on wires or objects with the Breakpoint tool to set breakpoints.
Zabel/Brehm/Arnold 2010 10 / 47 ,
Getting started First Steps Programming Examples and Tasks

Help
Show Context Help

Displays basic information about LabVIEW


objects. Objects with context help information
include VIs, functions, constants, structures,
palettes, properties, methods, events, and
dialog box components.
Open context help window
hCtrl + Hi
Help menu → Show Context Help
Hover over nodes to update help window

Get detailed help


Click on Detailed help in Context Help
Right-click on the node, then choose Help
Zabel/Brehm/Arnold 2010 11 / 47 ,
Getting started First Steps Programming Examples and Tasks

Loops
While–Loop

Run at least once (Do-While-Loop)


loop counter
loop stop condition
Loop runs until its input is True

For–Loop

loop counter
Run loop until number of iterations.

Zabel/Brehm/Arnold 2010 12 / 47 ,
Getting started First Steps Programming Examples and Tasks

Creating Loops
Palette Drawing the loop
Choose the Structures part Enclose code to be repeated.
from Functions Palette

Drag-and-Drop Nodes into


pre-defined structure.

Zabel/Brehm/Arnold 2010 13 / 47 ,
Getting started First Steps Programming Examples and Tasks

Sequences
Parallel Execution

All encapsulated code


fragments are
executed in parallel.

Sequence Execution

For sequential
comutation create a
Sequence structure.

Zabel/Brehm/Arnold 2010 14 / 47 ,
Getting started First Steps Programming Examples and Tasks

Have fun using LabVIEW

Whish you a successful start using

Zabel/Brehm/Arnold 2010 15 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 1: Generate and save signals


Working directory:
cd ∼/2010 LabviewCourse/example1

Task
Simulation of one time signal with variable properties
4096 Samples per second; 8192 samples per block
Save the time history as *.lvm file

Main VI’s to use


Block Diagram → Right Click → Express → Input → Simulate Signal
Block Diagram → Right Click → Express → Output → Write Meas.
File
Block Diagram → Right Click → Express → Arith & Comp →
Comparison → Comparison
Zabel/Brehm/Arnold 2010 16 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 1: Generate and save signals


Simulate signal – Configuration

Zabel/Brehm/Arnold 2010 17 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 1: Generate and save signals


Front Panel proposal

Zabel/Brehm/Arnold 2010 18 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 1: Generate and save signals


Block Diagram proposal

Zabel/Brehm/Arnold 2010 19 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 1: Generate and save signals


Head of .lvm file

Zabel/Brehm/Arnold 2010 20 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 2: Read and process data

Working directory:
cd ∼/2010 LabviewCourse/example2

Task
Read and visualize a signal from an .lvm file
Calculate the averaged Power Spectrum of the signal

Main VI’s to use


Block Diagram → Right Click → Express → Input → Read Meas. File
Block Diagram → Right Click → Express → Signal Analysis →
Spectral

Zabel/Brehm/Arnold 2010 21 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 2: Read and process data


Read file configuration

Zabel/Brehm/Arnold 2010 22 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 2: Read and process data


Spectral configuration

Zabel/Brehm/Arnold 2010 23 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 2: Read and process data


Front Panel proposal

Zabel/Brehm/Arnold 2010 24 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 2: Read and process data

Block Diagram proposal

Zabel/Brehm/Arnold 2010 25 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 1: Generate and save signals

Working directory:
cd ∼/2010 LabviewCourse/task1

Task: Add second signal


Based on Example 1 add a second signal with 4096 Samples per
second and 8192 samples per block
Save both signal as *.lvm file
Load the signals similar to Example 2 and calculate the Power
Spectrum

Main VI’s to use


Same as in Example 1 and Example 2

Zabel/Brehm/Arnold 2010 26 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 1: Generate and save signals

Front Panel proposal

Zabel/Brehm/Arnold 2010 27 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 1: Generate and save signals

Block Diagram proposal

Zabel/Brehm/Arnold 2010 28 / 47 ,
Getting started First Steps Programming Examples and Tasks

Structural system

System
k6
k1 k3
m1 k4 k5 m3

k2 m2

Measurement of
random signal at DOF 1
acceleration at all DOFs

Zabel/Brehm/Arnold 2010 29 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 3-1: Identify natural frequencies

Working directory:
cd ∼/2010 LabviewCourse/task3 1

File information
data is in file Measured data.lvm
Columns: | time | acce dof 1 - 3 | force dof 1 - 3 |
No header information; Comma delimiter
block size for average: 8192

Task
Identify the natural frequencies of the structure

Zabel/Brehm/Arnold 2010 30 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 3-1: Identify natural frequencies


Read file configuration

Zabel/Brehm/Arnold 2010 31 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 3-1: Identify natural frequencies

Front Panel proposal

Zabel/Brehm/Arnold 2010 32 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 3-1: Identify natural frequencies

Block Diagram proposal

Zabel/Brehm/Arnold 2010 33 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 3-2: Read and visualize transfer functions

Working directory:
cd ∼/2010 LabviewCourse/example3 2

File information
data is in file H matrix rea.lvm
Columns: | H11 | H12 | H13 | H21 | H22 | H23 | H31 | H32 | H33 |
No header information; Comma delimiter

Additional feature
Tab Control

Zabel/Brehm/Arnold 2010 34 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 3-2: Read and visualize transfer functions


Read file configuration

Zabel/Brehm/Arnold 2010 35 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 3-2: Read and visualize transfer functions


Front Panel proposal

Zabel/Brehm/Arnold 2010 36 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 3-2: Read and visualize transfer functions


Block Diagram proposal

Zabel/Brehm/Arnold 2010 37 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 3-2: Add imaginary part

Working directory:
cd ∼/2010 LabviewCourse/task3 2

File information
data is in file H matrix ima.lvm
Columns: | H11 | H12 | H13 | H21 | H22 | H23 | H31 | H32 | H33 |
No header information; Comma delimiter

Additional feature
Tab Control

Zabel/Brehm/Arnold 2010 38 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 3-2: Add imaginary part

Front Panel proposal

Zabel/Brehm/Arnold 2010 39 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 3-2: Add imaginary part

Block Diagram proposal

Zabel/Brehm/Arnold 2010 40 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 3-3:
Calculate and visualize transfer functions

Task
Calculate the complex transfer function (Accelerance) based on
mass-normalized eigenvectors [Φ], eigenvalues {λ} and modal
damping ratios {ζ}

Formula
[Hxf (ω)] = −ω 2 [Φ] [D(ω)] [Φ]T (1)

λl − ω 2 − ι 2 λl ζl ω

(D(ω))ll = 2 (2)
λl − 2λl ω 2 + ω 4 + 4λl ω 2 ζl2

Zabel/Brehm/Arnold 2010 41 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 3-3:
Calculate and visualize transfer functions

Working directory:
cd ∼/2010 LabviewCourse/example3 3

Additional feature
Simple mathematical matrix and scalar operations
For-loop

Zabel/Brehm/Arnold 2010 42 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 3-3:
Calculate and visualize transfer functions
Front Panel proposal

Zabel/Brehm/Arnold 2010 43 / 47 ,
Getting started First Steps Programming Examples and Tasks

Example 3-3:
Calculate and visualize transfer functions
Block Diagram proposal

Zabel/Brehm/Arnold 2010 44 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 3-3: Add imaginary part (Homework)

Working directory:
cd ∼/2010 LabviewCourse/task3 3

Task
Add imaginary part of transfer function using Example 3-3

Additional feature
Use boolean switch

Zabel/Brehm/Arnold 2010 45 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 3-3: Add imaginary part

Front Panel proposal

Zabel/Brehm/Arnold 2010 46 / 47 ,
Getting started First Steps Programming Examples and Tasks

Task 3-3: Add imaginary part

Block Diagram proposal

Zabel/Brehm/Arnold 2010 47 / 47 ,