Download - Lab Lecture3 Intro to LabView
-
8/7/2019 Lab Lecture3 Intro to LabView
1/41
MCEN 371 Mechanical Engineering Lab
Chapter 6:Chapter 6:
LabVIEWLabVIEW
Part 1: Introduction
-
8/7/2019 Lab Lecture3 Intro to LabView
2/41
MCEN 371 Mechanical Engineering Lab
Obje ctiv esObje ctiv es What i s Data Acqui sition and Why use it?
Overview of La bVIEW Develop an id ea of what La bVIEW r eally is Learn what grap hica l programming languag e and
dataf low mean Get a f eel for t he La bVIEW environm ent
Learning VI programming t hroug h examp le
-
8/7/2019 Lab Lecture3 Intro to LabView
3/41
MCEN 371 Mechanical Engineering Lab
Wh at is Data Acqui sition and Why use it? Traditiona l Ex periments signa ls from sensor s ar e sent to
ana log or digita l meter s, r ead by the ex perimenter , andr ecord ed by handIn automat ed data acqui sition systems the sensor s tran smit avoltag e or curr ent signa l dir ectly to a comput er via a dataacqui sition board.
Softwar e such as La bVIEW contro ls the acqui sition and
proc ess ing of such data The benefits of automat ed sys tems ar e man y:
Improv ed accurac y of r ecording Incr eased fr equency with wh ich measur ements can be tak en Potentia l to automat e pr e and po st proc ess ing and build in qua lity contro l
-
8/7/2019 Lab Lecture3 Intro to LabView
4/41
MCEN 371 Mechanical Engineering Lab
Overview of La bVIEW
La bVIEW La borator y Virtua l Instrum entEngin eering Work bench
Grap hica l programming languag e that a llows for
instrum ent contro l, data acqui sition , and pr e/ po st proc ess ing of acquir ed data
-
8/7/2019 Lab Lecture3 Intro to LabView
5/41
MCEN 371 Mechanical Engineering Lab
Graphica l programming languag e& Data f low
La bVIEW r elies on grap hica l sym bols rather thantex tua l languag e to d escri be programming action s
The princip le of dataf low, in wh ich function s exe cute on ly after r eceiving t he necessar y data , gov erns exe cution in a straig htfor ward mann er.
-
8/7/2019 Lab Lecture3 Intro to LabView
6/41
MCEN 371 Mechanical Engineering Lab
H ow does La bVIEW work?
La bVIEW program s ar e ca lled:
Virtual Instruments (VIs) becau se the ir app ear ence and op eration imitat e actua l instrum ents.
H owever , they ar e ana logou s to main program s, function s and su broutin es from popu lar languag e lik e C, Fortran , Pasca l,
-
8/7/2019 Lab Lecture3 Intro to LabView
7/41
MCEN 371 Mechanical Engineering Lab
What does a VI look like?
-
8/7/2019 Lab Lecture3 Intro to LabView
8/41
MCEN 371 Mechanical Engineering Lab
In La bVIEW you can cr eate or u se virtua l instrum ents (VI) for
data acqui sition. A VI a llows your comput er scr een to act a s anactua l la borator y instrum ent with charact eristics tai lor ed to your
particu lar needs.
You can a lso u se built-in examp les, or u se standard t emplates
for setting up your data acqui sition input c hann els .
-
8/7/2019 Lab Lecture3 Intro to LabView
9/41
MCEN 371 Mechanical Engineering Lab
A VI has thr ee main part s:1. T he front panel:
an interactiv e user int erfac e of a VI, so nam ed becau se itcan simu lates the front pan el of a p hys ica l instrum ent.
2. T he block (or wiring) diagram:It is the VIs sourc e cod e, con struct ed in La bVIEWs grap hica l programming languag e, G. It i s the actua l
exe cuta ble program .Su broutin e in the block diagram of VI.
3. Icon/connector
-
8/7/2019 Lab Lecture3 Intro to LabView
10/41
MCEN 371 Mechanical Engineering Lab
Chapter 6:Chapter 6:
LabVIEWLabVIEW
Part 2: The La bVIEW Environm ent
-
8/7/2019 Lab Lecture3 Intro to LabView
11/41
MCEN 371 Mechanical Engineering Lab
O bjectivesO bjectivesLearn how the thr ee main part s of t he La bVIEW environm ent the f ront panel , block diagram , and
icon/connector work tog ether.Learn t he diff er ence betwee n controls andindicators & Be a ble to r ecogniz e the ir block diagram terminals .
Learn a bout t he capa bilities and u ses of t he toolbar , tools palette , controls palette , f unctions
palette , and subpalettes .
-
8/7/2019 Lab Lecture3 Intro to LabView
12/41
MCEN 371 Mechanical Engineering Lab
Front Pan elsSimp ly put , the f ront panel is the windo w throug h wh ich
the user int eract s with the program .
When you run a VI, you mu sthave the front pan el open sothat you can input data to t he exe cuting program.
The front pan el is whe r e yousee your program s output.
-
8/7/2019 Lab Lecture3 Intro to LabView
13/41
MCEN 371 Mechanical Engineering Lab
Compon ents of a front pan el:
The f ront panel is primari ly acombination o f controls and indicators .
-
8/7/2019 Lab Lecture3 Intro to LabView
14/41
MCEN 371 Mechanical Engineering Lab
Contro l? or Indicator?
Controls = Input s from t he user = Sourc e Termina ls
Indicators = Output s to t he user = D estination s
-
8/7/2019 Lab Lecture3 Intro to LabView
15/41
MCEN 371 Mechanical Engineering Lab
M anipu lating Contro ls and Indicator s
R ight c lick on an indicator to Chang e to contro l Chang e format or pr ecision
R ight c lick on a contro l to
Chang e to indicator Chang e mechanica l action ( whe ther to latch open
or c losed, and what to u se as defau lt)
-
8/7/2019 Lab Lecture3 Intro to LabView
16/41
MCEN 371 Mechanical Engineering Lab
Block Diagram sThe block diagram windo w holds the grap hica l sourc e
cod e of a La bVIEW VI it is the actua l exe cuta ble cod e
You con struct t he block diagram by wiring tog ether o bjects that p erform s pecific
function s. The variou s compon ents of a
block diagram ar e terminals , nodes and w ires.
-
8/7/2019 Lab Lecture3 Intro to LabView
17/41
MCEN 371 Mechanical Engineering Lab
Te rmina lsWhe n you p lace a control (or indicator ) on t he
FRONT PA NEL
La bVIEW automatica lly
cr eates a corr es pondingcontrol (or indicator )terminal on t he BL OCK DIA GR AM
-
8/7/2019 Lab Lecture3 Intro to LabView
18/41
MCEN 371 Mechanical Engineering Lab
Contro l or Indicator Te rmina l?
Control terminals havethick bord er s
Indicator terminals havethin bord er s
-
8/7/2019 Lab Lecture3 Intro to LabView
19/41
MCEN 371 Mechanical Engineering Lab
Dele ting B lock Diagram Te rmina ls
By defau lt, you cannot d ele te a block diagram t ermina l that belong s to a control (or indicator ).
The terminal disapp ear s only whe n you d ele te its corr es ponding control (or indicator ) on t he FRONT PA NEL.
-
8/7/2019 Lab Lecture3 Intro to LabView
20/41
MCEN 371 Mechanical Engineering Lab
Nodes Node is just a fanc y word for a program exe cution element Nodes ar e ana logou s to statements, operators, f unctions and
subroutines in standard programming languag e: The add and subtract functions r e pr ese nt on e type of node .
A structure is an ot her ty pe of node . Structur es can exe cut e cod e r e peatedly or conditiona lly, simi lar to loop s and ca se
statements in traditiona l programming languag es.La bVIEW has also s pecia l nodes , called formula nodes , wh ich ar e useful for evaluating mat hematica l formu las or ex pr ess ion s.
-
8/7/2019 Lab Lecture3 Intro to LabView
21/41
MCEN 371 Mechanical Engineering Lab
Wir es
A La bVIEW VI is hel d tog ether by wires conn ecting nod es and t ermina ls; they deliver data from on e sourc e termina l toone or mor e destination t ermina ls.
-
8/7/2019 Lab Lecture3 Intro to LabView
22/41
MCEN 371 Mechanical Engineering Lab
Basic wir es used in block diagram sand corr es ponding t y pes
Eac h wir e has diff er ent style or co lor , de pending on t he data
ty pe that f lows throug h the wir e:Scalar 1D arra y 2D arra y Color
Floating-pointnum ber
orang e
Integer num ber blue
Boo lean gr een
String pink
-
8/7/2019 Lab Lecture3 Intro to LabView
23/41
MCEN 371 Mechanical Engineering Lab
Brok en wir esIf you conn ect mor e than
one sourc e or no sourc e
at a ll to a wir e,
La bVIEW DISAGR EES with what
your e doing , and t hewire will app ear broken
-
8/7/2019 Lab Lecture3 Intro to LabView
24/41
MCEN 371 Mechanical Engineering Lab
Compon ents of a block diagram Review !
Nodes : program exe cution
elementsTerminals : Port s throug h wh ich data pa sses betwee n the block diagram and t he front pan el and betwee n nod es of t he block diagramWires : Data pat hs be twee ntermina ls
-
8/7/2019 Lab Lecture3 Intro to LabView
25/41
MCEN 371 Mechanical Engineering Lab
Dataf low Programming Goingwith the f low
Stated simp ly, a nod e exe cut es on ly whe n dataarriv es at a ll its input t ermina ls; the nod es supp lies data to a ll of it s output t ermina ls whe n it fini shes exe cuting ; and t he data pa ss imm ediat ely from sourc e todestination t ermina ls.
-
8/7/2019 Lab Lecture3 Intro to LabView
26/41
MCEN 371 Mechanical Engineering Lab
Icon s and Conn ector s
The icon is the grap hica l
r e pr ese ntation of t he VIin the block diagram.
&
the connector defines the input s and output s
more on this later
The icons and connectors s pecif y the pathw ays for data to f low into and out of VIs.
-
8/7/2019 Lab Lecture3 Intro to LabView
27/41
MCEN 371 Mechanical Engineering Lab
Front Pan el & Wiring Diagram.It is often hel pfu l to vi ew both simultaneously using t he Windo ws-Tile Left and R ight command from t he pull down menu.A new (empt y) VI is shown below with the k ey pull-down m enu
pallets visi ble.
-
8/7/2019 Lab Lecture3 Intro to LabView
28/41
MCEN 371 Mechanical Engineering Lab
Modif ying a VI
Only one of t he two windo ws (front pan el or wiring diagram)is activ e at an y point in tim e. To activat e one simp ly mov e the mou se over it and c lick a mou se button.
To di s play any of the pallets (too ls, contro ls, or function s)you can u se the Windo ws pull down m enu or simp ly left or right click your mou se.
When you fir st pu ll up a pa llet an imag e of a pu sh pin i s dis played in t he upp er left hand corn er. C lick on it to k ee p the
pa llet continuou sly dis played.
-
8/7/2019 Lab Lecture3 Intro to LabView
29/41
MCEN 371 Mechanical Engineering Lab
Add /edit t ext
Wir e f eatur es tog ether tocontro l f low of data
Sele ct a f eatur e toedit or mov e
O perate a contro l
Pro be Data(trou blesh oot)
-
8/7/2019 Lab Lecture3 Intro to LabView
30/41
MCEN 371 Mechanical Engineering Lab
Insert a digita l indicator or contro l
Insert a boolean contro l
( button or switch)
-
8/7/2019 Lab Lecture3 Intro to LabView
31/41
MCEN 371 Mechanical Engineering Lab
Add a structur e such as for , wh ile, and ca se statements
Add a num ericoperator (+ ,-,)
File I/O
Add a booleanoperator (and , or)
Data Acqui sition
Signa l ana lysis
Compari son
M athematica l Function s
Timing /dia log
-
8/7/2019 Lab Lecture3 Intro to LabView
32/41
MCEN 371 Mechanical Engineering Lab
-
8/7/2019 Lab Lecture3 Intro to LabView
33/41
MCEN 371 Mechanical Engineering Lab
Reord er o bjects
R un
Continuou s run
Pau seStop
Font ring
Alignm ent ring
Distri bution ring
Debugging f eatur esmore on this later
-
8/7/2019 Lab Lecture3 Intro to LabView
34/41
-
8/7/2019 Lab Lecture3 Intro to LabView
35/41
MCEN 371 Mechanical Engineering Lab
Chapter 6:Chapter 6:
LabVIEWLabVIEW
Part 3: E xamp les
-
8/7/2019 Lab Lecture3 Intro to LabView
36/41
MCEN 371 Mechanical Engineering Lab
Examp le 1: Crap s
From t he function s num eric pan el insert a pair of dic eFrom t he Contro ls pan el insert a
num eric digita l indicator (on t he front pan el) Use the wiring too l to conn ect
the two (in t he wiring diagram)and c lick t he run buttonr e peatedly.
Num ber s from 0.00 to 1.00should be dis played in t he front
pan el
-
8/7/2019 Lab Lecture3 Intro to LabView
37/41
MCEN 371 Mechanical Engineering Lab
Examp le 1: Crap s (continu ed)
Dele te the wir eAdd a mu ltiplication nod e and anum eric con stant to a llow multip lication by 5
Add an addition nod e andnum eric con stant to a llow addition of 1Add a mat hematica l R ound to Near est nod e.M ak e a second cop y of t his structur e to r e pr ese nt a seconddie and wir e them tog ether throug h an addition nod e with anoutput to a num eric con stant
This wiring diagram simu lates the rollingof 2 dic e and t heir addition to form a num ber
from 2 t hroug h 12.
-
8/7/2019 Lab Lecture3 Intro to LabView
38/41
MCEN 371 Mechanical Engineering Lab
Examp le 2: Ana log & Digita l
Voltmeter (simulated signal)
Uniform noi se used as simu latedsigna l Function s Signa l
Proc ess ing Signa l GenerationmenuA bsolute value function fromfunction s num eric m enuM ean va lue of data series fromthe function s mat hematic s Pro ba bility and Stati stics menu
The 250 m s wait imp lementedfrom t he time and dia log m enuslows the f lutter of t he meter.
-
8/7/2019 Lab Lecture3 Intro to LabView
39/41
MCEN 371 Mechanical Engineering Lab
Examp le 3: Reading an ana log input signa l Requires A/D board to implement
From t he function s menu sele ctdata acqui sition and t hen ana log
input. The n sele ct either Samp le Chann el or Samp le Chann els
This places the samp ling icon inyour wiring diagram
You t hen need to configur e the chann el(s) and wir e the output toother part s of your program.
-
8/7/2019 Lab Lecture3 Intro to LabView
40/41
MCEN 371 Mechanical Engineering Lab
Examp le 4: Signa l Ana lys is (continu ed)
-
8/7/2019 Lab Lecture3 Intro to LabView
41/41
MCEN 371 Mechanical Engineering Lab
Examp le 5: Cr eating Su b-VIsIn wiring diagram u se sele ction too l (mou se box) to sele ct a ll items to be in t he
Su bVI.From Edit m enusele ct Cr eate Su bVIDou ble click on n ew icon and save it a s ase parat e VI.Cut-and-pa ste it atwill or in sert it u singFunction s SelectVI menu