59
LV 1 Introduction to LabVIEW

Introduction to LabVIEW

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Introduction to LabVIEW

LV 1

Introduction to LabVIEW

Page 2: 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

Page 3: Introduction to LabVIEW

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

Page 4: Introduction to LabVIEW

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

Page 5: Introduction to LabVIEW

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

Page 6: Introduction to LabVIEW

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

Page 7: Introduction to LabVIEW

LV 7

Introduction to LabVIEW

You Will Learn:

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

Page 8: Introduction to LabVIEW

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

Page 9: Introduction to 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)

Page 10: Introduction to LabVIEW

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:

Page 11: Introduction to LabVIEW

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

Page 12: Introduction to LabVIEW

LV 12

Creating, Editing, & Debugging a VI

A. How to Create VIsB. How to Edit VIs

C. How to Debug VIs

You Will Learn:

Page 13: Introduction to LabVIEW

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

Page 14: Introduction to LabVIEW

LV 14

Accessing Shortcut Menus

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

display for its shortcut menu

Page 15: Introduction to LabVIEW

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

Page 16: Introduction to LabVIEW

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

Page 17: Introduction to LabVIEW

LV 17

Exercise 1

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

Page 18: Introduction to LabVIEW

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

Page 19: Introduction to LabVIEW

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

Page 20: Introduction to LabVIEW

LV 20

Exercise

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

Page 21: Introduction to LabVIEW

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:

Page 22: Introduction to LabVIEW

LV 22

SubVI Example – Calculating Slope

Page 23: Introduction to LabVIEW

LV 23

Creating the Icon

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

Page 24: Introduction to LabVIEW

LV 24

Creating the Connector

Right-click in the icon pane (Panel only)

Page 25: Introduction to LabVIEW

LV 25

Creating the Connector - cont.Click

Page 26: Introduction to LabVIEW

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

Page 27: Introduction to LabVIEW

LV 27

Exercise 2

Students build icon and connector forConvert C to F.vi

*This VI will be used in a later exercise.

Page 28: Introduction to LabVIEW

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

Page 29: Introduction to LabVIEW

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

Page 30: Introduction to LabVIEW

LV 30

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

VI Documentation

Description and Tip

Page 31: Introduction to LabVIEW

LV 31

Exercise 3

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

Page 32: Introduction to LabVIEW

LV 32

The Create SubVI Option

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

Page 33: Introduction to LabVIEW

LV 33

Loops and Charts

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

You Will Learn:

Page 34: Introduction to LabVIEW

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

Page 35: Introduction to LabVIEW

LV 35

Select the Loop Condition

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

Iteration Terminal Conditional Terminal

Page 36: Introduction to LabVIEW

LV 36

Waveform Charts

• Selected from the Controls >> Graph subpalette

Page 37: Introduction to LabVIEW

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

Page 38: Introduction to LabVIEW

LV 38

Wiring to Charts

• Single-Plot Chart

• Multiple-Plot Chart

Page 39: Introduction to LabVIEW

LV 39

Exercise 4

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

Page 40: Introduction to LabVIEW

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)

Page 41: Introduction to LabVIEW

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

Page 42: Introduction to LabVIEW

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:

Page 43: Introduction to LabVIEW

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

Page 44: Introduction to LabVIEW

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

Page 45: Introduction to LabVIEW

LV 45

Creating Array Constants

1. Select Array Constant shell from the Arraysubpalette

2. Place the data object in the array shell

Page 46: Introduction to LabVIEW

LV 46

Creating and Using Arrays

• Auto-Indexing –loops accumulate arrays at their boundaries

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

Page 47: Introduction to LabVIEW

LV 47

Creating 2D Arrays

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

Page 48: Introduction to LabVIEW

LV 48

Common Array Functions

Array Size

Initialize Array

Array Subset

Page 49: Introduction to LabVIEW

LV 49

The Build Array Function

Building a higher dimension array

Concatenate Inputs (default)

Appending an element

Page 50: Introduction to LabVIEW

LV 50

The Index Array Function

Extracting an Element

Extracting a Row

Page 51: Introduction to LabVIEW

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

Page 52: Introduction to LabVIEW

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

Page 53: Introduction to LabVIEW

LV 53

Single-Plot Waveform Graphs

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

Uniform X axis - you specify point spacing

Page 54: Introduction to LabVIEW

LV 54

Exercise 5

Students build Temperature Analysis.vi

Page 55: Introduction to LabVIEW

LV 55

Case and Sequence Structures

A. About Case structures

B. About Sequence structures

D. How to replace Sequence structures

You Will Learn:

Page 56: Introduction to LabVIEW

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

Page 57: Introduction to LabVIEW

LV 57

Boolean and Numeric Cases

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

Page 58: Introduction to LabVIEW

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

Page 59: Introduction to LabVIEW

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