Introduction to LabVIEW for Scientists and Engineers - PowerPoint PPT Presentation

1 / 89
About This Presentation
Title:

Introduction to LabVIEW for Scientists and Engineers

Description:

Change Position, Size, etc. of Front Panel Objects. Change Position of Block Diagram Objects ... Ring and Enumerated Controls are excellent for this. Save as ... – PowerPoint PPT presentation

Number of Views:112
Avg rating:3.0/5.0
Slides: 90
Provided by: bradleyw4
Category:

less

Transcript and Presenter's Notes

Title: Introduction to LabVIEW for Scientists and Engineers


1
Introduction to LabVIEWfor Scientistsand
Engineers
  • UTSI Short Course
  • Tullahoma, TN
  • November 18 - 20, 2002
  • Brad Winkleman, Ph.D.

2
Course Goals
  • Be able to construct simple LabVIEW programs
  • Acquire data with a LabVIEW program
  • Know how to continue after the course.

3
Not Course Goals
  • To become an expert LabVIEW programmer
  • To become a large project programmer
  • Computer science fundamentals

4
What is LabVIEW?
  • National Instruments Software Product
  • Software or Program Development Environment
  • Differences
  • Graphical or Icon Based
  • Dataflow

5
Why LabVIEW?
  • Things are easier
  • Development time is shorter (4 - 10)
  • Modifications are easier
  • Debugging done interactively
  • Things are better
  • Professional attributes
  • High performance functions
  • Lower Costs
  • A Standard

6
LabVIEW History
  • LabVIEW 1 - 1985 Macintosh only
  • LabVIEW 2 - Compiled still Macintosh only
  • LabVIEW 3 - The Leap - forward and backward
  • LabVIEW 4 - Undoable
  • LabVIEW 5 Network
  • LabVIEW 6i Internet and Events

7
LabVIEW Uses
  • Data Acquisition
  • Experiment Control
  • Process Control
  • Data Reduction
  • Data Presentation
  • Modeling
  • Calculation
  • Simulation
  • Internet and Intranet Communications
  • General Tasks (file manipulations, data
    translation, plotting, etc)

8
Examples
9
Crucial LabVIEW Philosophy
  • LabVIEW is the tool to solve your problems (not a
    LabVIEW standalone application).

10
Some Preliminaries
  • A LabVIEW Program is called a Virtual Instrument
    or VI
  • A VI is composed of two main parts
  • The Front Panel
  • The Block Diagram
  • Viewing, Editing, and Running from same
    environment
  • Final VI can be separated from LabVIEW, if
    necessary.

11
The Beginning - The Front Panel
  • The Front Panel is the User Interface to
    operating the LabVIEW Virtual Instrument
  • The Front Panel contains Control and Indicator
    icons
  • Program Inputs are via the Controls on the Front
    Panel
  • Results appear in Front Panel Indicators
  • VI is controlled from the Toolbar

12
A Simple Front Panel
13
Exercise - Create A Simple Front Panel
  • Open LabVIEW
  • New VI
  • Controls Palette
  • Add Digital Control
  • Save as Simple Front Panel.vi

14
Exercise - More Complex Front Panel
  • Experiment with Controls Palette
  • Add more controls
  • Save as Complex Front Panel.vi

15
A Simple Block Diagram
  • Example of the G Language

Control Survey Continued
16
Terminals
  • Terminals come in many different types
  • Shape, Color, Text tell type of terminal, I/O
  • Common types
  • Numeric - SGL, DBL, EXT
  • Text
  • Boolean
  • Type determined by Front Panel Object

17
Wires
  • Wires also come in many different types
  • Shape, Color, Text tell type of terminal
  • Common types
  • Numeric - SGL, DBL, EXT
  • Text
  • Boolean
  • Type determined by connections

18
Making Connections
  • Wires go from output to input
  • No Loops
  • Bad Wire shows as dotted
  • Wires can follow any path that is convenient

19
Exercise Create A Simple Block Diagram
  • First must have an appropriate Front Panel

20
Exercise Create A Simple Block Diagram
  • Open Diagram
  • Use Function Palette - Add Node
  • Connect with Wiring Tool
  • Save as Adder.vi

21
Exercise - Running the Adder
  • Change input values with Operate tool
  • Click Run Arrow
  • Result Indicator is Updated
  • Continuous Run
  • Generally not used
  • Useful for special situations

22
Dataflow in Action
23
Data Dependencies Determine Execution Order
  • No Dependency - No Defined Execution Order
  • Light Bulb in Tool Bar of Block Diagram Shows the
    Data Flow

24
Dependency Determined by Connections
  • Path of wire irrelevant
  • Can take many complicated routes

25
Editing in LabVIEW
Text
Operate
Scroll Window
Position/Size/Select
Shortcut
Wire
Get Color
Breakpoint
Probe
Set Color
26
Exercise - Editing
  • Change Position, Size, etc. of Front Panel
    Objects
  • Change Position of Block Diagram Objects

27
Relation Between Front Panel and Block Diagram
  • Front - User Interface
  • Block Diagram - Relationships
  • Essentially Independent With Following Exceptions
  • All Controls/Indicators on Front Panel are on
    Block Diagram as Terminals
  • Only Controls/Indicators on Front Panel are on
    Block Diagram as Terminals
  • Initial Placement of Terminals is related to
    location of Front Panel Object

28
Review of Survey
  • Virtual Instruments
  • Front Panels
  • Block Diagrams

29
Modifying Front Panel Objects
  • Easy
  • No Change required in Block Diagram
  • Enhances Interface
  • Requires LabVIEW not Application

30
Exercise - Modifying Front Panel Objects
  • Replace controls and indicator as desired
  • Block diagram unchanged
  • Program has more functionality

31
Control Survey
  • Controls Indicators
  • Numeric
  • Important category
  • Numerical Information
  • Digital Displays, Thermometers, Sliders, Meters,
    Etc.
  • Boolean
  • True / False data
  • Toggles, Pushbuttons, LED, On/Off Indicators

32
Control Survey Continued
  • String Path
  • Text controls
  • Filename controls
  • Array Cluster
  • Not really controls but modifiers
  • Array - identical controls
  • Clusters - disparate collections

33
Control Survey Continued
  • List Table
  • Fairly Specialized
  • Allow selection or displays lists
  • Graph
  • Very important
  • Charts - accumulate like strip charts
  • Graphs - waveform data
  • Specialized Graphs

34
Control Survey Continued
  • Ring Enum
  • Special Category
  • Useful for selecting Options
  • I/O
  • New Category
  • Used to identify I/O channels by logical name
  • RefNum
  • Rarely Needed
  • Intra - VI communication control

35
Control Survey Continued
  • Dialog
  • Dialog Boxes
  • Classic
  • LabVIEW 5.0 Controls
  • Similar Functionality
  • Different Appearance
  • ActiveX
  • Stuff for ActiveX Components

36
Control Survey Continued
  • Decorations
  • Aesthetics
  • Boxes, Arrows, Lines
  • No Functionality
  • Select a Control and User Control
  • Customized Control Interface
  • Browse the disk
  • Include on the controls palette

37
Exercise - Familiarization With Controls Palette
38
How to Use Controls
  • Most controls are not necessary
  • Controls are used to make Front Panel intuitive

39
Intuitive Front Panel
40
Non-Intuitive Front Panel
41
LabVIEW Conventional
  • At the User / Program level LabVIEW is a high
    level graphical language with dataflow
    programming
  • Underneath LabVIEW is built conventionally as the
    previous panel highlights
  • C, C are its underpinnings
  • LabVIEW does use various techniques such as
    multithreading to improve performance

42
Block Diagram Control Structures
  • Continuous Run of Adder
  • Gave live updates
  • Controlled by Toolbar
  • Clumsy
  • Like other languages G has Control Structures
    to simplify programming
  • While
  • For - Next
  • Case
  • Sequence (Special Control Structure)

43
While Loops
  • Diagram inside repetitively executed
  • Loop Index terminal begins at zero and increments
    once each execution
  • By default Loop terminates when control terminal
    receives a False
  • If needed loop can be made to stop on True

44
Exercise - Looping AdderFront Panel
  • Add Toggle Switch to Front Panel

45
Exercise - Looping AdderBlock Diagram
  • Surround everything with a Loop structure
  • Connect Run switch to loop terminal
  • Run from Front Panel by flipping toggle switch
    and clicking the Run arrow.
  • No need for Continuous Run arrow

46
Waveform Charts
  • Chart Display in Looping Adder acts oddly
  • Display updates very fast
  • Control changes not easily seen
  • Display is updating asynchronously
  • Not all results displayed
  • Default mode of displays
  • Display attributes can be modified to force
    synchronous update

47
For Loops
  • Diagram inside repetitively executed
  • Loop Index terminal begins at zero and increments
    once each execution
  • Executes the number of times wired to the Count
    terminal

48
Exercise - For Loop AdderFront Panel
  • Add Digital Control to Front Panel

49
Exercise - For Loop AdderBlock Diagram
  • Replace While with a For structure
  • Connect Digital Control to Count terminal
  • Run from Front Panel by setting iterations and
    clicking the Run arrow.

50
The Nature of Loops
  • Terminals can be inside or outside loop
  • Only terminals inside loop are dynamic
  • Outside terminals read once or written once
  • Loop has no memory of intermediate results
  • Inputs are the same each time through loop
  • Output is the last value calculated

51
Case Structure
  • Standard Case Structure found in C
  • Case Structure has multiple subdiagrams
  • The selector terminal determines which subdiagram
    is executed

52
Exercise - CalculatorBlock Diagram
  • Add Case Structure around Add Node
  • Create multiple cases and subdiagrams

53
Exercise - CalculatorFront Panel
  • Create a selector for the operation
  • Ring and Enumerated Controls are excellent for
    this
  • Save as Looping Calculator.vi

54
Sequence Structure - A Special Need
  • Control structure unique to LabVIEW dataflow
    programming
  • In dataflow programs data dependencies determine
    execution order
  • Some operations have no data dependency but
    require a defined order
  • Sequence structures provide a forced order to a
    series of operations

55
Sequence Structure
  • Has multiple subdiagrams
  • Subdiagrams are executed in sequence - first to
    last
  • Structure has no operational controls

56
Sequence Structure Uses
  • File I/O
  • Data Acquisition
  • Initialization
  • Termination

57
Exercise - Calculator with Save
  • Create Sequence
  • Add File I/O operations
  • Create Local Variables
  • Connect Frames
  • Connect Data to write

58
Exercise - Calculator with Save - Name
59
Exercise - Calculator with Save - Create
60
Exercise - Calculator with Save - Write
61
Exercise - Calculator with Save - Close
62
Sequences are BAD
  • Hide program elements
  • Prevent optimal scheduling
  • Can lower performance
  • Prevent Parallelism
  • Sequence local variables difficult to use
  • Dont Use Sequences

63
Exercise - Calc with Save (No-Sequence)
  • Use data dependencies to determine order
  • Create dependencies if they do not exist
  • Single frame Sequence structure is useful

64
Exercise - Calc with Save (No-Sequence - Another
Way)
  • Use data dependencies to determine order
  • Create dependencies if they do not exist

65
Event Programming
  • Similar to Case structure
  • Event Structure has multiple subdiagrams
  • Execution determined by events
  • Waits for an event to occur
  • Event programming is different than dataflow
    programming

66
Events
  • Front Panel Activity
  • Key Down
  • Key Up
  • Key Repeat
  • Mouse Down
  • Mouse Up
  • Value Changed
  • Timeout event
  • Application and VI
  • Menu Selection
  • Exiting
  • Panel Closing
  • Events must be configured

67
Event Cautions
  • Programmatic actions do not generate events
  • More than one Event structure in a loop can cause
    problems
  • Latched Boolean controls are delayed
  • Event structure waits for an event (possibly
    forever)

68
Exercise Looping Calculator with Event
Controlled Save
  • Previous Calculator only saved the last result
  • Need a Calculator that saves intermediate results
  • Add Save Control
  • Add Event Structure
  • Configure Events

69
Exercise Looping Calculator with Controlled
Save without Events
?
  • Events are not necessary for previous example
  • How else can a controlled save be implemented?

70
Tunnels
  • Tunnels are the nodes at the border of control
    structures
  • Data passes into and out of a structure through
    the Tunnel
  • A white Tunnel on a case structure means not all
    cases are wired to tunnel

71
Recycling Data in Loops
  • Cannot connect a loop output to a loop input
  • Violation of no cycle
  • Frequently needed
  • Averaging
  • Accumulation
  • Finite Differencing
  • Control
  • Creating Series

72
Shift Registers
  • Shift Registers allow recycling of data in loops
  • Created by popping - up on the border
  • Single or Multi-element
  • Uninitialized or initialized

73
Exercise - Differencing Calculator
74
LabVIEW Arrays
  • Basically the same as in other languages
  • Normally LabVIEW and Arrays mix well
  • Complicated indexing schemes can be tedious

75
Front Panel Creation of Arrays
  • Front panel array control is like a container
  • Putting a control in an array control creates an
    array of controls
  • Pop-menu adds dimensions
  • Array index order - row, column, and so forth

76
Exercise - Array Creation
  • Digital Inputs
  • Change to Outputs
  • Expand View
  • Add Dimension
  • Expand View
  • Other Arrays
  • Try to make an array of arrays

77
Polymorphism
  • LabVIEW VIs are generally polymorphic - they
    accept various types of inputs
  • Very powerful for array manipulation
  • Also handle different numeric types (integer,
    single, double)
  • Concept extendable to non-numeric data types

78
Autoindexing
  • Loop structures can autoindex at a tunnel
  • Input
  • New element is used for each execution of loop
  • Array size sets Count terminal on For Loop
  • Output
  • Elements are collected into an array
  • Arrays become one higher dimension
  • Autoindexing can be disabled
  • Very useful feature

79
Exercise - Autoindexing
  • Create Front Panel
  • Array Inputs
  • Array Output

80
Exercise - Autoindexing
  • Place Add Node
  • Surround with For Loop
  • Connect terminals
  • No need to wire Count terminal

81
Formula Node
  • Not a Control Structure
  • Easy formula calculations
  • C-like syntax

82
Exercise Calc with Formula Node
  • Create a calculating VI that uses the Formula Node

83
Clusters
  • Agglomerations of data
  • Minimize wiring
  • Useful for connections to SubVIs
  • Polymorphism adds to functionality
  • Like structures in C
  • LabVIEW has some predefined Clusters

84
Global and Local Variables
  • Dataflow constructs can be a nuisance at times
  • Data must flow for point to point
  • Wires must be connected to define the flow
  • Unwieldy and complicated diagrams can result
  • Global and Local Variables allow the
    communication of data between points without
    wires.
  • Overall it is best to avoid their use.

85
SubVI
  • Any VI can be come a SubVI in another VI
  • VIs and SubVIs are essentially the same
  • Any collection of VIs in a diagram can be grouped
    into a SubVI
  • Use SubVIs to
  • Make diagrams more readable
  • Produce modular code
  • Simplify programming chores

86
Exercise - Creating a SubVI
  • Open Looping Calculator
  • Edit VI options
  • Set Connection Pane
  • Create Icon
  • Embed SubVI in a main VI

87
Survey of Functions Palette
  • VIs are found on the Function Palette
  • VIs are grouped logically (more or less)
  • The Function Palette changes
  • Installed Options
  • New versions (way too often)
  • Due to the numerous functions a complete review
    is not possible in this course but should be
    undertaken by the student.

88
Function Survey Using Help Utilities
  • Contextual Help
  • LabVIEW Help
  • VI and Function Reference
  • LabVIEW VIs and Functions

89
The End
  • Basic Concepts have been presented
  • Controls and Functions have been reviewed
  • Rest of LabVIEW is
  • Gaining familiarity with VIs
  • Developing dataflow skill (NI offers courses)
  • Details, Details, Details
Write a Comment
User Comments (0)
About PowerShow.com