Exp Urbana
-
Upload
pavithren-nathan -
Category
Documents
-
view
217 -
download
0
Transcript of Exp Urbana
-
8/8/2019 Exp Urbana
1/16
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
U niver sit y of Illin ois at U rba na -Ch am pa ign P hysics Depa rt m en t
Advan ced Ph ysics Laborat ory
E x p e r i m e n t 3B
LabVIEWG r a p h i c a l P r o gr a m m i n g
R e f e r e n c e s
1. Lisa K. Wells, Th e LabVIEW S tudent Ed ition User's Guide, Pren tice Ha ll,En glewood Cliffs, New J ers ey (1995). [ ht tp ://www.na t ins t.com ]
2. Barry E. Pat on, S ensors, Transd ucers & LabV IEW, Pren tice Ha ll PTR,Upper Sa ddle River, New J ersey (1999). [ http://www.phptr.com]
3. National Instruments,LabVIEW - Proven Productivity (Seminar Series),1997.
4. LabVIEW ma nu als (available in th e lab for classroom u se).
LabVIEWG r a p h i c a l P r o gr a m m i n g L a n g u a g e
Gra phical progra mming is a n at ur al extension of th e way scientists
an d engineers design and commu nicat e each other. Most of th e time when a n
idea is developed, a genera l diagram is dra wn or sketched and discussed. It
is a very productive tool in designing an d quickly produces result s.
With this in mind, LabVIEW(acronym for La bora tory Virt ua l
Inst rum ent En gineering Workbench) was developed in lat e 1980s by
Na tiona l Instru ment s, Inc for desktop environmen t. It becam e popular a nd
widely accepted in scient ific an d engineering environm ent s. Similar
gra phical progra mm ing products were offered by oth er compa nies. Hewlet t-
Pa cka rds HP-VEE is another popular pa ckage.
In LabVIEWone can creat e a virt ua l inst ru ment by dra wing on th e
comput er screen. Ea ch dr awing is tra nslat ed into codes by its inter na l code
generat or so tha t it will ru n on a comput er. LabVIEWuses a graph ical
progra mm ing language called G but you do not need t o know th is langua ge to
use LabVIEW.
http://www.phptr.com/http://www.phptr.com/http://www.phptr.com/ -
8/8/2019 Exp Urbana
2/16
Physics 344 Expt 3B LabVIEW Pa ge 2/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
LabVIEWp r o g r a m st r u c t u r e
Un der its h ood, a LabVIEWprogra m is like a t ext-based program with
fun ctions a nd su brout ines but in apper an ce it functions like a virtual
instrument(VI). An inst ru ment ma y accept an input , process on it a nd t hen
out put a resu lt. Similar ly a VI behaves the same.
A VI had 3 m ain par ts: the front pan el, the block d iagram and control
and tool palettes. The front pan el is similar to the front pan el of an
instr um ent. It ma y cont ain kn obs, switches, pushbut tons, graph ic plott er
etc. Dat a is inpu t th rough the keyboar d or mouse to intera ct with th ose
virtu al componen ts (for examp le a switch could be tur ned on). The resu lt is
shown t hr ough va rious outpu t componen t of th e VI (for exam ple on a gra ph).
The front pa nel is actu ally the ma in user int erface.
The block diagr am is th e VIs equivalent of sour ce code. It it self is an
execut able program . A componen t of a block diagr am is r epresen ted by an
icon. An icon ma y be a lower -level VI, cont rol st ructu res etc. By conn ecting
th e icons wit h wir es one can contr ol th e flow of the pr ogra m.
The cont rol and t ools palett es provide a medium to const ru ct t he block
diagra m. By choosing appr opria te functions a nd t ools each segmen t of th e
block dia gra m would work
A LabVIEW progra m is modular in n at ur e. Series of sub-ta sks could
be acted upon to ru n t he desired progra m. Ea ch VI ma y be designa ted as a
sub-VI of a lar ger program an d so on t o accomplish a mu ltit udes of ta sks.
A simp le Lab VIEW VI: Exer cise #1
We will star t a simple LabVIEW progra m by designing a ra ndom
nu mber generat or a nd display the results on a graph ic screen (a strip cha rt
recorder ). Since it is more productive to follow a step by step procedur e
rat her th an wading through the man uals to star t t his software, a detailed
procedur e is provided below. Follow th em to do th is first exercise. In t he
fut ur e you sh ould consu lt t he m an ua ls (paper or on-lineHELP ) t o
un dersta nd in dividual t ools an d functions.
Note: Mak e a folder called Studen ts inside LabVIEWfolder. Inside
th is St uden ts folder, mak e your own folder with your n am e. Save all your
program s th ere. But it is alwa ys safe to keep your files on a floppy before you
go home. Floppy disks ar e available in lab.
-
8/8/2019 Exp Urbana
3/16
Physics 344 Expt 3B LabVIEW Pa ge 3/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
Step # 1. Sta rt ing LabVIEW: Double click on the La bVIEW icon on your
desktop or select from S tart >> N ational Instru m ents>> LabVI EW. Select th e
button N ew VIfrom th e dialog box. Two new pan els should app ear a long
with T ool Pa lette. The two pan els ar e Un titled 1 f ron t pa n e l and a block
d i a gr a m p a n e l. You should also see Tool Palette and Controls Palette. If
th ey ar e not visible, select Win dow >> S how T ools Palette and Window >>S how Controls Palette to see th em. Tools palette conta ins t he ba sic tools to
build VI. Fa miliar ize th ese palet tes. Left mouse click once to activat e th e
respective tool. Right mouse click will show wha t t he t ool is.
Step # 2. On th e front pan el (usua lly its n am e would, be Un titled 1). select
th e defau lt Pa lette set from t he t op Pu lldown menu Ed it >> S elect Palette S et
>> Default.
Step # 3. Since we wan t to creat e a ra ndom num ber genera tor, we need a
device to init iat e th e opera tion. We will simply use a n on-off switch to sta rt
an d stop th e operat ion. To do th is, at Controls Palette, click a t t he Boolean
subpa lett e. Then from th e ava ilable cont rols, select an d place a Vertical
Toggle Switch on t he front pan el.
St ep # 4: Type Powerinto the la bel for t he switch using th e Labeling
(Editing) tool (ma rk ed as A). If th e label is not pr esent , use S how Label from
th e pop-up menu of th e switch (right m ouse click at t he switch cont rol).
Step # 5: At th e cont rols palet te, select th e Waveform Chart (Graph) control
an d place it on th e front pan el. Label it Ra nd om Plot.
Step # 6: Our ra ndom nu mber genera tor will generat e nu mbers from 0 to
1.0. Defau lt cha rt Y-axis is from 0 to 10.0. To relabel use th e Operating tool
(Ha nd) and double click on th e 10.0 in th e Y-axis of th e cha rt . En ter 1.0.
Anoth er wa y is to open t he pop-up m enu (double click on th e cha rt ) an d select
Y Sca le >> AutoS cale Y.
Step # 7: If you do not see the block diagra m, select Win dow >> S how
Diagram . When you were placing the power switch and t he cha rt on th e
front p an el, LabVIEW put t he corr esponding icons on th e block diagr am . You
should see those two icons on your block diagr am . Position t he mouse at th e
icon a nd t hen press CONTROL-H would show descript ion of th e icon. This is
a fast way to get help on a VI.
Step # 8: Since we want to int erconn ect an d operat e on th ese items to
generat e ran dom number, open th e Functions Palette from Win dows >> S how
Functions Palette men u at t he top of th e block diagra m window. Then select
-
8/8/2019 Exp Urbana
4/16
Physics 344 Expt 3B LabVIEW Pa ge 4/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
th e Ran dom Nu mber fun ction (double dice icon) from it s N um eric >>
Ra nd om N um ber (0-1).
Step # 9: In order to sta rt a nd stop the ra ndom num ber genera tor, we need to
set up a condit ion on our s ystem . This can be done by using Wh ile Loop
(Str uctur es). The simplest way is to sta rt generat ing th e ra ndom nu mbersafter we flip the swit ch on a nd t o stop when we flipped it t o off. Select from
the Functions Palette, S tru ctures >> Wh ile Loop fun ction. Then click at th e
an y place nea r t op left corn er of th e block diagram window. Then drag th e
Wh ile Loop icon to enclose th e other icons as sh own below. If you do not see
th e oth er icons or it was n ot pr operly done, open t he pop-up m enu of the
Wh ile Loop an d select Rem ove Loop. Then redo th is step.
Figure 1. Basic ra ndom nu mber genera tor vi.
Step # 10: As in text -based progra m, th e Wh ile loop ru ns a ll codes within its
boun daries u nt il the expression on th e conditiona l input (circular ar row)becomes false. The itera tion termina l (ma rked i ) gives you t he n um ber of
tim es th e loop ha s execut ed so far. In order to mak e the conn ections, click on
the Wirin g tool (wire spool icon) from t he Tools Palette. Move th e mouse to
the Rand om Nu m berfunction icon. Wait u nt il th e fun ction begins to flash ,
th en left click on th at function. Release the butt on an d move to the Random
N um ber Plot term inal. You will be at th e termina l when the icon begins to
flash . Then click to ter min at e th e wire. In case if you see th e das hed black
line, the wire is bad. Use Edit >> Remove Bad Wire or Control-B or right
mouse click at th e wire will rem ove th e bad wires. You sh ould finish t he
wiring as sh own in th e following diagra m.
-
8/8/2019 Exp Urbana
5/16
Physics 344 Expt 3B LabVIEW Pa ge 5/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
Figur e 2. Completed block diagr am of th e random num ber vi.
Step 11: Now you have finished progra mm ing. Retur n to th e front panel
(Remember to use Windows >> Show Front Panel or clicking on the front
pan el window.)
Step 12: After selectin g th e Operating tool (Ha nd icon), click on t he p owerswitch to tur n it on. Then at th e Opera te menu on th e top (usu ally locat ed
below t he Pu lldown men u), click on Run . To clear the cha rt , use right mouse
click on t he cha rt to select Data Operation >> Clear Chart.
St ep 13: Explore th e effects ofPause, Contin uously R un , Abort Execution of
the menu.
Step 14: Save your pr ogram a t File >> S ave As an d call it Random.vi.
Timin g, An alys is an d Fi le I /O: Exer cise #2
In t his exercise we will add Random.vi with timing and at the end of
th e exercise ana lyze the dat a a nd write it t o a spr eadsheet file.
1. Open Random.vi from LabVIEW men u ba r File >> Open , if it h as n ot beenopened yet .
2. At t he front pa nel, from Controls Palette, select Nu m eric >> Kn ob and addit to th e front pan el. Label th e knob as Delay. See Figure 3.
-
8/8/2019 Exp Urbana
6/16
Physics 344 Expt 3B LabVIEW Pa ge 6/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
Figur e 3. Adding kn ob, ana lysis an d file I/O to vi.
3. Use th e operat ing tool (ma rked H an d) to cha nge th e scale on t he Delaykn ob to show a ma ximum of 500 ms.
4. To hide the n um eric indicat or t ha t displays the kn ob value, right m ouseclick t he k nob an d deselect S how >> Digital Display on its popup menu .
5. For th e block diagram , at t he Functions Palette, select Tim e & Dialog >>Wait Until N ext m s Mu ltiple an d place it inside the Wh ile Loop as sh own in
figure 4.
6. Retur n t o the front pan el and observe the effects of var ying th e delay timeon t he ra ndom num ber genera tion by runn ing the vi.
7. We would like to find out what is the mea n value of th e ran dom n um bersgenerat ed. This stat istical fun ction is available from the Functions Palettes
Analysis >> Probability an d S tatistics >> Mean .vi . It should reside out side
th e While Loop as sh own in F igure 4. Since we would like to view th e mean
value, LabVIEW provide a convenien t way to gener at e an indicator. Position
th e mouse over th e top right corn er of th e Mean function and open the popup
menu. Select Create In dicator. This will au tomat ically creat e a num ericindicator labeled mean on t he front pan el.
8. Once th e dat a a re generat ed, we would like to save them into asprea dsheet file. In t he lab we will use Microsoft Excel spreadsheet program.
-
8/8/2019 Exp Urbana
7/16
Physics 344 Expt 3B LabVIEW Pa ge 7/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
Figur e 4. Block diagra m of th eRandom.vi for t iming a na lysis and file I/O.
To crea te t he vi for F ile I/O, at th e Functions Palette, select File I/ O >> Write
to S preadsh eet File.vi. Place th is vi out side th e Wh ile Loop .
9. Wire th e block diagr am as in F igure 4 using th e wiring tool. (a) When youwire from inside of th e Wh ile Loop to th e mean vi, the wire initially be broken
(as shown by da shes). You will need t o right-mouse-click t o open t he popup
menu on t he black t unn el that appears at the intersection ofWh ile Loop and
th e wire. Select En able Ind exing . The wire will th en cha nge to a th ick
ora nge line. This procedure allows the dat a to pass as a set at th eter min at ion inst ead of fina l data point only. (b) When you place th e wirin g
tool at t he ter mina ls of the Write to S preadsh eet vi, a tip strip or input
term inal appears along with its highlight ed label. When you wire, ma ke
sur e to wire int o th e 1D Array input.
10.These steps essent ially complete the pr ogram t o ru n. Save your progra man d then from the front pan el, ru n th e program . Once th e data ar e collected
at th e end of th e session, a popup window will ask wh ere you would like to
save the dat a. Save it in th e same folder where your pr ogram r esides and
called that dat a file as mydata.txt. View th e dat a by openin gExcel program.
Note tha t t his is a t ab-limited data an d appears a s one row in Excel.Remember to save your VI before you qu it t he pr ogra m for n ext exercises.
-
8/8/2019 Exp Urbana
8/16
Physics 344 Expt 3B LabVIEW Pa ge 8/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
Debu gging in LabVIEW: Exer c i se #3
We will review a few useful techniqu es of debugging in LabVIEW. The
debugging techniques we will use are Execution Highlighting, breakpoints,
single step, and probe techniques.
1. In debu gging a vi, it is very helpful to see how th e progra m execut es.Using the Execution Highlighting butt on, ma rked as a light bulb an d locat ed
at th e block diagra m's Operate men u (usu ally locat ed at top second r ow), th e
an ima ted flow of dat a from one node to an oth er can be visua lized. It is
usu ally used in conjunction with single-step mode. Click on th is but ton and
ru n th e progra m. Observe how the dat a "bubbles" moves from one node to
an oth er. When you are done, deselect the Execution Highlighting button and
tu rn off th e Power switch off. Save your dat a in t he sam e mydata.txtfile by
overwriting it.
2. Sometimes you would like to sus pend t he execut ion of a VI and inspectth e inpu ts to the subVI while troubleshootin g. This fun ction is perform ed by
setting break points in a VI after activating the Probe. Fir st click on th e
Probe icon (a circle with P ins ide) in Tools Palette. In the block d iagram ,
position t he mouse at t he wire between t he Rand om Nu m berfun ction an d
the Chartfun ction. The wire will begin to flash . Left m ouse click on t he wire
to insert t he Probe. The Probe will be ma rked as a nu mber, such a s 1 in a
recta ngular box on t he block d iagram . To see what it does, ru n th e VI at t he
front panel . The genera ted ra ndom numbers will be displayed on t he Probe
one at a tim e. Mak e your d elay large to see its effect.
3. To set t he brea kpoint s, select t he block d iagram . Right m ouse click on th eS et/ Clear Breakpointicon on th e Tools Palette. Now, position th e mouse
pointer on th e Rand om Nu m berfunction. The Rand om Nu m berfunction willnow ha ve a red out line. Turn on th e power switch and run th e VI. The block
diagram should flash on t he Rand om Nu m berfun ction, indicat ing th at it is
rea dy to execut e.
4. To execute, left mouse click on the S tep Overbutt on (arrow on th e square)in the block d iagram's top Operate toolbar. The generat ed nu mber now
displays in th e Probe window.
5. Left mouse click on th e S tep Into (ar row int o a squa re) an d S tep Overbut tons a few more times to see how single stepp ing works. To ru n
normally, deselect the Pause button at the Operate toolbar.
6. Turn off the Power switch an d overwrite your dat a int o th e samemyda ta .txt file. Do not save an y cha nges when you quit t his exercise.
7. If you need t o trouble shoot, u se th e combina tions of above techn iques t odebug your LabVIEW application program.
-
8/8/2019 Exp Urbana
9/16
Physics 344 Expt 3B LabVIEW Pa ge 9/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
Add ing modu la r i ty to VI : Exer c i se # 4
1. In a text-based pr ogram, we r out inely use subroutines (Fortan , BASIC),procedur es (Pa scal) or fun ctions (C). Their pu rpose is to mak e th e codes clear
an d modular . Similar ly we can a dd modular ity to our VI in LabVIEW. Many
VIs could be form ed in a group to crea te a noth er VI. Also these VIs could bereu sed in oth er pr ogra ms so tha t codes can be efficient ly gener at ed, saving
tim e. In our exercise we will crea te a simple subVI for our random.vi
program.
2. Open th e random.vi progra m t ha t you ha ve creat ed earlier in exercise 2.3. In the block d iagram , select t he Position tool (Arr ow icon) at th e ToolsPalette. Then select both Mean and Write to S preadsh eet File VIs by usin g
sh ift -left mouse click. Sh ift -left mouse click is a short cut t o select severa l VIs
at t he same time.
4. At th e top Pulldown men u, select Edit >> Create Su bVI. Thisau toma tically crea tes a subVI from th e section of code you selected. The
subVI appears as a new icon in t he block d iagram . Position the mouse and
click CONTROL-H to writ e t he descript ion.
5. Double click on th e subVI to see the n ew VI in both t he front pa nel andthe block d iagram . Save this new VI as mysub.vi. Also sa ve your random.vi
as randomsub.vi.
When you create many controls and functions which are grouped together, it
is logical to group t hem a nd label it as a s ubVI. This is especially tru e with
ma ny instru ment s and complex progra ms. Make sure to write description
(rem ember t o use Contr ol-H a t t he n ew VI) of wha t you ha ve done so tha t
days or month s later you could tra ck an d cha nge things in VIs.
Dat a Acqu is i t ion Boar ds : Exer c i se # 5
Inst ead of directly manipula ting t he centr al pr ocessing unit (CPU) or
microprocessor in th e compu ter , one can u se plug-in da ta acquisition boar ds
an d data commu nicat ion bus to commu nicat e with t he CPU. This provides
flexibility in reus ing the system for ma ny differen t wa ys. In our compu ter we
ha ve a GPIB (acronym for General P urpose Interface Bus) plug-in boar d an d
a Lab-PC+ m ultipur pose dat a acquisition plug-in board.
GPIB plu g-in board a cts a s a cont roller a nd pr ovides a quick way to
comm un icat e with inst ru men ts (such a s DMM, Oscilloscope, Lock-in
am plifier, etc.) which a lready have built-in GPIB instru ment at ion. In GPI B
environm ent a n inst ru ment acts as a ta lker (send dat a), listener (receive
dat a) or cont roller (ma na ge th e GPIB). In t his lab we will genera lly use our
compu ter t o play all three roles. By assigning th e unique inst ru ment a ddress
-
8/8/2019 Exp Urbana
10/16
Physics 344 Expt 3B LabVIEW Pa ge 10/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
(an ident ifying num ber st rin g such as 22 for our la b's HP 34401A DMMs) to
th e inst ru ment s, one can comm un icat e with as ma ny as 15 instr um ents (or
more with GPIB extender s) in a daisy-cha in of instr um ents. The t ypical dat a
tr an sfer ra te of GPIB is about 1 MBytes/second. The intern at iona l stan dar d
use to implement its h ar dware a nd softwar e is based on IEE E 488 Standa rds.
Cont ra st to GPIB, Lab-PC+ is a multipur pose dat a acquisition boar d. It can
accept raw analog signal, output analog voltages and provide timing controls.
Due to its multi-purpose functions, DAQ boards are relatively expensive than
GPIB plug-in boar ds. For example, our La b-PC+ are about t wice as much
expensive th an GP IB boar ds. Lab-PC+ boar ds can convert 8 ana log signals
(each is called a cha nn el) int o digital signa ls (0 an d 5 volts) simult an eously.
In a ddition t hese boar ds ha ve 3 an alog out put s cha nn el where one can
genera te t ypically 5 volts a na log signa ls. There ar e also 8 digita l cha nn els
where one can inpu t or out put digital signals. Fina lly Lab-PC+ boar ds have
3 different channels to time signals for several timing operations such as
coun ting, event timing, pulse generat ion, frequency measurem ent, et c.
In t his exercise we will explore h ow LabVIEW configure t he GP IB an d Lab-
PC+ boar ds for dat a acquisition an d commu nicat ion.
1. Tur n off power t o th e compu ter an d DMM.2. Locat e a 2 met er long GPIB cable at t he back of th e comput er. It h as 24pin conn ectors at one end. Note th at th e connector is dua l type - one ma le
and one female.
3. Turn on power to the DMM and t hen t o th e comput er. Observe tha t t heDMM will go th rough a self-test an d display its ad dress n um ber, typically itis 22 by defau lt.
4. In the LabVIEWma in pa nel, click on th e S olution Wizards, or if you ar ein a front pan el select Project >> In strum ent W izard .
5. Select GPIB Instru ment s to search. It will ta ke a few minu tes. Whenth ere is a GPIB boar d insta lled and t he DMM conn ected, it will report it ha s
foun d HP 34401A DMM. Double check the add ress of th e DMM at th e
configura tion window before qu itt ing at finish . This procedur e will be used if
you ha ve additiona l GPIB inst ru ment s are added.
Similar ly we can configur e th e setu p for La b-PC+ by using th e Project >>
DAQ Wizard >> DAQ Ch annel Wizard. Lab-PC+ will be shown as Device 1 orDev1. Write down t his na me in your notebook for futu re progra mm ing
reference. Though it is n ot r equired to name t he chann els at t his time, it
mu st be noted th at th e nam es should be noted down in your notebook as th ey
will be required to identify th e chann els during your progra mm ing sessions
when specifying the a na log inpu t or out put cha nn els. You ma y use alt-
printscreen key combinat ion t o capt ur e th e screen display an d past e it int o
-
8/8/2019 Exp Urbana
11/16
Physics 344 Expt 3B LabVIEW Pa ge 11/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
Worddocumen t an d print it out . Once you are done with t his setu p
configur at ion, close th e windows an d quit LabVIEW.
E x p e r i m e n t wi t h GP I B : E x e r c i s e # 6
As sta ted ea rlier, GPIB is a versatile bus u seful for acquiring data from
bencht op lab instr um ents t ha t ha ve built-in GPIB int erface. In our lab we
ha ve HP34401A DMM which h as su ch a featu re a nd we will use it to
understan d th e GPIB operation.
To un dersta nd m ore about GPIB a nd its ph ysical an d ha rdwar e conn ections
see reference 1 and 2.
As a way to provide bett er commu nicat ion, th ere is a st an dar d called Virtu al
Ins tr um ent s Softwar e Architectu re (VISA) for LabVIEW. As an exercise we
will use th e built-in LabVIEW VI using VISA Exa mples. In th e next
exercise you will build your own GP IB VI to comm un icat e with th e DMM.
1. Turn on t he DMM and m ake su re it is conn ected with GPIB cable.2. Click a th e LabVIEW icon on the deskt op. Open th e following exam ple atth e front pa nel with Help >> S earch Exam ples .. >> VIS A E xam ples >>
HP34401A Getting S tarted.
3. At th e front panel observe th e cont rols. Note the current addr ess of th eHP 34401A as sh own on th e front panel . Cha nge th e VI's addr ess if it is
differen t from your rea l DMM on t he ben ch.
4. Set t he function t o 2-wire resistan ce measu rement on t he VI.5. Run th e VI and measu re the open circuit resista nce value. Does theDMM click to ma ke mea sur emen t ? Observe th e block diagra m. Use
Execution Highlight ing and tr ace th e signa l flow. If you receive error
messages, analyze an d tr oubleshoot. Usua lly if th e address is not set
properly, error messages would reveal tha t t he GPIB instr um ent is not
responding.
6. Att ach some resistan ce to th e DMM input (use t he bench r esistor box) an dmeasu re th e resistan ces. To cha nge the pr ecision of th e display, right mouse
click on the front panel at t he display tha t shows th e measured value. Select
Forma t and Precision to cha nge th e precision.
7. Set your function genera tor t o ~ 1 Volt peak to peak, 1 kHz sine wa ve.Chan ge the function t o AC Voltage on t he front pan el to measu re. Chan ge
th e fun ction t o Fr equency and observe the measu red values. Can you
impr ove th e precision t o 7.5 digit a s a gainst 6.5 digit offered by t he DMM ? It
mean s your consecut ive measu remen ts m ust be fairly identical, assu ming th e
waveform is sta ble.
-
8/8/2019 Exp Urbana
12/16
Physics 344 Expt 3B LabVIEW Pa ge 12/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
8. To get back to man ua l contr ol of th e DMM, press a t blue Shi f t key on t heDMM pan el (locat ed at Local label).
Do not sa ve cha nges when you qu it LabVIEW.
Bui ld you r own GP IB VI us in g LabVIEW: Exer c i se # 7
To comm un icat e with HP 34401A DMM, you can simply build your own
GPIB VI. GPIB fun ctions are accessible at t he block d iagram from Functions
Palette >> In strum ent I/ O >> GPIB . Do not use GPIB 488.2 at t his time.
The typical procedure would be to inst ru ct t he instr umen t t o read a value by
issuing a comma nd (such as Read th e AC Voltage). Since th is comma nd is
comin g from th e cont roller in to the ins tr um ent , we call it a write operation.
The next step is to read th e value sent back by th e inst ru ment . In th is case
th e instru ment is writing but th e cont roller is reading. Therefore it is called
the readoperation.
In order t o implement th e first st ep, it is required t o input into the GPIB-
Writ e fun ct ion the following 3 item s: (1) addr ess st rin g (typically 22), (2)
mode nu mer ic nu mber (typically 0), (3) comm an d st rin g (such a s
Meas:Volt:DC? to meas ur e DC Volt). Once the cont roller sen ds (or writes)
th is informa tion t o DMM, DMM will acknowledge an d retu rn th e dat a st ring
back to th e cont roller. We ha ve to inst ru ct th e cont roller to read this
retu rn ed string. There are 2 inputs at least required: (1) th e number of bytes
to rea d (typically not more t ha n 20 bytes), and (2) mode (= 0). Since errorsma y occur in write a nd r ead opera tions, err or outpu t from GPIB Write
should be conn ected to err or inpu t of GPIB Read. You ma y rea d the err or
str ing and sta tu s out put if you wan t t o explore fur th er more. A typical VI is
shown in Figure 5. A cha rt is not required but added to check th e measur ed
dat a. Note th at t o convert th e measu red data st ring int o nu meric values
(such a s to plot on a cha rt ), you will need th e S tring >> Ad ditional S tring to
N um ber Fun ction >> From Exponential/ Frac/ En g (or EFG funct ion) from
Functions Palette.
This is left a s an exercise to pra ctice. Test your VI with va rious DMM
fun ctions, including resista nce an d frequ ency. Deta ils of th e HP 34401A
comm an ds ar e in HP 34401A DMM User Manu al sta rt ing from page 104,
Rem ote In terface Reference. These comma nds ar e par t ofStandard
Com m ands for Program m able Instrum ents (S CPI) comm an ds. A short
intr oduction t o SCPI is a lso given in HP DMM user m an ua l page 154.
Save your VI in a file for your n ext experimen ts.
-
8/8/2019 Exp Urbana
13/16
Physics 344 Expt 3B LabVIEW Pa ge 13/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
Figur e 5. Fr ont pan el and block diagra m of a simple GPI B VI of Exercise # 7.
Dat a Acqu is i t ion wi th Lab -P C+: Exer c i se # 8
As an int roduction t o dat a a cquisition we will use a n exam ple provided inLabVIEW packa ge to sa ve tim e in building VI. Most of th e tim e you will
need t o convert a na log signa l into digita l signa l so th at your program s could
ma nipulat e to get desired results. Since Lab-PC+ ha s 8 single-ended
cha nn els, we may n eed to specify which cha nn el we would like t o conn ect our
signal source. This can be done by selectin g Project >> DAQ W izard >> DAQ
Channel Wizard. You will need to na me th e cha nn el with New tab in the
-
8/8/2019 Exp Urbana
14/16
Physics 344 Expt 3B LabVIEW Pa ge 14/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
Channel Wizarddialog window. Make sur e to write it down t he new cha nn el
na me in your notebook so th at you could specify it lat er on VI. A typical
configur at ion ta ble will look like in Figur e 5.
In order t o prevent dam age to the expensive Lab-PC+ boar d th ere is an
extension board on t he lab ben ch wher e 3 fun ctions of Lab-PC+ ar e groupedint o 3 separ at e conn ectors. The deta iled diagra m of th e conn ections ar e given
at t he end of th is ha ndout. Make sure you un dersta nd which conn ection is
for what function. Consu lt with your TA if you are not sur e. Note th at a ll
th e even n um ber pins a re grounded at th is bench pr otective conn ector boar d.
Ana log inpu t chann el #0 is pin # 17 at t his boar d.
1. Open your Random.vi file from E xercise # 2.2. We would like to replace th e ran dom n um ber generat or with th e ana loginput signal. At th e block diagram, right m ouse click at th e random num ber
genera tor function. At t he pop-up m enu s elect Replace >> Data Acquisition
>> Ana log Input >> AI Sam ple Chan nel.vi. Mak e sur e you do not select AI
Sample Channels .vi
Figur e 6. A typical DAQ Cha nn el Wizard configur at ion dia log window.
3. Select th e wiring tool at th e Tools Palette and point at t he channel (0)term inal st rip of th e replaced AI Sample Channel.vi. At the termina ls's tip
str ip, right mouse click for t he pop-up men u. Select Create Constan tand t ype
in exactly like th e cha nn el nam e (for exam ple in Figur e 5 it is Mywave1 .)
-
8/8/2019 Exp Urbana
15/16
-
8/8/2019 Exp Urbana
16/16
Physics 344 Expt 3B LabVIEW Pa ge 16/16 Physics Departm ent, UIUC
Revised 9 1999
Copyright 1999 The Board of Tru ste es of th e Univer sity of Illinois. All right s reser ved
The pr otective circuit in sta lled on t he bench for t he La b-PC+ DAQ boar d.
Note tha t th e even pins at your conn ectors ar e conn ected t ogether t o ground.