41
Introduction to LabVIEW ES110

Introduction to LabVIEW ES110 Graphical programming language & Data flow LabVIEW relies on graphical symbols rather than textual language to describe

Embed Size (px)

Citation preview

Page 1: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Introduction to LabVIEWES110

Page 2: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Graphical programming language& Data flow

LabVIEW relies on graphical symbols rather than textual language to describe programming actions

The principle of dataflow, in which functions execute only after receiving the necessary data, governs execution in a straightforward manner

Page 3: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

How does LabVIEW work? LabVIEW programs are called:

Virtual Instruments (VIs) because their appearance and operation

imitate actual instruments. However, they are analogous to main

programs, functions and subroutines from popular language like C, Fortran, Pascal, …

Page 4: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Front Panel• Controls = Inputs• Indicators = Outputs

Block Diagram• Accompanying “program”

for front panel• Components “wired”

together

LabVIEW Programs Are Called Virtual Instruments (VIs)

Page 5: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

LabVIEW Introduction Two “sets” for development

Front Panel Block Diagram

Wiring connections

LabVIEW Conventions

Running LabVIEW programs

Page 6: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

LabVIEW Front Panel All user interface

goes here!

Used to display Controls or Indicators

Highly customizable

Page 7: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

LabVIEW Block Diagram Actual program

Invisible to user

Read left to right, like a book

Where the MAGIC happens!

Page 8: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

TerminalsWhen you place a control

(or indicator) on the

FRONT PANEL

LabVIEW automatically creates a correspondingcontrol (or indicator) terminal on the BLOCKDIAGRAM

Page 9: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Control? or Indicator?

Controls = Inputs from the user = Source Terminals

Indicators = Outputs to the user = Destinations

Page 10: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Manipulating Controls and Indicators

Right click on an indicator to Change to control Change format or precision

Right click on a control to Change to indicator Change mechanical action (whether to latch

open or closed, and what to use as default…)

Page 11: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Wiring Connections Wires transport data

through the block diagram

Wire color indicates variable type

A red “X” means something is wrong!

Page 12: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Wires

A LabVIEW VI is held together by wires connecting nodes

and terminals; they deliver data from one source terminal to

one or more destination terminals.

Page 13: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Broken wires

If you connect more than

one source or no source

at all to a wire,

LabVIEW DISAGREES with what

you’re doing, and thewire will appear broken

Page 14: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Messy vs. Clean Wiring

CLEAN: Easy to troubleshoot

MESSY: What is going on?

Page 15: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Basic wires used in block diagramsand corresponding types

Each wire has different style or color, depending on the data

type that flows through the wire:

Scalar 1D array 2D array Color

Floating-point number

orange

Integer number blue

Boolean green

String pink

Page 16: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

LabVIEW Conventions Front panel items

Controls and indicators

Block diagram items Program structures (loops, case structures, math, etc.)

Controls vs. Indicators Wires attach to controls on the right (give values) Wires attach to indicators on the left (receive values)

Wiring colors Wires are color coded to correspond to data types

Page 17: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Running LabVIEW Programs ALMOST ALWAYS put

your program in some sort of loop that can be stopped with a control

AVOID using the red “x” to stop your program

Page 18: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Lab. Equipment

Oscilloscope

Function Generator

Digital Voltmeter (DVM)

Universal Measuring Instruments

Signal Generator

Page 19: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Add/edit text

Wire features together tocontrol flow of data

Select a feature toedit or move

Operate a control

Probe Data(troubleshoot)

Page 20: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Insert a digital indicator or control

Insert a boolean control (button or switch)

Page 21: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Add a structure such as for, while, and case statements

Add a numericoperator (+,-,…)

File I/O

Add a booleanoperator (and, or…)

Data Acquisition

Signal analysis

Comparison

Mathematical Functions

Timing/dialog

Page 22: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe
Page 23: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Reorder objects

Run

Continuous run

PauseStop

Font ring

Alignment ring

Distribution ring

Debugging featuresmore on this later…

Page 24: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

The Run Button The Run button, which looks

like an arrow, starts VI execution when you click on it

It changes appearance when a VI is actually running.

When a VI won’t compile, the run button is broken

Page 25: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

ControlTerminals

Block Diagram Window

Front Panel Window

Indicator Terminals

Creating a VI

Page 26: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Example 1: Craps

From the functions – numeric panel insert a pair of dice

From the Controls panel insert a numeric digital indicator (on the front panel)

Use the wiring tool to connect the two (in the wiring diagram) and click the “run” button repeatedly.

Numbers from 0.00 to 1.00 should be displayed in the front panel

Page 27: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Example 1: Craps (continued)

Delete the wire Add a multiplication node and a

numeric constant to allow multiplication by 5

Add an addition node and numeric constant to allow addition of 1

Add a mathematical “Round to Nearest” node.

Make a second copy of this structure to represent a second die and wire them together through an addition node with an output to a numeric constant

This wiring diagram simulates the rollingof 2 dice and their addition to form a numberfrom 2 through 12.

Page 28: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Example 2: Analog & Digital Voltmeter (simulated signal)

Uniform noise used as simulated signal – Functions – Signal Processing – Signal Generation menu

Absolute value function from functions – numeric menu

Mean value of data series from the functions – mathematics – Probability and Statistics menu

The 250 ms wait implemented from the time and dialog menu slows the “flutter” of the meter.

Page 29: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Example 3: Reading an analog input signalRequires A/D board to implement

From the functions menu select data acquisition and then analog input. Then select either “Sample Channel” or Sample Channels”

This places the sampling icon in your wiring diagram

You then need to configure the channel(s) and wire the output to other parts of your program.

Page 30: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Example 4: Signal Analysis (continued)

Page 31: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Example 5: Creating Sub-VIs

In wiring diagram use selection tool (mouse box) to select all items to be in the SubVI.

From Edit menu select “Create SubVI”

Double click on new icon and save it as a separate VI.

Cut-and-paste it at will or insert it using “Functions – Select VI menu”

Page 32: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Section II – Elements of Typical Programs

A. Loops• While Loop• For Loop

B. Functions and SubVIs• Types of Functions• Creating Custom Functions (SubVI)• Functions Palette & Searching

C. Decision Making and File IO• Case Structure• Select (simple If statement)• File I/O

Page 33: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Loops While Loops

i terminal counts iteration Always runs at least once Runs until stop condition is

met

• For Loops– i terminal counts iterations– Run according to input N of

count terminal

While LoopWhile Loop

For LoopFor Loop

Page 34: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Drawing a Loop

1. Select the structure

2. Enclose code to be repeated

3. Drop or drag additional nodes and then wire

Page 35: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

What Types of Functions are Available? Input and Output

Signal and Data Simulation Acquire and Generate Real Signals with DAQ Instrument I/O Assistant (Serial & GPIB) ActiveX for communication with other programs

Analysis Signal Processing Statistics Advanced Math and Formulas Continuous Time Solver

Storage File I/O

Express Functions Palette

Page 36: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

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

Page 37: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

LabVIEW Functions and SubVIs operate like Functions in other languages

Function Pseudo Codefunction average (in1, in2, out){out = (in1 + in2)/2.0;}

SubVI Block Diagram

Calling Program Pseudo Codemain{average (in1, in2, pointavg)}

Calling VI Block Diagram

Page 38: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

How Do I Make Decisions in LabVIEW?1. Case Structures

2. Select

(a) (b)

(c)

Page 39: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

• Loops can accumulate arrays at their boundaries with auto-indexing

• For Loops auto-index by default

• While Loops output only the final value by default

• Right-click tunnel and enable/disable auto-indexing

Building Arrays with Loops (Auto-Indexing)

Wire becomes thicker

Wire remains the same size

Auto-Indexing Disabled

Auto-Indexing Enabled

Only one value (last iteration) is passed out of the loop

1D Array

0 1 2 3 4 5

5

Page 40: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Review of Data Types Found in LabVIEW

Page 41: Introduction to LabVIEW ES110 Graphical programming language & Data flow  LabVIEW relies on graphical symbols rather than textual language to describe

Shift Register – Access Previous Loop Data• Available at left or right border of loop structures• Right-click the border and select Add Shift Register • Right terminal stores data on completion of iteration• Left terminal provides stored data at beginning of next iteration

Before LoopBegins

First Iteration

SecondIteration

LastIteration

Value 3InitialValue