introduction to labview - elfit.ssru.ac.th · labview programs are called virtual instruments...

32
Introduction to LabVIEW

Upload: others

Post on 19-Mar-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

Introduction to LabVIEW

Page 2: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

Front Panel• Controls = Inputs• Indicators = Outputs

Block Diagram• Accompanying “program”

for front panel• Components “wired”

together

LabVIEW Programs Are Called Virtual Instruments (VIs)

Presenter
Presentation Notes
LabVIEW programs are called virtual instruments (VIs). Stress that controls equal inputs, indicators equal outputs. Each VI contains three main parts: Front Panel – How the user interacts with the VI. Block Diagram – The code that controls the program. Icon/Connector – Means of connecting a VI to other VIs. The Front Panel is used to interact with the user when the program is running. Users can control the program, change inputs, and see data updated in real time. Stress that controls are used for inputs- adjusting a slide control to set an alarm value, turning a switch on or off, or stopping a program. Indicators are used as outputs. Thermometers, lights, and other indicators indicate values from the program. These may include data, program states, and other information. Every front panel control or indicator has a corresponding terminal on the block diagram. When a VI is run, values from controls flow through the block diagram, where they are used in the functions on the diagram, and the results are passed into other functions or indicators.
Page 5: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

LabVIEW Introduction Two “sets” for development Front Panel Block Diagram

Wiring connections

LabVIEW Conventions

Running LabVIEW programs

Page 6: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

LabVIEW Front Panel All user interface

goes here!

Used to display Controls or Indicators

Highly customizable

Page 7: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

LabVIEW Block Diagram Actual program

Invisible to user

Read left to right, like a book

Where the MAGIC happens!

Page 8: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

TerminalsWhen you place a

control(or indicator) on the FRONT PANEL

LabVIEW automatically

creates a corresponding

control (or indicator) terminal on the

BLOCK

Page 9: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

Control? or Indicator?

Controls = Inputs from the user = Source Terminals

Indicators = Outputs to the user = Destinations

Page 10: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

Broken wiresIf you connect more than

one source or no sourceat all to a wire,

LabVIEW DISAGREES with what

you’re doing, and thewire will appear broken

Page 14: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

Messy vs. Clean Wiring

CLEAN: Easy to troubleshoot

MESSY: What is going on?

Page 15: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

Basic wires used in block diagramsand corresponding typesEach wire has different style or color, depending on the data type that flows through the wire:

Scalar 1D array 2D array ColorFloating-point number

orange

Integer number blue

Boolean green

String pink

Page 16: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

Lab. Equipment

Oscilloscope

Function Generator

Digital Voltmeter (DVM)

Universal Measuring Instruments

Signal Generator

Page 19: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

Insert a digital indicator or control

Insert a boolean control (button or switch)

Page 21: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each
Page 23: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

Reorder objects

Run

Continuous run

PauseStop

Font ring

Alignment ring

Distribution ring

Debugging featuresmore on this later…

Page 24: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

Examples

Page 26: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

ControlTerminals

Block Diagram Window

Front Panel Window

Indicator Terminals

Creating a VI

Presenter
Presentation Notes
When you create an object on the Front Panel, a terminal will be created on the Block Diagram. These terminals give you access to the Front Panel objects from the Block Diagram code. Each terminal contains useful information about the Front Panel object it corresponds to. For example, the color and symbols provide the data type. Double-precision, floating point numbers are represented with orange terminals and the letters DBL. Boolean terminals are green with TF lettering. In general, orange terminals should wire to orange terminals, green to green, and so on. This is not a hard-and-fast rule; LabVIEW will allow a user to connect a blue terminal (integer value) to an orange terminal (fractional value), for example. But in most cases, look for a match in colors. Controls have an arrow on the right side and have a thick border. Indicators have an arrow on the left and a thin border. Logic rules apply to wiring in LabVIEW: Each wire must have one (but only one) source (or control), and each wire may have multiple destinations (or indicators). The program in this slide takes data from A and B and passes the values to both an Add function and a subtract function. The results are displayed on the appropriate indicators.
Page 27: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 28: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 29: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 30: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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 31: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

Example 4: Signal Analysis (continued)

Page 32: Introduction to Labview - elfit.ssru.ac.th · LabVIEW programs are called virtual instruments \⠀嘀䤀猀尩.\爀屲Stress that controls equal inputs, indicators equal outputs.\爀屲Each

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”