You are on page 1of 30

CONCORDIAUNIVERSITY

DepartmentofMechanicalandIndustrialEngineering

MECH373
INSTRUMENTATIONANDMEASUREMENTLABORATORY

Fundamentalsof

LabVIEW

1.IntroductiontoLabVIEW

LabVIEW (Laboratory Virtual Instrument Engineering Workbench) is a graphical


programminglanguagethatusesiconsinsteadoflinesoftexttocreateapplications.In
contrasttotextbasedprogramminglanguages,whereinstructionsdeterminetheorder
of program execution, LabVIEW uses dataflow programming, where the flow of data
throughthenodesontheblockdiagramdeterminestheexecution.

In LabVIEW, you build a user interface, or front panel, with controls and indicators.
Controls are knobs, push buttons, dials, and other input mechanisms. Indicators are
graphs,LEDs,andotheroutputdisplays.Afteryoubuildtheuserinterface,youaddcode
using Virtual Instruments (VIs) and structures to control the front panel objects. The
block diagram contains this code. In some ways, the block diagram resembles a
flowchart. You can use LabVIEW to communicate with hardware such as data
acquisition,vision,andmotioncontroldevices.

2.VirtualInstruments(VIs)

LabVIEWprogramsarecalledVirtualInstruments,orVIs,becausetheirappearanceand
operationimitatephysicalinstruments,suchasoscilloscopesandmultimeters.LabVIEW
contains a comprehensive set of tools for acquiring, analyzing, displaying, and storing
data,aswellastoolstohelpyoutroubleshootyourcode.

2.1PartsofaVI

AVIcontainsthefollowingthreecomponents:
FrontpanelServesastheuserinterface.
BlockdiagramContainsthegraphicalsourcecodethatdefinesthefunctionalityof
theVI.
IconandconnectorpaneIdentifiestheinterfacetotheVIsothatyoucanusetheVI
inanotherVI.AVIwithinanotherVIiscalledasubVI.AsubVIcorrespondstoa
subroutineintextbasedprogramminglanguages.

2.1.1FrontPanelWindow

The front panel is the user interface of the VI. The following Figure 2.1 shows an
exampleofafrontpanel.

Figure2.1:FrontPanelofaVI

The front panel can be built using controls and indicators, which are the interactive
input and output terminals of the VI, respectively. Controls are knobs, push buttons,
dials, and other input mechanisms. Indicators are graphs, LEDs, and other output
displays.Controlssimulateinstrumentinputmechanismsandsupplydatatotheblock
diagramoftheVI.Indicatorssimulateinstrumentoutputmechanismsanddisplaydata
theblockdiagramacquiresorgenerates.

2.1.2BlockDiagramWindow

After the front panel is built, code can be added using graphical representations of
functions to control the front panel objects. The block diagram contains this graphical
sourcecode,alsoknownasGcodeorblockdiagramcode.Frontpanelobjectsappearas
terminalsontheblockdiagram.

Figure2.2:BlockdiagramofaVI

Figure2.3:FrontPanelandBlockDiagramofaVI

The VI in Figure 2.3 contains several primary block diagram objectsterminals,


functions,andwires.

2.1.2.1Terminals
The terminals represent the data type of the control or indicator. You can configure
frontpanelcontrolsorindicatorstoappearasiconordatatypeterminalsontheblock
diagram.Bydefault,frontpanelobjectsappearasiconterminals.Forexample,aknob
iconterminal,shownasfollows,representsaknobonthefrontpanel.

The DBL at the bottom of the terminal represents a data type of doubleprecision,
floatingpointnumeric.ADBLterminal,shownasfollows,representsadoubleprecision,
floatingpointnumericcontrol.


Terminalsareentryandexitportsthatexchangeinformationbetweenthefrontpanel
andblockdiagram.Datayouenterintothefrontpanelcontrolsentertheblockdiagram
through the control terminals. The data then enter the Add and Subtract functions.
When the Add and Subtract functions complete their calculations, they produce new
data values. The data values flow to the indicator terminals, where they update the
frontpanelindicators(Figure2.3).

2.1.2.2Wires
You transfer data among block diagram objects through wires. In Figure 2.3, wires
connect the control and indicator terminals to the Add and Subtract functions. Each
wirehasasingledatasource,butyoucanwireittomanyVIsandfunctionsthatread
the data. Wires are different colors, styles, and thicknesses, depending on their data
types.AbrokenwireappearsasadashedblacklinewitharedXinthemiddle.Broken
wires occur for a variety of reasons, such as when you try to wire two objects with
incompatibledatatypes.

2.1.2.3Structures
Structuresaregraphicalrepresentationsoftheloopsandcasestatementsoftextbased
programminglanguages.Usestructuresontheblockdiagramtorepeatblocksofcode
andtoexecutecodeconditionallyorinaspecificorder.

2.1.3IconandConnectorPane

IconandconnectorpaneidentifiestheVIsothatyoucanusetheVIinanotherVI.AVI
withinanotherVIiscalledasubVI.AsubVIcorrespondstoasubroutineintextbased
programminglanguages.EveryVIdisplaysanicon,suchastheoneshownasfollows,in
theupperrightcornerofthefrontpanelandblockdiagramwindows.

An icon is a graphical representation of a VI. It can contain text, images, or a


combinationofboth.IfyouuseaVIasasubVI,theiconidentifiesthesubVIontheblock
diagramoftheVI.Youcandoubleclicktheicontocustomizeoreditit.

Youalsoneedtobuildaconnectorpane,shownasfollows,tousetheVIasasubVI.

Theconnectorpaneisasetofterminalsthatcorrespondtothecontrolsandindicators
of that VI, similar to the parameter list of a function call in textbased programming
languages.TheconnectorpanedefinestheinputsandoutputsyoucanwiretotheVIso
you can use it as a subVI. A connector pane receives data at its input terminals and
passesthedatatotheblockdiagramcodethroughthefrontpanelcontrolsandreceives
theresultsatitsoutputterminalsfromthefrontpanelindicators.

2.2ControlsPalette

TheControlspaletteisavailableonlyonthefrontpanel.TheControlspalettecontains
the controls and indicators you use to create the front panel. The controls and
indicatorsarelocatedonsubpalettesbasedonthetypesofcontrolsandindicators.

Figure2.4:ControlsPaletteinFrontPanelWindow.

Select ViewControls Palette or rightclick the front panel workspace to display the
Controls palette. LabVIEW retains the Controls palette position and size so when you
restartLabVIEW,thepaletteappearsinthesamepositionandhasthesamesize.You
canchangethecontentsoftheControlspalette.

2.3FunctionsPalette

The Functions palette is available only on the block diagram. The Functions palette
containstheVIsandfunctionsyouusetobuildtheblockdiagram.TheVIsandfunctions
arelocatedonsubpalettesbasedonthetypesofVIsandfunctions.

Figure2.5:FunctionsPaletteofaBlockDiagram

SelectViewFunctionsPaletteorrightclicktheblockdiagramworkspacetodisplaythe
Functionspalette.LabVIEWretainstheFunctionspalettepositionandsizesowhenyou
restartLabVIEW,thepaletteappearsinthesamepositionandhasthesamesize.You
canchangethecontentsoftheFunctionspalette.

2.4NavigatingtheControlsandFunctionsPalette

Clickanobjectonthepalettetoplacetheobjectonthecursorsoyoucanplaceitonthe
frontpanelorblockdiagram.YoualsocanrightclickaVIicononthepaletteandselect
OpenVIfromtheshortcutmenutoopentheVI.Clicktheblackarrowsontheleftsideof
the Controls or Functions palette to expand or collapse subpalettes. These arrows
appearonlyifyousetthepaletteformattoCategory(Standard)orCategory(Iconsand
Text).

Use the following buttons on the Controls and Functions palette toolbars to navigate
thepalettes,toconfigurethepalettes,andtosearchforcontrols,VIs,andfunctions.

2.5ToolsPalette

The Tools palette is available on the front panel and the block diagram. A tool is a
specialoperatingmodeofthemousecursor.Thecursorcorrespondstotheiconofthe
tool you select on the palette. Use the tools to operate and modify front panel and
blockdiagramobjects.Ifautomatictoolselectionisenabledandyoumovethecursor
over objects on the front panel or block diagram, LabVIEW automatically selects the
correspondingtoolfromtheToolspalette.

Figure2.6:ToolsPalette(availableinbothfrontpanelandblockdiagramwindow)

SelectViewToolsPalettetodisplaytheToolspalette.LabVIEWretainstheToolspalette
positionsowhenyourestartLabVIEW,thepaletteappearsinthesameposition.

2.6ContextHelpWindow

TheContextHelpwindowdisplaysbasicinformationaboutLabVIEWobjectswhenyou
move the cursor over each object. Objects with context help information include VIs,
functions, constants, structures, palettes, properties, methods, events, dialog box
components, and items in the Project Explorer window. You also can use the Context
HelpwindowtodetermineexactlywheretoconnectwirestoaVIorfunction.

Figure2.7:ContextualHelp

Select HelpShow Context Help to display the Context Help window. You also can
displaytheContextHelpwindowbyclickingtheShowContextHelpWindowbuttonon
thetoolbar,shownasfollows.

Youalsocandisplaythewindowbypressingthe<Ctrl+H>keys.

TheContextHelpwindowresizestoaccommodateeachobjectdescription.Youalsocan
resizetheContextHelpwindowtosetitsmaximumsize.LabVIEWretainstheContext
HelpwindowpositionandsizesowhenyourestartLabVIEW,thewindowappearsinthe
samepositionandhasthesamemaximumsize.IfacorrespondingLabVIEWHelptopic
existsforanobjecttheContextHelpwindowdescribes,abluedetailedhelplinkappears
intheContextHelpwindow.

3.BuildingaVirtualInstrument(VI)

LaunchingLabVIEW

Figure3.1:LabVIEWgettingstartedwindow

TheGettingStartedwindow,showninFigure3.1,appearswhenyoulaunchLabVIEW.
Use this window to create new VIs, select among the most recently opened LabVIEW
files,findexamples,andlaunchtheLabVIEWHelp.Youalsocanaccessinformationand
resourcestohelpyoulearnaboutLabVIEW,suchasspecificmanuals,helptopics,and
resourcesontheNationalInstrumentsWebsite,ni.com.

TheGettingStartedwindowdisappearswhenyouopenanexistingfileorcreateanew
file. The Getting Started window reappears when you close all open front panels and
blockdiagrams.Youalsocandisplaythewindowfromthefrontpanelorblockdiagram
byselectingViewGettingStartedWindow.

10

CreatingaNewVIfromTemplate

LabVIEW provides builtin template VIs that include the subVIs, functions, structures,
and front panel objects you need to get started building common measurement
applications.

CompletethefollowingstepstocreateaVIthatgeneratesasignalanddisplaysitonthe
frontpanel.

1.LaunchLabVIEW.

Figure3.2:Newdialogbox

2.IntheGettingStartedwindow,clicktheNeworVIfromTemplatelinktodisplaythe
Newdialogbox.

3. From the Create New list, select VIFrom TemplateTutorial (Getting Started)
GenerateandDisplay.ThistemplateVIgeneratesanddisplaysasignal.

11

ApreviewandabriefdescriptionofthetemplateVIappearintheDescriptionsection.
Figure 3.2 shows the New dialog box and the preview of the Generate and Display
templateVI.

4.ClicktheOKbuttontocreateaVIfromthetemplate.Youalsocandoubleclickthe
nameofthetemplateVIintheCreateNewlisttocreateaVIfromatemplate.

5.ExaminethefrontpaneloftheVI.Theuserinterface,orfrontpanel,appearswitha
graybackgroundandincludescontrolsandindicators.Thetitlebarofthefrontpanel
indicatesthatthiswindowisthefrontpanelfortheGenerateandDisplayVI.

6. Select WindowShow Block Diagram and examine the block diagram of the VI. The
block diagram appears with a white background and includes VIs and structures that
control the front panel objects. The title bar of the block diagram indicates that this
windowistheblockdiagramfortheGenerateandDisplayVI.

7.Onthefrontpaneltoolbar,clicktheRunbutton.Youalsocanpressthe<CtrlR>keys
torunaVI.Asinewaveappearsonthegraphonthefrontpanel.

8.StoptheVIbyclickingtheSTOPbutton,onthefrontpanel.

AddingaControltotheFrontPanel

Controlsonthefrontpanelsimulatetheinputmechanismsonaphysicalinstrumentand
supplydatatotheblockdiagramoftheVI.Manyphysicalinstrumentshaveknobsyou
canturntochangeaninputvalue.Completethefollowingstepstoaddaknobcontrol
tothefrontpanel.

1. If the Controls palette, shown in Figure 3.3, is not visible on the front panel, select
ViewControlsPalette.

12

Figure3.3:ControlsPalette
2. TheControlspaletteopenswith theExpresssubpalettevisiblebydefault.Ifyoudo
not see the Express subpalette, click Express on the Controls palette to display the
Expresssubpalette.

3. Move the cursor over the icons on the Express subpalette to locate the Numeric
Controls palette. When you move the cursor over icons on the Controls palette, the
nameofthesubpalette,control,orindicatorappearsinatipstripbelowtheicon.

4.ClicktheNumericControlsicontodisplaytheNumericControlspalette.

5. Click theknob control on the Numeric Controls palette to attach the control to the
cursor,thenplacetheknobonthefrontpaneltotheleftofthewaveformgraph.You
willusethisknobinalaterexercisetocontroltheamplitudeofasignal.

6. Select FileSave As and save the VI as Acquiring a Signal.vi in an easily accessible


location.

ChangingaSignalType

The block diagram has a blue icon labeled Simulate Signal. This icon represents the
Simulate Signal Express VI. The Simulate Signal Express VI simulates a sine wave by
default.Completethefollowingstepstochangethissignaltoasawtoothwave.

1. Display the block diagram by pressing the <CtrlE> keys or by clicking the block
diagram. Locate the Simulate Signal Express VI. An Express VI is a component of the
block diagram that you can configure to perform common measurement tasks. The
SimulateSignalExpressVIsimulatesasignalbasedontheconfigurationthatyouspecify.
13


2. Rightclick the Simulate Signal Express VI and select Properties from the shortcut
menutodisplaytheConfigureSimulateSignaldialogbox.Youalsocandoubleclickthe
Express VI to display the Configure Simulate Signal dialog box. If you wire data to an
ExpressVIandrunit,theExpressVIdisplaysrealdataintheconfigurationdialogbox.If
you close and reopen the Express VI, the VI displays sample data in the configuration
dialogboxuntilyouruntheVIagain.

3.SelectSawtoothfromtheSignaltypepulldownmenu.Thewaveformonthegraphin
theResultPreviewsectionchangestoasawtoothwave.TheConfigureSimulateSignal
dialogboxshouldappearsimilartoFigure3.4.

Figure3.4:Configuresimulatesignaldialogbox

4. Click the OK button to save the current configuration and close the Configure
SimulateSignaldialogbox.
14


5.MovethecursoroverthedownarrowsatthebottomoftheSimulateSignalExpress
VI.Thedownarrowsindicateyoucanrevealhiddeninputsandoutputsbyextendingthe
borderoftheExpressVI.

6.Whenadoubleheadedarrowappears,clickanddragtheborderoftheExpressVIto
addtworows.Whenyoureleasetheborder,theAmplitudeinputappears.Becausethe
Amplitudeinputappearsontheblockdiagram,youcanconfiguretheamplitudeofthe
sawtoothwaveontheblockdiagram.InFigure3.4,noticethatAmplitudeisanoptionin
the Configure Simulate Signal dialog box. When inputs, such as Amplitude, appear on
theblockdiagramandintheconfigurationdialogbox,youcanconfiguretheinputsin
eitherlocation.

WiringObjectsontheBlockDiagram

Tousetheknobtochangetheamplitudeofthesignal,youmustconnecttwoobjectson
the block diagram. Complete the following steps to wire the knob to the Amplitude
inputoftheSimulateSignalExpressVI.

1.Ontheblockdiagram,movethecursorovertheKnobterminal.Thecursorbecomes
anarrow,orthePositioningtool.UsethePositioningtooltoselect,position,andresize
objects.

2.UsethePositioningtooltoselecttheKnobterminalandmakesureitistotheleftof
theSimulateSignalExpressVIandinsidethegrayloop.Theterminalsinsidetheloopare
representations of front panel controls and indicators. Terminals are entry and exit
portsthatexchangeinformationbetweenthefrontpanelandblockdiagram.

3. Deselect the Knob terminal by clicking a blank space on the block diagram. If you
wanttouseadifferenttoolwithanobject,youmustdeselecttheobjecttoswitchthe
tool.

4. Move the cursor over the arrow on the Knob terminal. The cursor becomes a wire
spool, or the Wiring tool. Use the Wiring tool to wire objects together on the block
diagram.

5.WhentheWiringtoolappears,clickthearrowontheKnobterminalandthenclickthe
arrowontheAmplitudeinputoftheSimulateSignalExpressVI,towirethetwoobjects
together.Awireappearsandconnectsthetwoobjects.Dataflowsalongthiswirefrom
theKnobterminaltotheExpressVI.

6.SelectFileSavetosavetheVI.
15

RunningaVI

RunningaVIexecutesthesolution.CompletethefollowingstepstoruntheAcquiringa
SignalVI.

1.Displaythefrontpanelbypressingthe<CtrlE>keysorbyclickingthefrontpanel.

2.ClicktheRunbuttonorpressthe<CtrlR>keystoruntheVI.

3.Movethecursorovertheknob.Thecursorbecomesahand,ortheOperatingtool.
UsetheOperatingtooltochangethevalueofacontrol.

4. Using the Operating tool, turn the knob to adjust the amplitude of the sawtooth
wave. The amplitude of the sawtooth wave changes as you turn the knob. As you
changetheamplitude,theOperatingtooldisplaysatipstripthatindicatesthenumeric
value of the knob. The yaxis on the graph scales automatically to account for the
change in amplitude. To indicate that the VI is running, the Run button changes to a
darkened arrow. You can change the value of most controls while a VI runs, but you
cannotedittheVIinotherwayswhiletheVIruns.

5. Click the STOP button, to stop the VI. The STOP button stops the VI after the VI
completesthecurrentiteration.TheAbortExecutionbutton,stopstheVIimmediately,
beforetheVIfinishesthecurrentiteration.AbortingaVIthatusesexternalresources,
such as external hardware, might leave the resources in an unknown state by not
resetting or releasing them properly. Design the VIs you create with a stop button to
avoidthisproblem.

ModifyingaSignal

Complete the following steps to scale the signal by 10 and display the results in the
graphonthefrontpanel.

1.Ontheblockdiagram,usethePositioningtooltodoubleclickthewirethatconnects
theSimulateSignalExpressVItotheWaveformGraphterminal.

2.Pressthe<Delete>keytodeletethiswire.

3. If the Functions palette, shown in Figure 3.5, is not visible, select ViewFunctions
Palettetodisplayit.TheFunctionspaletteopenswiththeExpresssubpalettevisibleby
default. If you have selected another subpalette, you can return to the Express
subpalettebyclickingExpressontheFunctionspalette.
16

Figure3.5:FunctionsPalette

4.OntheArithmetic&Comparisonpalette,selecttheFormulaExpressVIandplaceit
on the block diagram inside the loop between the Simulate Signal Express VI and the
WaveformGraphterminal.YoucanmovetheWaveformGraphterminaltotherightto
make more room between the Express VI and the terminal. The Configure Formula
dialog box appears when you place the Express VI on the block diagram. When you
placeanExpressVIontheblockdiagram,theconfigurationdialogboxforthatVIalways
appearsautomatically.

5.ClicktheHelpbutton,inthebottomrightcorneroftheConfigureFormuladialogbox
todisplaytheLabVIEWHelptopicforthisExpressVI.TheFormulahelptopicdescribes
theExpressVI,theconfigurationdialogboxoptions,andtheinputsandoutputsofthe
ExpressVI.EachExpressVIhasacorrespondinghelptopicyoucanaccessbyclickingthe
Help button in the configuration dialog box or by rightclicking the Express VI and
selectingHelpfromtheshortcutmenu.

6. In the Formula topic, find the dialog box option whose description indicates that it
entersavariableintotheformula.

7.MinimizetheLabVIEWHelptoreturntotheConfigureFormuladialogbox.

8.ChangethetextintheLabeltextboxofthedialogboxoptionyoureadaboutfromX1
toSawtoothtoindicatetheinputvaluetotheFormulaExpressVI.Whenyouclickinthe
String text box at the top of the Configure Formula dialog box, the text changes to
matchthelabelyouentered.

9.Definethevalueofthescalingfactorbyentering*10afterSawtoothintheStringtext
box.YoucanusetheInputbuttonsintheconfigurationdialogboxoryoucanusethe*,
1,and0keyboardbuttonstoenterthescalingfactor.IfyouusetheInputbuttonsinthe
configurationdialogbox,LabVIEWplacestheformulainputaftertheSawtoothinputin

17

theStringtextbox.Ifyouusethekeyboard,clickintheStringtextboxafterSawtooth
andentertheformulayouwanttoappearinthetextbox.TheConfigureFormuladialog
boxshouldappearsimilartoFigure3.6.

Figure3.6:Configureformuladialogbox

10. Click the OK button to save the current configuration and close the Configure
Formuladialogbox.

11. Move the cursor over the arrow on the Sawtooth output of the Simulate Signal
ExpressVI.

12. When the Wiring tool appears, click the arrow on the Sawtooth output and then
clickthearrowontheSawtoothinputoftheFormulaExpressVI,towirethetwoobjects
together.

13. Use the Wiring tool to wire the Result output of the Formula Express VI to the
WaveformGraphterminal.

18

ExaminethewiresconnectingtheExpressVIsandterminals.ThearrowsontheExpress
VIsandterminalsindicatethedirectionthatthedataflowsalongthesewires.Theblock
diagramshouldappearsimilartoFigure3.7.

Figure3.7:BlockdiagramofacquiringasignalVI

14.Pressthe<CtrlS>keysorselectFileSavetosavetheVI.

DisplayingTwoSignalsonaGraph

To compare the signal generated by the Simulate Signal Express VI and the signal
modifiedbytheFormulaExpressVIonthesamegraph,usetheMergeSignalsfunction.
Completethefollowingstepstodisplaytwosignalsonthesamegraph.

1.Ontheblockdiagram,movethecursoroverthearrowontheSawtoothoutputofthe
SimulateSignalExpressVI.

2. Use the Wiring tool to wire the Sawtooth output to the Waveform Graph terminal.
TheMergeSignalsfunction,appearswherethetwowiresconnect.Afunctionisabuilt
inexecutionelement,comparabletoanoperator,function,orstatementinatextbased
programminglanguage.TheMergeSignalsfunctiontakesthetwoseparatesignalsand
combinesthemsothatbothcandisplayonthesamegraph.

TheblockdiagramshouldappearsimilartoFigure3.8.

19


Figure3.8:Blockdiagramshowingthemergesignalfunction

3.Pressthe<CtrlS>keysorselectFileSavetosavetheVI.

4.Returntothefrontpanel,runtheVI,andturntheknobcontrol.Thegraphplotsthe
sawtooth wave and the scaled signal. The maximum value on the yaxis automatically
changestobe10timestheknobvalue.Thisscalingoccursbecauseyouconfiguredthe
FormulaExpressVItogenerateaslopeof10.

5.ClicktheSTOPbuttontostoptheVI.

CustomizingaKnobControl

Theknobcontrolchangestheamplitudeofthesawtoothwave,solabelingitAmplitude
accurately describes the behavior of the knob. Complete the following steps to
customizetheappearanceoftheknob.

1.Onthefrontpanel,rightclicktheknobandselectPropertiesfromtheshortcutmenu
todisplaytheKnobPropertiesdialogbox.

2. In the Label section on the Appearance page, delete the label Knob, and enter
Amplitudeinthetextbox.

TheKnobPropertiesdialogboxshouldappearsimilartoFigure3.9.

20


Figure3.9:Knobpropertiesdialogbox

3.ClicktheScaletabandintheScaleStylesection,placeacheckmarkintheShowcolor
rampcheckbox.Theknobonthefrontpanelupdatestoreflectthesechanges.

4.ClicktheOKbuttontosavethecurrentconfigurationandclosetheKnobProperties
dialogbox.

5.SavetheVI.

6.ReopentheKnobPropertiesdialogboxandexperimentwithotherpropertiesofthe
knob.Forexample,ontheScalepage,trychangingthecolorsfortheMarkertextcolor
byclickingthecolorbox.

7.ClicktheCancelbuttontoavoidapplyinganychangesyoumadewhileexperimenting.
Ifyouwanttokeepthechangesyoumade,clicktheOKbutton.

21

CustomizingaWaveformGraph

The waveform graph indicator displays the two signals. To indicate which plot is the
scaledsignalandwhichisthesimulatedsignal,youcancustomizetheplots.Complete
thefollowingstepstocustomizetheappearanceofthewaveformgraphindicator.

1.Onthefrontpanel,movethecursoroverthetopoftheplotlegendonthewaveform
graph.Thoughthegraphhastwoplots,theplotlegenddisplaysonlyoneplot.

2. When a doubleheaded arrow appears, shown in Figure 3.10, click and drag the
borderoftheplotlegendtoaddoneitemtothelegend.Whenyoureleasethemouse
button,thesecondplotnameappears.

Figure3.10.ExpandingaPlotLegend

3. Rightclick the waveform graph and select Properties from the shortcut menu to
displaytheWaveformGraphPropertiesdialogbox.

4.OnthePlotspage,selectSawtoothfromthepulldownmenu.IntheColorssection,
clicktheLinecolorboxtodisplaythecolorpicker.Selectanewlinecolor.

5.SelectSawtooth(FormulaResult)fromthepulldownmenu.

6.PlaceacheckmarkintheDonotusewaveformnamesforplotnamescheckbox.

7.IntheNametextbox,deletethecurrentlabelandchangethenameofthisplotto
ScaledSawtooth.

22

8.ClicktheOKbuttontosavethecurrentconfigurationandclosetheWaveformGraph
Propertiesdialogbox.Theplotcoloronthefrontpanelchanges.

9. Reopen the Waveform Graph Properties dialog box and experiment with other
propertiesofthegraph.Forexample,ontheScalespage,trydisablingautomaticscaling
andchangingtheminimumandmaximumvalueoftheyaxis.

10. Click the Cancel button to avoid applying any changes you made while
experimenting.Ifyouwanttokeepthechangesyoumade,clicktheOKbutton.

11.SaveandclosetheVI.

23

LabVIEWPracticeExample#1

CompletethefollowingstepstocreateaVIthatgenerates,analyzes,anddisplaysasignal.
1.IntheGettingStartedwindow,clickNewtodisplaytheNewdialogbox.
2. From the Create New list, select VIFrom TemplateTutorial (Getting Started)Generate,
Analyze, and Display. This template VI simulates a signal and analyzes it for its root mean
square(RMS)value.
3. Click the OK button or doubleclick the name of the template to create a VI from the
template.
4.MovethecursorovertheAmplitudeandLevelMeasurementsExpressVI.TheContextHelp
window (press Ctrl+H) displays information about the behavior of the Express VI. Keep the
ContextHelpwindowopen.Itwillprovideusefulinformationasyoucompletetherestofthis
exercise.
5. On the front panel, remove the RMS indicator, along with any broken wires on the block
diagram that result from removing the indicator. To remove all broken wires from the block
diagram,youcanpressthe<CtrlB>keys.
6.Onthefrontpanel,rightclickthewaveformgraphindicatorandselectPropertiesfromthe
shortcutmenu.TheGraphPropertiesdialogboxappears.
7.OntheAppearancetab,placeacheckmarkintheVisiblecheckboxintheLabelsectionand
enterUnfilteredSignalinthetextbox.
8.ClicktheOKbuttontosavetheconfigurationandclosetheGraphPropertiesdialogbox.
9.RuntheVI.Thesignalappearsinthegraph.
10.ClicktheSTOPbuttontostoptheVI.

AddingaSignal
The Simulate Signal Express VI simulates a sine wave by default. You can customize the
simulatedsignalbychangingtheoptionsintheConfigureSimulateSignaldialogbox.
Completethefollowingstepstocreateanadditionalsimulatedsignalthataddsuniformwhite
noisetothesinewave.
1.Ontheblockdiagram,usethePositioningtooltoselecttheSimulateSignalExpressVI.
24

Hold down the <Ctrl> key and drag to create an additional Simulate Signal Express VI on the
blockdiagram.
2.ReleasethemousebuttontoplacethecopiedSimulateSignalExpressVIbelowtheoriginal
SimulateSignalExpressVI.LabVIEWupdatesthenameofthecopiedSimulateSignalExpressVI
toSimulateSignal2.
3.DoubleclicktheSimulateSignal2ExpressVItodisplaytheConfigureSimulateSignaldialog
box.
4.SelectSinefromtheSignaltypepulldownmenu.
5.Enter60intheFrequency(Hz)textbox.
6.Enter.1intheAmplitudetextbox.
7.PlaceacheckmarkintheAddnoisecheckboxtoaddnoisetothesinesignal.
8.SelectUniformWhiteNoisefromtheNoisetypepulldownmenu.
9.Enter0.1intheNoiseamplitudetextbox.
10.Enter1intheSeednumbertextbox.
11.IntheTimingsection,selecttheRunasfastaspossibleoption.
12. In the Signal Name section, remove the checkmark from the Use signal type name
checkbox.
13.Enter60HzandNoiseintheSignalnametextbox.
When you change the signal name in the Configure Simulate Signal dialog box, LabVIEW
changesthenameofthesignaloutputontheblockdiagram.Changingthesignalnamemakesit
easierforyoutoidentifythesignaltypewhenyouviewtheExpressVIontheblockdiagram.
TheResultPreviewsectiondisplaysarandomsignal.TheConfigureSimulateSignaldialogbox
shouldappearsimilartoFigure1.

25


Figure1:ConfigureSimulateSignalDialogueBox
14. Click the OK button to save the current configuration and close the Configure Simulate
Signaldialogbox.

AddingTwoSignals
Toaddtwosignalstogethertocreateonesignal,youcanusetheFormulaExpressVI.Rather
thanmergingtwosignalsononegraph,theFormulaExpressVIaddsbothsignalstogetherto
createasinglesignalonthegraph.YoucanusethisExpressVItoaddnoisetoasignal.
Completethefollowingstepstoaddthe60HzandNoisesignaltotheSinesignal.
1. On the block diagram, tripleclick the wire that connects the Sine output of the Simulate
SignalExpressVItotheSignalsinputoftheAmplitudeandLevelMeasurementsExpressVIand
totheUnfilteredSignalindicatorandremovethewire.
26

2.ClicktheSearchbuttonontheFunctionspalettetosearchfortheFormulaExpressVI,and
placeitontheblockdiagrambetweentheSimulateSignalExpressVIsandtheAmplitudeand
LevelMeasurementsExpressVI.TheConfigureFormuladialogboxappears.
3.IntheLabelcolumn,changethelabelforX1toSineandthelabelforX2to60HzandNoise.
NoticethattheFormulaExpressVIautomaticallyentersthefirstinput,Sine,intheFormulatext
box.
4.Clickthe+buttonandthentheX2buttontoaddSineand60HzandNoisetogetherinthe
Formulatextbox.
5.ClicktheOKbuttontosavethecurrentconfigurationandclosetheConfigureFormuladialog
box.
6.UsetheWiringtooltowiretheSineoutputoftheSimulateSignalExpressVItotheSineinput
oftheFormulaExpressVI.
7.Wirethe60HzandNoiseoutputoftheSimulateSignal2ExpressVItothe60HzandNoise
inputoftheFormulaExpressVI.
8.WiretheResultoutputoftheFormulaExpressVItotheUnfilteredSignalindicatorandtothe
SignalsinputoftheAmplitudeandLevelMeasurementsExpressVI.
9.Displaythefrontpanelbypressingthe<CtrlE>keys.
10.RuntheVI.Thesignalwithaddednoiseappearsinthegraph.
11.ClicktheSTOPbuttontostoptheVI.
12.SelectFileSaveAsandsavetheVIasAnalysis.viinaneasilyaccessiblelocation.

FilteringaSignal
YoucanusetheFilterExpressVItoprocesssignalsthroughfiltersandwindows.
Complete the following steps to configure the Filter Express VI to filter the signal using an
infiniteimpulseresponse(IIR)filter.
1. Remove the wire that connects the Result output of the Formula Express VI to the Signals
inputoftheAmplitudeandLevelMeasurementsExpressVI.
2.Removeallbrokenwiresthatresultfromremovingthewire.

27

3. Search for the Filter Express VI and place it on the block diagram between the Simulate
Signal2ExpressVIandtheAmplitudeandLevelMeasurementsExpressVI.TheConfigureFilter
dialogboxappears.
4.IntheFilterSpecificationssection,changetheCutoffFrequency(Hz)to25.
5.ClicktheOKbuttontosavetheconfigurationandclosetheConfigureFilterdialogbox.
6.Displaythefrontpanel.
7.ClicktheUnfilteredSignalwaveformgraphindicatoronthefrontpanelandpressthe<Ctrl>
keywhileyoudragtocreateanadditionalwaveformgraphindicator.
8.PlacetheadditionalwaveformgraphindicatorbelowtheUnfilteredSignalwaveformgraph.
9.TripleclicktheUnfilteredSignal2labelabovethenewwaveformgraphindicatorandenter
Filtered Signal to change the label of the indicator. You also can change the label on the
AppearancepageoftheGraphPropertiesdialogbox.
10.Ontheblockdiagram,wiretheResultoutputoftheFormulaExpressVItotheSignalinput
oftheFilterExpressVI.
11.WiretheFilteredSignaloutputoftheFilterExpressVItotheSignalsinputoftheAmplitude
and Level Measurements Express VI and to the input of the Filtered Signal waveform graph
indicator.
12.SelectFileSave.TheblockdiagramoftheAnalysisVIshouldappearsimilartoFigure2.

Figure2:BlockdiagramoftheAnalysisVI
28

ModifyingtheAppearanceofGraphs
You can use the Display Format page of the Graph Properties dialog box to specify how the
scalesofthexaxisandyaxisappearonthegraph.
Complete the following steps to change the format of the xaxis and yaxis of the Unfiltered
SignalandFilteredSignalgraphs.
1.Onthefrontpanel,rightclicktheUnfilteredSignalgraphindicatorandselectPropertiesfrom
theshortcutmenu.TheGraphPropertiesdialogboxappears.
2.OntheDisplayFormatpage,selectTime(XAxis)fromthetoppulldownmenu.
3.IntheTypelist,selectAutomaticformatting.
4. In the Digits field, enter 6 and select Significant digits from the Precision Type pulldown
menu.
5.PlaceacheckmarkintheHidetrailingzeroscheckbox.
6.SelectAmplitude(YAxis)fromthetoppulldownmenuandrepeatsteps35sotheyaxis
configurationmatchesthexaxisconfiguration.
7.OntheScalespage,selectAmplitude(YAxis).
8.RemovethecheckmarkfromtheAutoscalecheckbox.
9.Enter2.5intheMinimumtextboxand2.5intheMaximumtextbox.
10.ClicktheOKbuttontosavetheconfigurationandclosetheGraphPropertiesdialogbox.
11.Repeatsteps110toconfiguretheFilteredSignalgraphindicator.Thexaxisandtheyaxis
on the Unfiltered Signal and Filtered Signal graph indicators change to reflect the new
configuration.

AnalyzingtheAmplitudeofaSignal
You can use the Amplitude and Level Measurements Express VI to analyze the voltage
characteristicsofasignal.

29

Complete the following steps to reconfigure the Express VI to measure the peaktopeak
amplitudevaluesofthesignal.
1. On the block diagram, doubleclick the Amplitude and Level Measurements Express VI to
displaytheConfigureAmplitudeandLevelMeasurementsdialogbox.
2.IntheAmplitudeMeasurementssection,removethecheckmarkfromtheRMScheckbox.
3.PlaceacheckmarkinthePeaktopeakcheckbox.PeaktopeakappearsintheResultssection
withthecorrespondingvalueofthemeasurement.
4.ClicktheOKbuttontosavethecurrentconfigurationandclosetheConfigureAmplitudeand
Level Measurements dialog box. The RMS output of the Amplitude and Level Measurements
ExpressVIchangestoreflectthenewPeaktoPeakoutput.

ControllingtheSpeedofExecution
Toplotthepointsonthewaveformgraphsmoreslowly,youcanaddatimedelaytotheblock
diagram.
CompletethefollowingstepstocontrolthespeedatwhichtheVIruns.
1.SearchfortheTimeDelayExpressVI.
2. Place the Time Delay Express VI in the lower lefthand corner of the While Loop. The
ConfigureTimeDelaydialogboxappears.
3.Enter.1intheTimedelay(seconds)textboxandclicktheOKbutton.
4.RuntheVI.Theloopiteratesonceeverytenthofasecond.
5.StoptheVI.

30

You might also like