Introduction to LabVIEW

Preview:

DESCRIPTION

 

Citation preview

LV 1

Introduction to LabVIEW

LV 2

•Graphical Programming• Easy to use• Faster Development Time• Graphical User Interface• Graphical Source Code• Easily Modularized• Application Builder to create

stand-alone executables

LabVIEW TM

LV 3

Network-based Measurement & Automation

AcquireAnywhere

AnalyzeAnywhere

PresentAnywhere

Your entire Measurement and Automation system can be controlled with LabVIEW

locally, or over the Internet

Network Network

LV 4

Acquisition with LabVIEW• LabVIEW can acquire data by using

one or more of the following devices:• GPIB• Serial• Data Acquisition (DAQ)• Remote Data Acquisition (RDA)• PCI eXtensions for Instrumentation (PXI)• Image Acquisition (IMAQ)• Motion Control• Real-Time (RT) Board• PLC (through OPC Server)

LabVIEW is completely compatible with National Instruments hardware, and also works with a variety of third party devices

AcquireAnywhere

LV 5

AnalyzeAnywhere

Analysis with LabVIEW• LabVIEW includes the following tools to help you analyze your data:

• Analysis VIs for Differential Equations, Optimization, Curve Fitting, Calculus, Linear Algebra, Statistics, etc.

• Signal Processing VIs for Filtering, Windowing, Transforms, Peak Detection, Harmonic Analysis, Spectrum Analysis, etc.

Analysis can either be done directly in LabVIEW, or with third party software such as Matlab, HiQ, or C

LV 6

PresentAnywhere

Presentation with LabVIEW• LabVIEW includes the following tools to help you present your data:

• On your machine - Graphs, Charts, Tables, Gauges, Meters, Tanks, 3D Controls, Picture Control, 3D Graphs (Windows Only), Report Generation (Windows Only)

• Over the Internet - Web Publishing Tools, Datasocket (Windows Only), TCP/IP, VI Server

• Enterprise Connectivity Toolset -SQL Tools (Databases), Internet Tools (FTP, E-mail, Telnet, HTML)

Presentation with LabVIEW can be done on your PC or over a network, and you can use third party software like Excel, or DIAdem

LV 7

Introduction to LabVIEW

You Will Learn:

A. What a virtual instrument (VI) isB. The LabVIEW environmentC. LabVIEW Help Options

LV 8

Start » All Programs » National Instruments LabVIEW 8.0

Startup Screen:

Start from a Blank VI:New»Blank VI

Start from an Example:Examples»Find

Examples…

»

or

Open and Run LabVIEW

LV 9

Each VI has 2 Windows

Front Panel• User Interface (UI)

– Controls = Inputs– Indicators = Outputs

Block Diagram• Graphical Code

– Data travels on wires from controls through functions to indicators

– Blocks execute by Dataflow

LabVIEW Programs Are Called Virtual Instruments (VIs)

LV 10

• Recommended: Automatic Selection Tool• Tools to operate and modify both front panel and

block diagram objects

Operating Tool

Positioning/Resizing Tool

Labeling Tool

Wiring Tool

Tools Palette

Automatic Selection Tool

Automatically chooses among the following tools:

LV 11

Run Button

Continuous Run Button

Abort Execution

Execution Highlighting Button

Additional Buttons on the Diagram Toolbar

Status Toolbar

Retain Wire Values Button

Step Function Buttons

LV 12

Creating, Editing, & Debugging a VI

A. How to Create VIsB. How to Edit VIs

C. How to Debug VIs

You Will Learn:

LV 13

Creating a VI Front Panel

• Numeric controls and indicators• Boolean controls and indicators• Configuring controls and indicators

– Use shortcut menus– Parts have different menus

DigitalControl

DigitalIndicator

Labels

Increment Buttons Boolean

Control BooleanIndicator

LV 14

Accessing Shortcut Menus

Right-click on the label for its shortcut menu Right-click on the digital

display for its shortcut menu

LV 15

Terminal pattern for theAdd Function and theSubtract function (three node terminals).

Creating a VI Block Diagram

NodesWires

ControlTerminals

Diagram Window

Panel Window

Indicator Terminals

LV 16

Wiring a VI Block Diagram

Hot SpotTools to Help Wiring

- Automatic Wiring- Tip Strips- Right-click on terminals and select Show Terminals

- Context Help Window

Scalar 1D Array

Numeric

Boolean

String

Orange (floating point)Blue ( integer)

Green

Purple

2D Array

LV 17

Exercise 1

Students build Convert C to F.vi* This VI will be used in a later exercise

LV 18

Debugging Techniques

• Finding Errors

• Execution Highlighting

• Probe

Click on broken Run buttonWindow showing error appears

Click on Execution Highlighting button; data flow is animated using bubbles. Values are displayed on wires.

Right-click on wire to display probe and it shows data as it flows through wire segment

You can also select Probe tool from Tools palette and click on wire

LV 19

Debugging Techniques

• Breakpoints

• Step Into, Over, and Out buttons for Single Stepping

Click on Step Into button to enable single steppingOnce Single Stepping has begun, the button steps into nodes

Click on Step Over button to enable single stepping or to step over nodes

Click on Step Out button to step out of nodes

Select Breakpoint tool from Tools palette and click on wire or node where you want execution to pause

LV 20

Exercise

Students modify and run Debug Exercise (Main).vi(Uses Debug Exercise (Sub).vi)

LV 21

Creating a SubVI

A. What a SubVI isB. How to create the icon and connectorC. How to use a VI as a subVI

You Will Learn:

LV 22

SubVI Example – Calculating Slope

LV 23

Creating the Icon

• Right-click in the icon pane (Panel or Diagram)and select “Edit Icon…” option

LV 24

Creating the Connector

Right-click in the icon pane (Panel only)

LV 25

Creating the Connector - cont.Click

LV 26

The Connector Pane

• The terminal colors match the data types to which they are connected

• Click on the terminal to see its associated front panel object

LV 27

Exercise 2

Students build icon and connector forConvert C to F.vi

*This VI will be used in a later exercise.

LV 28

Using the VI as a SubVI

• Changes made to subVI saved in memory until saved to disk

• Calling subVIs– Functions >>Select a VI…

OR– Drag icon onto target diagram

LV 29

Help and Classifying Terminals

• Context Help for subVIs

• Classify inputs and outputs:How displayed in Context Help WindowRequired - Bold label Recommended - Normal textOptional - Visible or wire

stubs shown

LV 30

Documenting the VI• Document VIs - VI Properties>>Documentation• Document objects - Description and Tip...

VI Documentation

Description and Tip

LV 31

Exercise 3

Students build Thermometer.vi*This VI will be used in a later exercise.

LV 32

The Create SubVI Option

• Enclose area to be converted into a subVI• Select Create SubVI from the Edit Menu

LV 33

Loops and Charts

A. About While LoopsB. About waveform chartsD. About For Loops

You Will Learn:

LV 34

While Loop

Do

(Execute diagraminside Loop)

While Condition is TRUE

1. Select While Loop 2. Enclose code to be repeated

3. Drop or drag additional nodes and then wire

LV 35

Select the Loop Condition

• Right-click on Conditional Terminal to define when the loop stops

Iteration Terminal Conditional Terminal

LV 36

Waveform Charts

• Selected from the Controls >> Graph subpalette

LV 37

Customizing Charts and Graphs

• Plot Legend (color, point style, line style, etc.)• Digital Display • Scrollbar • Customize the

X and Y Axes • Graph Palette• Scale Legend

LV 38

Wiring to Charts

• Single-Plot Chart

• Multiple-Plot Chart

LV 39

Exercise 4

Students build Temperature Monitor.vi*This VI will be used in a later exercise.

LV 40

For Loop

• In Structures subpalette of Functions palette• Enclose code to be repeated and/or resize and

add nodes inside boundary• Executes diagram inside of loop a predetermined

number of times

Count terminal(Numerical input)

LV 41

Numeric Conversion

• Numeric defaults to double precision (8 bytes) or long integer (4 bytes)

• LabVIEW automatically converts to different representations

• Gray coercion dot on terminal indicates conversion

LV 42

Arrays, Graphs, and Clusters

A. About arraysB. About generating arrays with loopsC. Some basic array functionsD. What polymorphism isE. Using graphs to display data

You Will Learn:

LV 43

Arrays• Collection of data elements that are of same type• One or more dimensions, up to 2 elements per

dimension• Elements accessed by their index• First element is index 0

31

index10-element array 1.2 3.2 8.2 8.0 4.8 5.1 6.0 1.0 2.5 1.7

0 1 2 3 4 5 6 7 8 9

2D array

Five-row by seven column array of 35 elements

0 1 2 3 4 5 60 1 2 34

LV 44

Array Controls and Indicators

Add Dimension for 2D arrays

1. Select the Array Shell from the Controls palette

2. Place data object inside shell

LV 45

Creating Array Constants

1. Select Array Constant shell from the Arraysubpalette

2. Place the data object in the array shell

LV 46

Creating and Using Arrays

• Auto-Indexing –loops accumulate arrays at their boundaries

• For Loops auto index by default; While Loops do not

LV 47

Creating 2D Arrays

• Inner loop creates column elements• Outer loop stacks them into rows

LV 48

Common Array Functions

Array Size

Initialize Array

Array Subset

LV 49

The Build Array Function

Building a higher dimension array

Concatenate Inputs (default)

Appending an element

LV 50

The Index Array Function

Extracting an Element

Extracting a Row

LV 51

Polymorphism• Function inputs can be of different types• All LabVIEW arithmetic functions are polymorphic

• Run Polymorphism Example.vi

Scalar + Scalar

Array + Scalar

Combination ResultScalar

Array

Array

1 4 22

4 6 7

52

7

Array + Array 3 2 51 4 2

Array + Array 1 4 23 2 5 7

Array3 6 4

4 6 7

LV 52

Graphs• Selected from the Graph subpalette• Waveform Graph – Plot an array of numbers

against their indices• XY Graph – Plot one array against another

Plot Legend(point and

line styles)

Graph PaletteScale Legend

LV 53

Single-Plot Waveform Graphs

Uniform X axis - initial X = 0.0, delta X = 1.0

Uniform X axis - you specify point spacing

LV 54

Exercise 5

Students build Temperature Analysis.vi

LV 55

Case and Sequence Structures

A. About Case structures

B. About Sequence structures

D. How to replace Sequence structures

You Will Learn:

LV 56

Case Structures• In the Structures subpalette of Functions palette• Enclose nodes or drag them inside the structure• Stacked like a deck of cards, only one case visible

LV 57

Boolean and Numeric Cases

Note: all possible outputs of the Case structure must be wired

LV 58

Sequence Structures

• In the Structures subpalette of Functions palette• Executes diagrams sequentially, Frame 0 (0..x),

where x is the total number of frames• Stacked like a deck of cards, only one frame visible

LV 59

Sequence Locals

• Pass data from one frame to future frames• Created at the border of the Sequence structure

Sequence local created in Frame 1

Data notavailable

Data available

Recommended