Labview Workshop Labview Workshop P P Review Session Review Session
Labview Workshop Labview Workshop P P Review Session Review Session
LabVIEWWorkshop p ReviewSession
Outline
What is LabVIEW LabVIEW VI and Toolboxes Palettes Co t o s a d d cato s Controls and Indicators Functions Graphing
5/16/2011
WhatisLabVIEW?
LabVIEW is Laboratory Virtual Instrument Engineering Workbench. Its Graphical Programming Language We will use LabVIEW for:
Simple programming tasks Data Displaying and Plotting Data Acquisition Control Systems
LabVIEWVI
Open NewVI
5/16/2011
LabVIEWVI LabVIEWVI
Each VI is composed of front panel and block diagram. Front Panel: is the graphical user interface that contains controls and indicators. Block Diagram: is the actual coding. Here you have to construct the connection wiring between the controls, indicators and other icons that represent functions and control structures. Tip: to move back-and-forth from front panel to block diagram use the shortcut crtl+E
LabVIEWVI
RightClick FrontPanel RightClick BlockDiagram
Tip:usethesearchutilitytofindanycontrol,indicatororfunctionifyouareunable toallocatethem
5/16/2011
ToolsPalette
The tools palette can be viewed from the view menu. The most common tools are indicated below.
InsertcontrolsandindicatorsintotheFront Paneltocontrolyourinputandoutputdata
5/16/2011
ControlsandIndicators
Numerical Controls/indicators: if you are working numerical data
10
5/16/2011
ControlsandIndicators
Boolean Controls/Indicators: if you are working with logical data
11
Numerical&MathConstants
12
5/16/2011
BooleanConstants
Boolean constants
13
WiringColors
Wiresarecolorcodedtocorresponddatatypes.Belowaresomeofthe mostcommondatatypesalongwiththecorrespondingcolor
14
5/16/2011
Inputvs.Output Numericalvs.Numerical
15
ControlStructures
For Loop While Loop Case structure st uctu e Sequence Structure
16
5/16/2011
ForLoop
Theforlooprepeatstheexecutionofitssubdiagramafixednumber oftimes.Numberofrepetitions(iterations)dependsontheinput terminalN.
17
ForLoop
18
5/16/2011
WhileLoop
The while loop repeats the sub diagram inside it until loop condition receives a particular Boolean value value. It can be stopped by: Boolean Button Condition
Currentiterationnumber
Bydefault,autoindexingisdisabled inwhileloops.
Loopcondition Stopiftrue
19
WhileLoopExamples
20
10
5/16/2011
CaseandSequenceStructures
Case structure: It is by default has two states, true and false. The value wired to the selector input terminal determines which case sub-diagram is going to be executed. Remember that one case is executed at a time, and the whole case structure is executed once. Unlike Looping structure which can be executed as many times as required. Sequence Structure: Consists of one or more sub-diagram or frames, which are executed sequentially.
21
FormulaNode
Perform math operations based on a numerical input. You have to identify the inputs and outputs of the equation programmed in Variable names are case sensitive You can use built in functions such as: abs, exp, sqrt Each statement must be terminated with a semicolon (;)
22
11
5/16/2011
SelectorFunctions
It its called selector because it returns at the output either: The input t if s is TRUE. The input f if s is FALSE. p
The inputs t and f should be of the same type. Both should be numerical or both should be Boolean.
23
Example1
Write a VI that tests an input number against 5. If it is greater than 5 a green LED will light, otherwise a red LED will light (Use one LED).
24
12
5/16/2011
Graphicalindicators
Chart - can be used to plot single values or arrays. Also used y to view history of the data Graph - Plot an array of numbers g against their indices XY Graph - Plot an array of numbers against another
Ayman Rabee|UAEU - ERU
25
26
13
5/16/2011
27
Example4
A stone is dropped into a deep well and is heard to hit the water 3.41 s after being dropped. Write a LabVIEW to determine the depth of the well. Solution: From Newtons law of Motion H= V0 t + at2 Given : V0 = 0 m/s Gi / t = 3.41 s a = g = 9.8 m/s2
28
14
5/16/2011
29
Example4
Write a LabVIEW VI to automatically determine the currentvoltage characteristic for a Resistor. The current-voltage characteristic of the Resistor is to be determined from 0 to 12 Volts. For quick analysis, the currentvoltage characteristic is plotted on an XY graph with no less than 24 samples. Also, note that a 500ms time delay is often required between the setting of the power supply and reading the measurement of the DMM.
30
15
5/16/2011
31
32
16