Introduction to LabVIEW
Transcription
Introduction to LabVIEW
UniversityCollegeofSoutheastNorway IntroductiontoLabVIEW Hans-PetterHalvorsen,2016-09-07 http://home.hit.no/~hansha Preface ThisdocumentexplainsthebasicconceptsofLabVIEW. Youfindadditionalresources,code,etc.here: http://home.hit.no/~hansha/?tutorial=labview YouneedtoinstalltheLabVIEWProfessionalDevelopmentSystem. FormoreinformationaboutLabVIEW,visitmyBlog:http://home.hit.no/~hansha/ LabVIEWBasicsVideos: http://home.hit.no/~hansha/video/labview_basics.php LabVIEWTrainingandResources: http://home.hit.no/~hansha/?training=labview ii TableofContents Preface......................................................................................................................................ii TableofContents.....................................................................................................................iii 1 2 Introduction......................................................................................................................1 1.1 DataflowProgramming...............................................................................................1 1.2 GraphicalProgramming..............................................................................................1 1.3 Benefits.......................................................................................................................2 StartusingLabVIEW..........................................................................................................4 2.1 TheLabVIEWEnvironment.........................................................................................4 2.2 FrontPanel.................................................................................................................5 2.3 BlockDiagram.............................................................................................................7 2.4 ControlsPalette........................................................................................................10 2.4.1 NumericSubPalette..........................................................................................12 2.4.2 BooleanSubPalette..........................................................................................12 2.4.3 String&PathSubPalette..................................................................................13 2.5 FunctionPalette........................................................................................................13 2.6 ToolsPalette.............................................................................................................14 2.7 Wiring.......................................................................................................................16 2.8 Toolbar......................................................................................................................16 2.9 Execution..................................................................................................................17 2.10 TheObjectsshort-cutmenu.................................................................................18 2.11 DataflowProgramming.........................................................................................19 2.12 Help.......................................................................................................................20 Exercises..............................................................................................................................20 iii iv 3 TableofContents SubVIs.............................................................................................................................24 3.1 CreateNewSubVIfromScratch...............................................................................25 3.1.1 InputandOutputSubVIConnectors.................................................................26 3.1.2 IconEditor.........................................................................................................28 3.2 CreateSubVIfromexistingcode..............................................................................29 3.3 UsingSubVIs............................................................................................................30 Exercises..............................................................................................................................31 4 CustomizeLabVIEW.........................................................................................................33 Exercises..............................................................................................................................34 5 LoopsandStructures.......................................................................................................35 5.1 Loops.........................................................................................................................35 5.1.1 ForLoop.............................................................................................................36 5.1.2 WhileLoop........................................................................................................37 5.2 Structures.................................................................................................................38 5.2.1 CaseStructure...................................................................................................38 5.2.2 SequenceStructure...........................................................................................39 5.2.3 EventStructure..................................................................................................40 Exercises..............................................................................................................................42 6 TroubleshootingandDebugging.....................................................................................45 6.1 Howtofinderrors....................................................................................................45 6.2 HighlightExecution...................................................................................................45 6.3 Probes.......................................................................................................................46 6.4 Breakpoints...............................................................................................................47 6.5 Stepinto/over/outdebugging..................................................................................48 Exercises..............................................................................................................................48 Tutorial:AnIntroductiontoLabVIEW v 7 TableofContents WorkingwithData..........................................................................................................50 7.1 Arrays........................................................................................................................50 7.1.1 Auto-Indexing....................................................................................................50 7.1.2 ArrayFunctions.................................................................................................51 7.2 Cluster.......................................................................................................................53 7.2.1 ClusterOrder.....................................................................................................54 7.2.2 ClusterElements................................................................................................55 Exercises..............................................................................................................................56 8 WorkingwithStrings.......................................................................................................58 Exercises..............................................................................................................................60 9 ErrorHandling.................................................................................................................62 9.1 FindingError.............................................................................................................62 9.2 ErrorWiring..............................................................................................................62 9.3 ErrorHandlinginSubVIs...........................................................................................63 9.4 ErrorHandling...........................................................................................................64 Exercises..............................................................................................................................65 10 WorkingwithProjects..................................................................................................66 10.1 ProjectExplorer.....................................................................................................66 10.2 Deployment...........................................................................................................67 Exercises..............................................................................................................................69 11 DesignTechniques........................................................................................................71 11.1 ForceProgramFlow..............................................................................................71 11.2 ShiftRegister.........................................................................................................72 11.3 StateProgrammingArchitecture..........................................................................73 11.4 MultipleLoops/Parallelprogramming..................................................................75 Tutorial:AnIntroductiontoLabVIEW vi 11.5 TableofContents Templates..............................................................................................................77 Exercises..............................................................................................................................78 12 UserInterface...............................................................................................................80 12.1 VIProperties.........................................................................................................81 Exercises..............................................................................................................................84 13 PlottingData.................................................................................................................85 13.1 Customizing...........................................................................................................87 Exercises..............................................................................................................................89 14 Tips&Tricks.................................................................................................................91 14.1 10functionsyouneedtoknowabout..................................................................91 14.2 The10mostusefulShort-cuts..............................................................................96 15 ExampleApplication.....................................................................................................97 16 AdditionalExercises...................................................................................................101 17 What’sNext?..............................................................................................................106 17.1 MyBlog...............................................................................................................106 17.2 Tutorials..............................................................................................................106 17.3 AdditionalResources..........................................................................................106 17.4 Examples.............................................................................................................107 QuickReference....................................................................................................................108 Tutorial:AnIntroductiontoLabVIEW 1 Introduction LabVIEW(shortforLaboratoryVirtualInstrumentationEngineeringWorkbench)isa platformanddevelopmentenvironmentforavisualprogramminglanguagefromNational Instruments.Thegraphicallanguageisnamed"G".OriginallyreleasedfortheApple Macintoshin1986,LabVIEWiscommonlyusedfordataacquisition,instrumentcontrol,and industrialautomationonavarietyofplatformsincludingMicrosoftWindows,variousflavors ofUNIX,Linux,andMacOSX.ThelatestversionofLabVIEWisversionLabVIEW2011.Visit NationalInstrumentsatwww.ni.com. Thecodefileshavetheextension“.vi”,whichisanabbreviationfor“VirtualInstrument”. LabVIEWofferslotsofadditionalAdd-OnsandToolkits. 1.1 DataflowProgramming TheprogramminglanguageusedinLabVIEW,alsoreferredtoasG,isadataflow programminglanguage.Executionisdeterminedbythestructureofagraphicalblock diagram(theLV-sourcecode)onwhichtheprogrammerconnectsdifferentfunction-nodes bydrawingwires.Thesewirespropagatevariablesandanynodecanexecuteassoonasall itsinputdatabecomeavailable.Sincethismightbethecaseformultiplenodes simultaneously,Gisinherentlycapableofparallelexecution.Multi-processingandmultithreadinghardwareisautomaticallyexploitedbythebuilt-inscheduler,whichmultiplexes multipleOSthreadsoverthenodesreadyforexecution. 1.2 GraphicalProgramming LabVIEWtiesthecreationofuserinterfaces(calledfrontpanels)intothedevelopmentcycle. LabVIEWprograms/subroutinesarecalledvirtualinstruments(VIs).EachVIhasthree components:ablockdiagram,afrontpanel,andaconnectorpanel.Thelastisusedto representtheVIintheblockdiagramsofother,callingVIs.Controlsandindicatorsonthe frontpanelallowanoperatortoinputdataintoorextractdatafromarunningvirtual instrument.However,thefrontpanelcanalsoserveasaprogrammaticinterface.Thusa virtualinstrumentcaneitherberunasaprogram,withthefrontpanelservingasauser interface,or,whendroppedasanodeontotheblockdiagram,thefrontpaneldefinesthe inputsandoutputsforthegivennodethroughtheconnectorpane.ThisimplieseachVIcan beeasilytestedbeforebeingembeddedasasubroutineintoalargerprogram. 1 2 Introduction Thegraphicalapproachalsoallowsnon-programmerstobuildprogramssimplybydragging anddroppingvirtualrepresentationsoflabequipmentwithwhichtheyarealreadyfamiliar. TheLabVIEWprogrammingenvironment,withtheincludedexamplesandthe documentation,makesitsimpletocreatesmallapplications.Thisisabenefitononeside, butthereisalsoacertaindangerofunderestimatingtheexpertiseneededforgoodquality "G"programming.Forcomplexalgorithmsorlarge-scalecode,itisimportantthatthe programmerpossessanextensiveknowledgeofthespecialLabVIEWsyntaxandthe topologyofitsmemorymanagement.ThemostadvancedLabVIEWdevelopmentsystems offerthepossibilityofbuildingstand-aloneapplications.Furthermore,itispossibletocreate distributedapplications,whichcommunicatebyaclient/serverscheme,andaretherefore easiertoimplementduetotheinherentlyparallelnatureofG-code. 1.3 Benefits OnebenefitofLabVIEWoverotherdevelopmentenvironmentsistheextensivesupportfor accessinginstrumentationhardware.Driversandabstractionlayersformanydifferenttypes ofinstrumentsandbusesareincludedorareavailableforinclusion.Thesepresent themselvesasgraphicalnodes.Theabstractionlayersofferstandardsoftwareinterfacesto communicatewithhardwaredevices.Theprovideddriverinterfacessaveprogram developmenttime.ThesalespitchofNationalInstrumentsis,therefore,thatevenpeople withlimitedcodingexperiencecanwriteprogramsanddeploytestsolutionsinareduced timeframewhencomparedtomoreconventionalorcompetingsystems.Anewhardware drivertopology(DAQmxBase),whichconsistsmainlyofG-codedcomponentswithonlya fewregistercallsthroughNIMeasurementHardwareDDK(DriverDevelopmentKit) functions,providesplatformindependenthardwareaccesstonumerousdataacquisition andinstrumentationdevices.TheDAQmxBasedriverisavailableforLabVIEWonWindows, MacOSXandLinuxplatforms. Thisdocumentintroducingthefollowingthemes: • • • • • StartusingLabVIEW o TheLabVIEWEnvironment o FrontPanelandBlockDiagram o Palettes:ControlPalette,FunctionsPalette,ToolsPalette o DataTypes o PropertyNodes SubVIs LoopsandStructures TroubleshootingandDebugging WorkingwithData Tutorial:AnIntroductiontoLabVIEW 3 • • • • • • • • • • Introduction o Arrays § ArrayFunctions o Cluster WorkingwithStrings ErrorHandling WorkingwithProjectsusingProjectExplorer DesignTechniques o ShiftRegister o StateMachine o MultipleLoops UserInterface PlottingData Deployment:BuildingExecutableApplications(.exe) IntroductiontoAdd-OnsandToolkits o Brieflyexplanations… o MoredetailaboutControlandSimulationModuleinlater IntroductiontoDAQ-DataAcquisition o MAX–MeasurementandAutomationExplorer o NI-DAQmx QuickReferencewithKeyboardShort-cuts FormoreinformationaboutLabVIEW,visitmyBlog:http://home.hit.no/~hansha/ Tutorial:AnIntroductiontoLabVIEW 2 StartusingLabVIEW ThischapterexplainsthebasicconceptsinLabVIEW. Thetopicsareasfollows: • • • • • TheLabVIEWEnvironment FrontPanelandBlockDiagram Palettes:ControlPalette,FunctionsPalette,ToolsPalette DataTypes PropertyNodes 2.1 TheLabVIEWEnvironment LabVIEWprogramsarecalledVirtualInstruments,orVIs,becausetheirappearanceand operationimitatephysicalinstruments,suchasoscilloscopesandmultimeters.LabVIEW containsacomprehensivesetoftoolsforacquiringanalyzing,displaying,andstoringdata,as wellastoolstohelpyoutroubleshootyourcode. WhenopeningLabVIEW,youfirstcometothe“GettingStarted”window. 4 5 StartusingLabVIEW InordertocreateanewVI,select“BlankVI”orinordertocreateanewLabVIEWproject, select“Emptyproject”. WhenyouopenablankVI,anuntitledfrontpanelwindowappears.Thiswindowdisplays thefrontpanelandisoneofthetwoLabVIEWwindowsyouusetobuildaVI.Theother windowcontainstheblockdiagram.Thesectionsbelowdescribethefrontpanelandthe blockdiagram. 2.2 FrontPanel WhenyouhavecreatedanewVIorselectedanexistingVI,theFrontPanelandtheBlock DiagramforthatspecificVIwillappear. InLabVIEW,youbuildauserinterface,orfrontpanel,withcontrolsandindicators.Controls areknobs,pushbuttons,dials,andotherinputdevices.Indicatorsaregraphs,LEDs,and otherdisplays. Youbuildthefrontpanelwithcontrolsandindicators,whicharetheinteractiveinputand outputterminalsoftheVI,respectively.Controlsareknobs,pushbuttons,dials,andother inputdevices.Indicatorsaregraphs,LEDs,andotherdisplays.Controlssimulateinstrument Tutorial:AnIntroductiontoLabVIEW 6 StartusingLabVIEW inputdevicesandsupplydatatotheblockdiagramoftheVI.Indicatorssimulateinstrument outputdevicesanddisplaydatatheblockdiagramacquiresorgenerates. E.g.,a“Numeric”caneitherbea“NumericControl”ora“NumericIndicator”,asseenbelow. Iyouselecta“NumericControl”,itcaneasybechangedtoan“NumericIndicator”byright clickontheobjectanselect“ChangetoIndicator” Oropposite,Iyouselecta“NumericIndicator”,itcaneasybechangedtoan“Numeric Control”byrightclickontheobjectanselect“ChangetoControl” Tutorial:AnIntroductiontoLabVIEW 7 StartusingLabVIEW Thedifferencebetweena“NumericControl”anda“NumericIndicator”isthatfora “NumericControl”youmayenteravalue,whilethe“NumericIndicator”isread-only,i.e., youmayonlyreadthevalue,notchangeit. Theappearanceisalsoslightlydifferent,the“NumericControl”hasanincrementandan decrementbuttoninfront,whilethe“NumericIndicator”hasadarkerbackgroundcolorin ordertoindicatethatitsread-only. 2.3 BlockDiagram Afteryoubuildtheuserinterface,youaddcodeusingVIsandstructurestocontrolthefront panelobjects.Theblockdiagramcontainsthiscode.Insomeways,theblockdiagram resemblesaflowchart. Tutorial:AnIntroductiontoLabVIEW 8 StartusingLabVIEW Afteryoubuildthefrontpanel,youaddcodeusinggraphicalrepresentationsoffunctionsto controlthefrontpanelobjects.Theblockdiagramcontainsthisgraphicalsourcecode.Front panelobjectsappearasterminals,ontheblockdiagram.Blockdiagramobjectsinclude terminals,subVIs,functions,constants,structures,andwires,whichtransferdataamong otherblockdiagramobjects. TheFigurebelowshowsafrontpanelanditscorrespondingblockdiagramwithfrontpanel andblockdiagramcomponents. Tutorial:AnIntroductiontoLabVIEW 9 StartusingLabVIEW Thedifferentcomponentsareasfollows: 1. Toolbar 2. OwnedLabel 3. NumericControl 4. FreeLabel 5. NumericControlTerminal 6. KnobTerminal 7. NumericConstant 8. MultiplyFunction 9. Icon 10. KnobControl 11. PlotLegend 12. XYGraph Tutorial:AnIntroductiontoLabVIEW 10 StartusingLabVIEW 13. WireDataPath 14. XYGraphTerminal 15. BundleFunction 16. SubVI 17. ForLoopStructure 2.4 ControlsPalette TheControlsandFunctionspalettescontainsubpalettesofobjectsyoucanusetocreatea VI.Whenyouclickasubpaletteicon,theentirepalettechangestothesubpaletteyou selected.Touseanobjectonthepalettes,clicktheobjectandplaceitonthefrontpanelor blockdiagram.TheControlspaletteisavailableonlyonthefrontpanel.TheControlspalette containsthecontrolsandindicatorsyouusetobuildthefrontpanel. ThemostusedSubPalettesaretheNumericSubPalette,theBooleanSubPaletteandthe String&PathSubPalette. YoumaychangetheappearanceandthecontentsoftheControlspalette: Tutorial:AnIntroductiontoLabVIEW 11 StartusingLabVIEW YoumayPinthepalette,soitisalwaysvisible,justclickthelittlepinbutton upperleftcornerofthepalette: inthe Ifyouwanttochangethecontentandappearanceofthepalette,clickthe“View”button. Hereyoumaychangethewaythepaletteshouldlook. Ifyouclick“ChangeVisibleCategories…”youmaychangewhichCategoriesyouwanttohave visible. Tutorial:AnIntroductiontoLabVIEW 12 2.4.1 StartusingLabVIEW NumericSubPalette “NumericalControl”and“NumericalIndicator”arethemostusedobjectsinthenumericsub palette. 2.4.2 BooleanSubPalette Thispalettehaslotsofdifferentbuttonsyoumayuse.OK,CancelandStopbuttonsare useful. Tutorial:AnIntroductiontoLabVIEW 13 StartusingLabVIEW 2.4.3 String&PathSubPalette IntheStringandPathpalettewehaveStringControls,ComboBox,etc. 2.5 FunctionPalette TheFunctionspaletteisavailableonlyontheblockdiagram.TheFunctionspalettecontains theVIsandfunctionsyouusetobuildtheblockdiagram. Tutorial:AnIntroductiontoLabVIEW 14 StartusingLabVIEW 2.6 ToolsPalette Youcancreate,modify,anddebugVIsusingthetoolslocatedonthefloatingToolspalette. TheToolspaletteisavailableonboththefrontpanelandtheblockdiagram.Atoolisa specialoperatingmodeofthemousecursor.Thecursorcorrespondstotheiconofthetool selectedintheToolspalette.Usethetoolstooperateandmodifyfrontpanelandblock diagramobjects. Tutorial:AnIntroductiontoLabVIEW 15 StartusingLabVIEW TheToolspaletteisavailablefromtheViewmenu: Ifyoumakesure“Automaticwiring”isdisabled(Irecommendyoudoso!)youmayuse theTabkeyonyourkeyboardinordertoswitchbetweenthemostcommontools. Themostusedtoolsare: UsetheOperatingtool,shownatleft,tochangethevaluesofacontrolorselect thetextwithinacontrol.TheOperatingtoolchangestotheiconshownatleftwhenit movesoveratextcontrol,suchasanumericorstringcontrol. UsethePositioningtool,shownatleft,toselect,move,orresizeobjects.The Positioningtoolchangestoresizinghandleswhenitmovesovertheedgeofaresizable object. UsetheLabelingtool,shownatleft,toedittextandcreatefreelabels.The Labelingtoolchangestothefollowingicon whenyoucreatefreelabels. UsetheWiringtool,shownatleft,towireobjectstogetherontheblockdiagram. Tutorial:AnIntroductiontoLabVIEW 16 StartusingLabVIEW 2.7 Wiring InordertocreatethelogicalflowbetweentheobjectontheBlockDiagram,youneedtouse theWiringtoolinordertoconnectthedifferentobjectstogether. UsetheWiringtooltowireobjectstogetherontheblockdiagram. AvailableKeyboardShortcutswhendealingwithWiring: Ctrl-Bisveryuseful.Thisshort-cutremovesallbrokenwiresontheBlockDiagram. 2.8 Toolbar BelowweseetheLabVIEWToolbar: Thebehaviorsofthedifferentbuttonsareasfollows: Tutorial:AnIntroductiontoLabVIEW 17 StartusingLabVIEW ClicktheRunbuttontorunaVI.LabVIEWcompilestheVI,ifnecessary.YoucanrunaVI iftheRunbuttonappearsasasolidwhitearrow.Thesolidwhitearrow,shownabove,also indicatesyoucanusetheVIasasubVIifyoucreateaconnectorpanefortheVI. WhiletheVIruns,theRunbuttonappearsasshownatleftiftheVIisatop-levelVI, meaningithasnocallersandthereforeisnotasubVI. IftheVIthatisrunningisasubVI,theRunbuttonappearsasshownatleft. TheRunbuttonappearsbroken,shownatleft,whentheVIyouarecreatingorediting containserrors.IftheRunbuttonstillappearsbrokenafteryounishwiringtheblock diagram,theVIisbrokenandcannotrun.ClickthisbuttontodisplaytheErrorlistwindow, whichlistsallerrorsandwarnings. ClicktheRunContinuouslybutton,shownatleft,toruntheVIuntilyouabortorpause execution.Youalsocanclickthebuttonagaintodisablecontinuousrunning. WhiletheVIruns,theAbortExecutionbutton,shownatleft,appears.Clickthisbutton tostoptheVIimmediatelyifthereisnootherwaytostoptheVI.Ifmorethanonerunning top-levelVIusestheVI,thebuttonisdimmed. Note:AvoidusingtheAbortExecutionbuttontostopaVI.EitherlettheVIcompleteitsdata owordesignamethodtostoptheVIprogrammatically.Bydoingso,theVIisataknown state.Forexample,placeabuttononthefrontpanelthatstopstheVIwhenyouclickit. ClickthePausebutton,shownatleft,topausearunningVI.WhenyouclickthePause button,LabVIEWhighlightsontheblockdiagramthelocationwhereyoupausedexecution, andthePausebuttonappearsred.ClickthebuttonagaintocontinuerunningtheVI. 2.9 Execution InadditiontotheToolbarbuttonsabovethefollowingKeyboardShortcutsareavailable whendealingwithExecution: Tutorial:AnIntroductiontoLabVIEW 18 StartusingLabVIEW 2.10 TheObjectsshort-cutmenu Themostoften-usedmenuistheobjectshortcutmenu.AllLabVIEWobjectsandempty spaceonthefrontpanelandblockdiagramhaveassociatedshortcutmenus.Usethe shortcutmenuitemstochangethelookorbehavioroffrontpanelandblockdiagram objects.Toaccesstheshortcutmenu,right-clicktheobject,frontpanel,orblockdiagram. TheNumericcontrolhasthefollowingshort-cut/right-clickmenu: Theshort-cutmenuwillbedifferentforthedifferentcontrolsorobjects. Tutorial:AnIntroductiontoLabVIEW 19 2.11 StartusingLabVIEW DataflowProgramming LabVIEWfollowsadataflowmodelforrunningVIs.Ablockdiagramnodeexecuteswhenall itsinputsareavailable.Whenanodecompletesexecution,itsuppliesdatatoitsoutput terminalsandpassestheoutputdatatothenextnodeinthedataflowpath. VisualBasic,C++/C#,Java,andmostothertext-basedprogramminglanguagesfollowa controlflowmodelofprogramexecution.Incontrolflow,thesequentialorderofprogram elementsdeterminestheexecutionorderofaprogram. Example:DataflowProgramming TheExampleshowsablockdiagramthataddstwonumbersandthensubtracts50.00from theresultoftheaddition.Inthiscase,theblockdiagramexecutesfromlefttoright,not becausetheobjectsareplacedinthatorder,butbecausetheSubtractfunctioncannot executeuntiltheAddfunctionfinishesexecutingandpassesthedatatotheSubtract function.Rememberthatanodeexecutesonlywhendataareavailableatallofitsinput terminals,anditsuppliesdatatoitsoutputterminalsonlywhenitfinishesexecution. Example:DataflowProgramming Inthisexample,considerwhichcodesegmentwouldexecutefirst-theAdd,Random Number,orDividefunction.YoucannotknowbecauseinputstotheAddandDivide functionsareavailableatthesametime,andtheRandomNumberfunctionhasnoinputs.In asituationwhereonecodesegmentmustexecutebeforeanotherandnodatadependency Tutorial:AnIntroductiontoLabVIEW 20 StartusingLabVIEW existsbetweenthefunctions,useotherprogrammingmethods,suchaserrorclusters,to forcetheorderofexecution. 2.12 Help TheContextHelpwindow(Ctrl+H)displaysbasicinformationaboutLabVIEWobjects whenyoumovethecursorovereachobject.TheContextHelpwindowisvisiblebydefault. TotoggledisplayoftheContextHelpwindow,selectHelp-ShowContextHelp,presstheCtrlHkeys,orclicktheShowContextHelpWindowbuttononthetoolbar. Whenyoumovethecursoroverfrontpanelandblockdiagramobjects,theContextHelp windowdisplaystheiconforsubVIs,functions,constants,controls,andindicators,with wiresattachedtoeachterminal.Whenyoumovethecursoroverdialogboxoptions,the ContextHelpwindowdisplaysdescriptionsofthoseoptions.Inthewindow,required connectionsarebold,recommendedconnectionsareplaintext,andoptionalconnections aredimmedordonotappear.TheFigurebelowshowsanexampleoftheContextHelp window. Exercises Exercise:CreateyourfirstLabVIEWapplication(VI) CreateasimpleLabVIEWapplication(VI)withaFrontPanelwithsomeControlsand Indicators.CreatethelogicbyconnectingtheTerminalsontheBlockDiagram TheFrontPanelcouldlooksomethinglikethis: Tutorial:AnIntroductiontoLabVIEW 21 StartusingLabVIEW TheBlockDiagramcouldlooksomethinglikethis: StarttheprogramwiththeRunbutton. Exercise:CreateasimpleCalculator CreateasimplecalculatorthatAddandSubtract2numberslikethis: Tutorial:AnIntroductiontoLabVIEW 22 StartusingLabVIEW StarttheprogramwiththeRunbutton. Exercise:WriteDatatoFile CreateaVIthatwritesdatatoaTextFile. UseVisorfunctionsfromtheFileI/Opalette Theprogramcouldlooksomethinglikethis: Tutorial:AnIntroductiontoLabVIEW 23 StartusingLabVIEW Exercise:ReadDatafromFile CreateanotherVIthatreadthetextfileyoucreatedinthepreviousVI. Tutorial:AnIntroductiontoLabVIEW 3 SubVIs ThischapterexplainsthebasicconceptsofcreatingandusingSubVIsinLabVIEW. Topics: • • • CreateNewSubVIfromScratch CreateSubVIfromexistingcode UsingSubVIs WhenyouplaceaVIontheblockdiagram,LabVIEWconsiderstheVItobeasubVI.When youdouble-clickasubVI,itsfrontpanelandblockdiagramappear,ratherthanadialogbox inwhichyoucanconfigureoptions.Thefrontpanelincludescontrolsandindicators.The blockdiagramincludeswires,frontpanelicons,functions,possiblysubVIs,andother LabVIEWobjects.Theupperrightcornerofthefrontpanelandblockdiagramdisplays. BelowweseeanexampleofabadBlockDiagram.Thisexampledoesnotmakeuseofthe SubVIfunctionalityinLabVIEWatall!ThismakestheBlockdiagramhardtoreadand understand.Thesizeofthediagramisalsotoolarge!TheBlockDiagramshouldalwaysfit intothescreen.BoththeFrontPanelandtheBlockDiagramshouldfitintoascreen resolutionof1024x768. 24 25 SubVIs WithuseofSubVIs,theexampleabovecouldturninto,e.g.: Asyoucansee,muchofthecodeintheMainVIhavebeenreplacedandputintoSubVIs. Theprogramisnowmorereadable. Anotherapproachistouseaso-calledStateMachineprinciple(moreaboutthisinchapter 11-DesignTechniques). AvailableKeyboardShortcutswhendealingwithSubVis: 3.1 CreateNewSubVIfromScratch Tutorial:AnIntroductiontoLabVIEW 26 SubVIs Select“BlankVI”inthe“GettingStarted”windowwhenopeningLabVIEW,orwhenLabVIEW isalreadyopenedselectFile→NewV”orusetheshort-cutCtrl+N. 3.1.1 InputandOutputSubVIConnectors MostSubVIswillhaveinputandoutput“connectors”.Thisissimilarwithfunctionsor methodsinotherprogramminglanguagethathaveinputargumentsandanoutput/result. Inordertocreateconnectors,Right-clickontheiconintheupperrightcorneroftheVIand select“ShowConnector”. YoumayselectdifferentPatterns,i.e.,howmanyinputandoutputconnectorsyouneed. Tutorial:AnIntroductiontoLabVIEW 27 SubVIs MakesureyouselectaPatternwithenoughconnectorsevenifyoudon’tneedallthe connectorsatthemoment.IrecommendthatyoustandardizeonthepatternintheFigure above. SelecttheWiretoolandclickonthewantedconnector,thenclickontheControlor IndicatorontheFrontPanelyouwanttoconnecttothisconnector. Youshouldalwaysfollowtheseconnectorrules: • • • • Upperleftconnector:“Reference”In Upperrightconnector:“Reference”Out Lowerleftconnector:ErrorInCluster Lowerrightconnector:ErrorOutCluster Example:SubVIConnectors Seeexamplebelowabouttheseconnectorrules: Tutorial:AnIntroductiontoLabVIEW 28 SubVIs MostcommonVIsthatexitsfollowtheserules,seeexamplebelow. Ifyoufollowtheseconnectorrulesit’smucheasiertocreateacleanandneatcodelikethis: Bydoingthisit’salsoclearhowtheDataflowsintheprogram.Itshouldalwaysflowfrom lefttoright. 3.1.2 IconEditor YoushouldalsocreateasuitableiconforyourSubVI. InordertoopentheIconEditor,double-clickontheiconintheupperrightcornerofyourVI. Tutorial:AnIntroductiontoLabVIEW 29 SubVIs BelowweseeablockdiagramwithSubVIsiconappearancecreatedwiththeIconEditor. 3.2 CreateSubVIfromexistingcode Ifyoufindoutthatyoucodeisgettingmessy,youcouldconsiderputsomecodeintoa SubVI. Theprocedureisasfollows: 1. SelectthepartofyourcodeyouwanttoturnintoaSubVI 2. FromtheEditmenu,select“CreateSubVI” Tutorial:AnIntroductiontoLabVIEW 30 SubVIs 3. LabVIEWwillautomaticallycreateaSubVIfortheselectedcode. 4. Cleanupautomaticallycreatedwires,etc. 5. CreateasuitableiconforyourSubVI Althoughthisisquiteeasytodothis,Idonotrecommendthatyouusethisfunctionalityto much.ThisisbecauseyoushouldcreateanduseSubVIsfromthefirstmomentyoustart creatingyourapplicationandnotafterwardswhenyoufindoutthatyouhavebeencreating amessycode. SoyoushouldstructureanddesignyourcodewiththeuseofSubVIsfromthebeginning! 3.3 UsingSubVIs BelowweseeanexampleofhowtouseSubVIsinaprogram(TopVIorSubVIs): YoumayopenaSubVIfromtheFilemenu,selectaSubVIfromtheFunctionspaletteoruse draganddropindifferentways,e.g.,youmaydragaVIfromtheFileExplorerinWindows directlyintoanexistingVIyouhavealreadyopenedinLabVIEW Tutorial:AnIntroductiontoLabVIEW 31 SubVIs Exercises Exercise:ConvertCtoFVI CreateaSubVIthatconvertaTemperatureinCelsiustoaTemperatureinFahrenheit 1. 2. 3. 4. CreatetheSubVI CreatetheFrontPanelandtheBlockDiagramasshownabove CreatenecessaryConnectors Createasuitableicon,e.g.: 5. UsetheSubVIinanotherVI 6. Runtheprogramtoseeifitworks 7. ExpandtheprogramsoyoucanselectifyouwanttoconvertfromCelsiusto FahrenheitorfromFahrenheittoCelsius Exercise:ConvertexistingcodeintoaSubVI Tutorial:AnIntroductiontoLabVIEW 32 SubVIs ConvertapartofyourapplicationintoaSubVIbyusingtheCreateSubVIfunctionin LabVIEW. Tutorial:AnIntroductiontoLabVIEW 4 CustomizeLabVIEW LabVIEWhaslotsofpossibilitiesforcustomizingtheappearanceandtheuseoftheLabVIEW environment.Select“Options…”fromtheToolsmenu. Thedefaultsettingsisnotnecessarythebest,herearesomerecommendationsforsetting uptheLabVIEWenvironment. Category:BlockDiagram 33 34 CustomizeLabVIEW • • Disable“Enableautowiring”option.ThispreventsLabVIEWfromautomatically connectingadjacentblocks.Althoughitseemsusefultohaveautowiringenables,it ismyexperiencethattheautowiringisalittleannoyingsinceittendstodrawwires betweenblockswhenyoudonotwantanywire. Disable“Placefrontpanelelementsasicons”option.ThiscausesLabVIEWtouse smallterminaliconsontheblockdiagram.Ifyou,instead,activatethisoption,the terminaliconsarelarger,withamimicoftheelementasitappearsatthefront panel. Category:Controls/FunctionsPalettes • IntheFormatlist: select“Category(IconsandText)” Category:AlignmentGrid • Turnoff“ShowFrontPanelGrid”and“ShowBlockDiagramGrid” Exercises Exercise:CustomizeLabVIEW Trythedifferentsettingsexplainedinthischapter.Turnthemonandoffandwatchthe different. Tutorial:AnIntroductiontoLabVIEW 5 LoopsandStructures ThischapterexplainsthebasicconceptsofLoopsandStructuresinLabVIEW. Thetopicsareasfollows: • • • • • ForLoop WhileLoop CaseStructure SequenceStructure EventStructure ThedifferentLoopsandStructuresavailablearelocatedinthe“Structures”subpalettein theFunctionspaletteontheBlockDiagram. 5.1 Loops Themostimportantloopsare: • • ForLoop WhileLoop 35 36 LoopsandStructures Theseloopswillbeexplainedindetailbelow. 5.1.1 ForLoop AForLoopexecutesasubdiagramasetnumberoftimes.TheFigurebelowshowsanempty ForLoopinLabVIEW. AForloopexecutesitssubdiagramntimes,wherenisthevaluewiredtothecount( ) terminal.Theiteration( )terminalprovidesthecurrentloopiterationcount,whichranges from0ton-1. AfteryoucreateaForLoop,youcanuseshiftregisterstopassvaluesfromoneiterationto thenext.IfyouwireanarraytoaForLoop,youcanreadandprocesseveryelementinthat arraybyenablingauto-indexing.Youalsocanenableauto-indexingbyconfiguringaFor Looptoreturnanarrayofeveryvaluegeneratedbytheloop. YoucanaddaconditionalterminaltoconfigureaForLooptostopwhenaBoolean conditionoranerroroccurs.AForLoopwithaconditionalterminalexecutesuntilthe conditionoccursoruntilalliterationscomplete,whicheverhappensfirst.Toadda conditionalterminaltoaForLoop,right-clicktheForLoopborderandselectConditional Terminalfromtheshortcutmenu.Youmustwiretheconditionalterminalandeitherwire thecountterminalorauto-indexaninputarrayforthelooptoexecuteandfortheVItorun. ToconvertaForLooptoaWhileLoop,right-clicktheForLoopandselectReplacewithWhile Loopfromtheshortcutmenu. Example:ForLoop ThefollowingexampleusesaForLoopinordertocreateanarraywith10elementsandfillit withrandomnumbers. Tutorial:AnIntroductiontoLabVIEW 37 LoopsandStructures 5.1.2 WhileLoop AWhilelooprepeatsthesubdiagraminsideituntiltheconditionalterminal,aninput terminal,receivesaparticularBooleanvalue.TheBooleanvaluedependsonthe continuationbehavioroftheWhileLoop.Right-clicktheconditionalterminalandselectStop ifTrueorContinueifTruefromtheshortcutmenu.Youalsocanwireanerrorclustertothe conditionalterminal,right-clicktheterminal,andselectStoponErrororContinuewhile Errorfromtheshortcutmenu.TheWhileLoopalwaysexecutesatleastonce. BelowweseeanemptyWhileloop: AfteryoucreateaWhileLoop,youcanuseshiftregisterstopassvaluesfromoneiteration tothenext.IfyouwireanarraytoaWhileLoop,youcanreadandprocesseveryelementin thatarraybyenablingauto-indexing. InordertoconvertaWhileLoopintoaForLoop,right-clicktheWhileLoopandselect “ReplacewithForLoop”fromtheshortcutmenu.ToconvertaWhileLoopintoaTimed Loop,right-clicktheWhileLoopandselect“ReplacewithTimedLoop”fromtheshortcut menu. Example:WhileLoop Tutorial:AnIntroductiontoLabVIEW 38 LoopsandStructures Thisexamplerununtileithertheuserclicksthestopbuttonornumberofiterationsis greaterthan10. 5.2 Structures 5.2.1 CaseStructure TheCaseStructurehasoneormoresubdiagrams,orcases,exactlyoneofwhichexecutes whenthestructureexecutes.Thevaluewiredtotheselectorterminaldetermineswhich casetoexecuteandcanbeBoolean,string,integer,orenumeratedtype.Youmayright-click thestructurebordertoaddordeletecases.UsetheLabelingtooltoentervalue(s)inthe caseselectorlabelandconfigurethevalue(s)handledbyeachcase. BelowweseeanemptyCasestructure: BelowweseeanexampleofaCasestructurewith2cases,a“True”caseanda“False”case. DependingoftheBooleaninputvalue,theNumeric1andNumeric2iseitherAddedor Subtracted. Tutorial:AnIntroductiontoLabVIEW 39 LoopsandStructures 5.2.2 SequenceStructure ASequencestructureConsistsofoneormoresubdiagrams,orframes,thatexecute sequentially.Right-clickthestructurebordertoaddanddeleteframesortocreatesequence localstopassdatabetweenframes.UsetheStackedSequencestructuretoensureasub diagramexecutesbeforeorafteranothersubdiagram. BelowweseeanemptySequencestructure. Tutorial:AnIntroductiontoLabVIEW 40 LoopsandStructures Belowweseeanexamplewhereweuse“SequenceLocal”,i.e.,wepassavaluefromone sequencetothenext Note!TotakeadvantageoftheinherentparallelisminLabVIEW,avoidoverusingSequence structures.Sequencestructuresguaranteetheorderofexecution,butprohibitparallel operations.AnothernegativetousingSequencestructuresisthatyoucannotstopthe executionpartwaythroughthesequence. 5.2.3 EventStructure AnEventstructurehasoneormoresubdiagrams,oreventcases,exactlyoneofwhich executeswhenthestructureexecutes.TheEventstructurewaitsuntilaneventhappens, thenexecutestheappropriatecasetohandlethatevent.Right-clickthestructureborderto addneweventcasesandconfigurewhicheventstohandle.WireavaluetotheTimeout terminalatthetopleftoftheEventstructuretospecifythenumberofmillisecondsthe Eventstructureshouldwaitforaneventtooccur.Thedefaultis–1,indicatingnevertotime out. Belowweseeanexample: Tutorial:AnIntroductiontoLabVIEW 41 LoopsandStructures Right-clickontheborderinordertoAdd/EditEventCases,seethedialogboxbelow. Tutorial:AnIntroductiontoLabVIEW 42 LoopsandStructures Exercises Exercise:ForLoop CreateaVIwithaForLoop.Createthelogictofindoutifanumberinanarrayisgreater than10.SeeFrontPanelbelow: Tutorial:AnIntroductiontoLabVIEW 43 LoopsandStructures Exercise:WhileLoop CreateaVIwithaWhileLoop.Createthelogictofindoutwhich(thefirst)indexinthearray thathaveanumbergreaterthan30.SeeFrontPanelbelow: Exercise:CaseStructure CreateaVIwithaCaseStructure. UseaCasestructureinsideaForLooptowritethetext“TheNumberisgreaterthan10”if valueisgreaterthan10.SeeFrontPanelbelow: Tutorial:AnIntroductiontoLabVIEW 44 LoopsandStructures Exercise:SequenceStructure CreateaVIwithaSequenceStructure.SeeFrontPanelbelow: Exercise:EventStructure CreateaVIwithanEventStructure.SeeFrontPanelbelow: Tutorial:AnIntroductiontoLabVIEW 6 Troubleshootingand Debugging ThischapterexplainsthebasicconceptsoftroubleshootinganddebugginginLabVIEW. Topics: • • • • • Howtofinderrors HighlightExecution Probes Breakpoints Stepinto/over/outdebugging 6.1 Howtofinderrors IfaVIdoesnotrun,itisabroken,or“nonexecutable”,VI.TheRunbuttonoften appearsbroken,shownatleft,whenyoucreateoreditaVI.Ifitisstillbrokenwhenyou finishwiringtheblockdiagram,theVIisbrokenandwillnotrun.Generally,thismeansthata requiredinputisnotwired,orawireisbroken. ClickthebrokenRunbuttontodisplaytheErrorlistwindow,whichlistsalltheerrors. Double-clickanerrordescriptiontodisplaytherelevantblockdiagramorfrontpaneland highlighttheobjectthatcontainstheerror. 6.2 HighlightExecution ViewananimationoftheexecutionoftheblockdiagrambyclickingtheHighlight Executionbutton.Executionhighlightingshowstheflowofdataontheblockdiagramfrom onenodetoanotherusingbubblesthatmovealongthewires.Note!Executionhighlighting greatlyreducesthespeedatwhichtheVIruns. 45 46 TroubleshootingandDebugging 6.3 Probes UsetheProbetooltocheckintermediatevaluesonawireasaVIruns. Whenexecutionpausesatanodebecauseofsingle-steppingorabreakpoint,youalsocan probethewirethatjustexecutedtoseethevaluethatflowedthroughthatwire.Youalso cancreateacustomprobetospecifywhichindicatoryouusetoviewtheprobeddata.For example,ifyouareviewingnumericdata,youcanchoosetoseethatdatainachartwithin theprobe.Tocreateacustomprobe,right-clickawireandselectCustomProbe-Newfrom theshortcutmenu. Tutorial:AnIntroductiontoLabVIEW 47 TroubleshootingandDebugging 6.4 Breakpoints UsetheBreakpointtooltoplaceabreakpointonaVI,node,orwireontheblock diagramandpauseexecutionatthatlocation.Whenyousetabreakpointonawire, executionpausesafterdatapassthroughthewire.Placeabreakpointontheblockdiagram workspacetopauseexecutionafterallnodesontheblockdiagramexecute.WhenaVI pausesatabreakpoint,LabVIEWbringstheblockdiagramtothefrontandusesamarquee tohighlightthenodeorwirethatcontainsthebreakpoint.LabVIEWhighlightsbreakpoints withredbordersfornodesandblockdiagramsandredbulletsforwires.Whenyoumove thecursoroveranexistingbreakpoint,theblackareaoftheBreakpointtoolcursorappears white.UsetheBreakpointtooltoclickanexistingbreakpointtoremoveit. Youmayalsoright-clickonthewireinordertosetabreakpointoropentheBreakpoint Manager. BreakpointManagerisatoolforenable,disableanddeletebreakpoints. Tutorial:AnIntroductiontoLabVIEW 48 TroubleshootingandDebugging 6.5 Stepinto/over/outdebugging AvailableKeyboardShortcutswhenDebugging: Exercises Exercise:HighlightExecution Enable“HighlightExecution”inoneofyourprograms,andseehowitworks. Exercise:Probes SetSeveralProbesaroundinyourapplicationandwatchhowitworks.UsetheProbewatch Windowandcheckoutthefunctionalitythistooloffers. Alsocheckoutthe“CustomProbe”andthe“FindProbe”functionality. Tutorial:AnIntroductiontoLabVIEW 49 TroubleshootingandDebugging Exercise:Breakpoints SetsomeBreakpointaroundinyourcodeandcheckouthowitworks.UsetheBreakpoint Managertool. Example: Exercise:Stepinto/over/outdebugging UsetheStepinto/over/outfunctionalitytogetherwithyourBreakpointsandlearnhowyou canusethemandseewhatthedifferencebetweenthemis. Tutorial:AnIntroductiontoLabVIEW 7 WorkingwithData ThischapterexplainsthebasicconceptsofcreatingandusingSubVisinLabVIEW. Topics: • • • Arrays ArrayFunctions Cluster 7.1 Arrays ArraysareverypowerfultouseinLabVIEW.Inallyourapplicationsyouwouldprobablyuse bothOne-DimensionalArraysandTwo-DimensionalArrays. 7.1.1 Auto-Indexing LabVIEWusesapowerfulmechanismcalled“Auto-indexing”. ForExampleyoumayuseaForlooptocreateArraydatalikethis: OryoumayuseanArraylikethisinordertoautomaticallyspecifynumberofiterations: 50 51 WorkingwithData 7.1.2 ArrayFunctions LabVIEWhaslotsofbuilt-infunctionsformanipulatingarrays. ThemostusefulArrayfunctionsare: ArraySize IndexArray Tutorial:AnIntroductiontoLabVIEW 52 WorkingwithData DeletefromArray Search1DArray InitializeArray BuildArray ArraySubset ArrayConstant Allthesefunctionsarebasic(butveryuseful)arrayfunctionsyouwillprobablybeusinginall yourapplicationsandVIs. Example:Arrayfunctions InthisexampleweseehowwecanusetheseArrayfunctionsandwhattheydo. TheresultingFrontPanelisasfollows: Tutorial:AnIntroductiontoLabVIEW 53 WorkingwithData 7.2 Cluster Clustersgroupdataelementsofmixedtypes,suchasabundleofwires,asinatelephone cable,whereeachwireinthecablerepresentsadifferentelementofthecluster.Aclusteris similartoarecordorastructintext-basedprogramminglanguages.Bundlingseveraldata elementsintoclusterseliminateswireclutterontheblockdiagramandreducesthenumber ofconnectorpaneterminalsthatsubVIsneed.Theconnectorpanehas,atmost,28 terminals.Ifafrontpanelcontainsmorethan28controlsandindicatorsthatyouwantto useprogrammatically,groupsomeofthemintoaclusterandassigntheclustertoaterminal ontheconnectorpane.Likeanarray,aclusteriseitheracontroloranindicator.Acluster cannotcontainamixtureofcontrolsandindicators. Tutorial:AnIntroductiontoLabVIEW 54 WorkingwithData Althoughclusterandarrayelementsarebothordered,youmustunbundleallcluster elementsatonceratherthanindexoneelementatatime.Youalsocanusethe“Unbundle ByName”functiontoaccessspecificclusterelements. ExampleofaClusterinLabVIEW: 7.2.1 ClusterOrder Youmaysortthedifferentelementsintheclusterbyright-clickontheclusterborderand select“ReorderControlsinCluster…” Tutorial:AnIntroductiontoLabVIEW 55 WorkingwithData 7.2.2 ClusterElements InordertomanipulateandworkwithclusterLabVIEWofferslotsoffunctions,suchasthe “Bundle”and“Unbundle”functions. Inordertowritetoaclusterfromthecode,youmayusethe“Bundle”functionorthe “BundleByName”function.Seeexamplebelow: Example:Clusters Tutorial:AnIntroductiontoLabVIEW 56 WorkingwithData Inordertogetaccesstothedifferentelementsinthecluster,youneedto“Unbundle”by usingthe“Unbundle”functionorthe“UnbundleByName”.Seeexamplebelow: Exercises Exercise:Arrays CreatesomesimpleVIswhereyouusethesearrayfunctionstomanipulatearraydata: ArraySize IndexArray DeletefromArray Search1DArray InitializeArray BuildArray ArraySubset Exercise:Arrays CreateaSubVIthatfindthe“peaks”intheinputarrayregardingtoaninputpeaklevel. Tutorial:AnIntroductiontoLabVIEW 57 WorkingwithData Exercise:Clusters CreateaClusterandgetthedifferentvaluesfromthecontrolsintheCluster.SeeFrontPanel below: Tutorial:AnIntroductiontoLabVIEW 8 WorkingwithStrings WorkingandmanipulatingwithstringsisanimportantpartinLabVIEWdevelopment. OntheFrontpanelwehavethefollowingStringcontrolsandindicatorsavailablefromthe Controlpalette: OntheBlockDiagramwehavethefollowingStringfunctionsavailablefromtheFunctions palette: SomeofthemostimportantStringfunctionsare: ConcatenateStrings 58 59 WorkingwithStrings Thisfunctionconcatenatesseveralstringsintoonstring: SearchandReplaceString Usethiswhenyouwanttoreplaceorremoveacertaintextinastring. MatchPattern Tutorial:AnIntroductiontoLabVIEW 60 WorkingwithStrings Thisisthemostusefulfunctionwhenitcomestostringmanipulation. FormatIntoString Example: Exercises HerearesomeexercisesusingsomeoftheStringfunctionsthatareavailableinLabVIEW. Exercise:SubVI:Removeleadingzerosinstring.vi CreateaSubVIwhichremovesleadingzerosinastring.CreateaTestVIthatusestheSubVI. Tutorial:AnIntroductiontoLabVIEW 61 WorkingwithStrings Exercise:SubVI:Removespacefromendofstring.vi CreateaSubVIwhichremovesallspacesfromtheendofthestring.CreateaTestVIthat usestheSubVI. Exercise:SubVI:Add2String.vi CreateaSubVIwhichadds2stringsintoone.CreateaTestVIthatusestheSubVI. Tutorial:AnIntroductiontoLabVIEW 9 ErrorHandling Thischapterexplainsthebasicconceptsofhandleerrorsinyourcode. Topics: • • • FindingErrors ErrorWiring ErrorHandling 9.1 FindingError IfaVIdoesnotrun,itisabroken,or“nonexecutable”,VI.TheRunbuttonoftenappears broken,shownatleft,whenyoucreateoreditaVI.Ifitisstillbrokenwhenyoufinishwiring theblockdiagram,theVIisbrokenandwillnotrun.Generally,thismeansthatarequired inputisnotwired,orawireisbroken.ClickthebrokenRunbuttontodisplaytheErrorlist window,whichlistsalltheerrors.Double-clickanerrordescriptiontodisplaytherelevant blockdiagramorfrontpanelandhighlighttheobjectthatcontainstheerror. 9.2 ErrorWiring Errorhandlingisimportantinallprogramminglanguages.LabVIEWhaspowerfulmechanism forhandlingerrorsanderrorwiring. YoushouldalwayswiretheErrorclusterbetweenallSubVIs,nodes,etc.thatsupportthis, seeexamplebelow. TheErrorclusterislocatedintheControlspalettehere: 62 63 ErrorHandling TheErrorCluster: TheErrorclustercontainsofthefollowingparts: • • • Status–True/False.False:NoError,True:Error Code–ErrorCode Source–TextualErrormessage 9.3 ErrorHandlinginSubVIs WhencreatingSubVIsyoushouldalwayscreateanErrorInandanErrorOut.IntheSubVI codeyoushouldalsouseaCasestructureandwiretheErrorinclustertotheCaseSelector asshownbelow. Tutorial:AnIntroductiontoLabVIEW 64 ErrorHandling 9.4 ErrorHandling LabVIEWhasseveralusefulSubVIs,etc.forErrorHandling: Tutorial:AnIntroductiontoLabVIEW 65 ErrorHandling Theseare: Ingeneralyoushouldalwaysshowtheerrortotheuser.SeeLabVIEWHelpformoredetails ofhowtousetheseSubVIs. Exercises Exercise:ErrorHandling CheckoutthedifferentErrorVisinLabVIEW.UsetheminsomeofyourpreviousVis. Tutorial:AnIntroductiontoLabVIEW 10 WorkingwithProjects ThischapterexplainsthebasicconceptsoftheprojectExplorerinLabVIEW. Topics: • • • ProjectExplorer Building.exe(executable)applications Deployment:CreateanInstaller 10.1 ProjectExplorer ItisnotnecessarytousetheProjectExplorerwhendevelopingyourLabVIEWcode,butitis aneasywaytostructureyourcode,especiallyforlargerprojects. TheprojectExplorerisnecessarywhenyouwanttodeployyourcodeinto,e.g.,an executable(.exe)application,buildasetup,etc. 66 67 WorkingwithProjects TheProjectExplorerisalsoveryusefulwhenyouintegrateasourcecontroltool,suchas TeamFoundationServer,VisualSourceSafe,etc.Thenyoumayeasilycheckfilesinandout ofthesourcecodesystem. InordertocreateanewProjectinLabVIEW,simplyselect“EmptyProject”fromtheGetting StartedwindowwhenyouopenLabVIEW. 10.2 Deployment Whenyourapplicationisfinished,youmaywanttodistributeordeployyourapplicationand shareitwithothers. TheProjectExplorergivesyouseveralchoiceswhenitcomestodistributeanddeployyour application.Someoftheoptionsare: • • • Createanexecutableapplication(.exe)–thismeansthatthetargetdoesn’tneedto haveLabVIEWinstalledontheircomputer.AllthetargetneedisLabVIEWRun-Rime, whichisasmallinstallationpackage. Youmaycreateyourowninstaller,soallthetargetneedistorunasetup.exein ordertouseyourapplication OtherpossibilitiesistocreateaWebServiceoraSharedLibrary(DLL)ofyour application Tutorial:AnIntroductiontoLabVIEW 68 WorkingwithProjects AlltheseoptionsareavailablefromtheProjectExplorer,justright-clickonyour“Build Specifications”node. Wewillgothroughhowwecreateanexecutableapplication.ClickBuild Specifications→New→Application(EXE). InthePropertieswindowfillinyournameoftheapplication. Tutorial:AnIntroductiontoLabVIEW 69 WorkingwithProjects MakesureyouselectaStartupVI. Therearelotsofpropertiesandsettingyoumayuseinordertocreateyourapplication,go throughalltheCategoriesinthePropertieswindow. Whenyouhavefinishedallthesteps,justselect“Build”inordertocreateyourapplication. Whenyoumakechangesinyourapplication,itiseasytorebuildyourapplication: Exercises Exercise:ProjectExplorer CreateanewProjectandputonofyourexistingapplicationintotheproject Tutorial:AnIntroductiontoLabVIEW 70 Exercise:Deployment Createanexecutableapplication Tutorial:AnIntroductiontoLabVIEW WorkingwithProjects 11 DesignTechniques Thischapterexplainssomeusefultechniquestousewhencreatingyourapplication. Topics: • • • • • ForcetheProgramFlowusinganErrorcluster ShiftRegister StateMachine MultipleLoops Templates 11.1 ForceProgramFlow Asmentionedearlier,LabVIEWfollowsadataflowmodelforrunningVIs.Ablockdiagram nodeexecuteswhenallitsinputsareavailable.Whenanodecompletesexecution,it suppliesdatatoitsoutputterminalsandpassestheoutputdatatothenextnodeinthe dataflowpath. IntheexamplebelowwecannotbesurethattheDAQmxWrite.viexecutesbeforethe DAQmxStopTask.viexecutes.LabVIEWwillinthiscaserandomlyexecuteoneofthesefirst. IftheStopVIhappenstoexecutefirstthentheWriteVIwillfailedbecausetaskhasbeen stopped. IntheexamplebelowwewiretheErrorclusterthroughalltheVIs,andtherewillbeno doubtthattheWriteVIwillexecutebeforetheStopVI. 71 72 DesignTechniques Thisapproachwillalsotakecareoftheerrorhandlinginyourprogram,whichisvery importantinreal-worldapplications. 11.2 ShiftRegister UseshiftregistersonForLoopsandWhileLoopstotransfervaluesfromoneloopiteration tothenext.Shiftregistersaresimilartostaticvariablesintext-basedprogramming languages.Ashiftregisterappearsasapairofterminals,directlyoppositeeachotheronthe verticalsidesoftheloopborder.Therightterminalcontainsanuparrowandstoresdataon thecompletionofaniteration.LabVIEWtransfersthedataconnectedtotherightsideofthe registertothenextiteration.Createashiftregisterbyright-clickingtheleftorrightborder ofaloopandselectingAddShiftRegisterfromtheshortcutmenu. Ashiftregistertransfersanydatatypeandautomaticallychangestothedatatypeofthe firstobjectwiredtotheshiftregister.Thedatayouwiretotheterminalsofeachshift registermustbethesametype. Toinitializeashiftregister,wireanyvaluefromoutsidethelooptotheleftterminal.Ifyou donotinitializetheshiftregister,theloopusesthevaluewrittentotheshiftregisterwhen thelooplastexecutedorthedefaultvalueforthedatatypeiftheloophasneverexecuted. UsealoopwithanuninitializedshiftregistertorunaVIrepeatedlysothateachtimetheVI runs,theinitialoutputoftheshiftregisteristhelastvaluefromthepreviousexecution.Use anuninitializedshiftregistertopreservestateinformationbetweensubsequentexecutions ofaVI.Aftertheloopexecutes,thelastvaluestoredintheshiftregisterremainsattheright terminal.Ifyouwiretherightterminaloutsidetheloop,thewiretransfersthelastvalue storedintheshiftregister.Youcanaddmorethanoneshiftregistertoaloop.Ifyouhave multipleoperationswithinaloop,usemultipleshiftregisterstostorethedatavaluesfrom thosedifferentprocessesinthestructure. Tutorial:AnIntroductiontoLabVIEW 73 DesignTechniques 11.3 StateProgrammingArchitecture CreatingVIsusingtheStateMachineapproachisveryusefulwhencreating(large) applications. Ingeneral,astatemachineisamodelofbehaviorcomposedofafinitenumberofstates, transitionsbetweenthosestates,andactions.Itissimilartoa"flowgraph"wherewecan inspectthewayinwhichthelogicrunswhencertainconditionsaremet. Sometimes,youmaywanttochangetheorderofthesequence,repeatoneiteminthe sequencemoreoftenthantheotheritems,stopasequenceimmediately,orhaveitemsin thesequencethatmayexecuteonlywhencertainconditionsaremet.Althoughyour programmaynothaveanysuchrequirements,thereisalwaysthepossibilitythatthe programmustbemodifiedinthefuture.Therefore,astateprogrammingarchitectureisa goodchoice,evenifasequentialprogrammingstructureissufficient.Thefollowinglist describesmorecomplexprogrammingrequirementsthatjustifytheuseofastate programmingarchitectureforanapplication. Tutorial:AnIntroductiontoLabVIEW 74 • • • DesignTechniques Youneedtochangetheorderofthesequence Youmustrepeataniteminthesequencemoreoftenthanotheritems Youwantsomeitemsinthesequencetoexecuteonlywhencertainconditionsare met TheStateMachineapproachinLabVIEWusesaCasestructureinsideaWhilelooptohandle thedifferentstatesintheprogram,andthetransitionsbetweenthem.TheShiftRegisteris usedtosavedatafromandbetweenthedifferentstates. BelowweseeexamplesofastatemachineprincipleimplementedinLabVIEW. SimpleStateMachineprinciple StateMachinewithmultipletransitionsdependingontheState: Tutorial:AnIntroductiontoLabVIEW 75 DesignTechniques MoreadvancedStateMachineusingShiftRegisters: 11.4 MultipleLoops/Parallel programming Often,youneedtoprogrammultipletaskssothattheyexecuteatthesametime.In LabVIEWtaskscanruninparalleliftheydonothaveadatadependencybetweenthem,and Tutorial:AnIntroductiontoLabVIEW 76 DesignTechniques iftheyarenotusingthesamesharedresource.Anexampleofasharedresourceisafile,or aninstrument. UsingmultipleWhileloopsissometimesusefulinapplicationsthatneedtohandleUser interactionsinparallelwith,e.g.,DAQoperations,etc. Belowweseeanexampleofhowthisstructurecouldlooklike.Theupperloopcouldhandle interactionwiththeuser,whilethelowerloopcouldhandleDAQoperations,suchas readingandwritingtosomeI/Oequipments. Tutorial:AnIntroductiontoLabVIEW 77 DesignTechniques Inordertopassdatabetweentheloops,youmaye.g.uselocalvariables.Theloopmayhave differenttimecycles.TheI/OmayrequirefastercyclesthantheUserinteractionloop. 11.5 Templates YoushouldcreateyourowntemplatesforsuchVIyouusealot.Itiseasytocreateyourown templatesforscratch,justcreateaVIasyounormallydoandthensaveitasatemplatewith theending“.vit”.YoumayalsoconvertaVIyoualreadymadejustbychangingtheextension to“.vit”. YoushouldcopyyourtemplatestotheLabVIEWtemplatefolderwhichisdefaultlocatedin “C:\ProgramFiles\NationalInstruments\LabVIEWX.X\Templates\”. TheTemplateswillthenbeavailablefromtheGettingStartedWindoworFile→New…in LabVIEW. ImaycaseIhavecreatedasubfoldercalled“MyTemplates”whereIplaceallmytemplates. Tutorial:AnIntroductiontoLabVIEW 78 DesignTechniques Exercises Herearesomeexercisesaboutshift-registers,StateMachinesandparallelprogramming. Exercise:Shift-register CreateaVI(seeexamplebelow)whereyouhavethefollowingstates: • • • • Initialize Write Read Close IntheVIyouwilluseashift-registerasatemporarystorage.IntheWritestateyouWrite Datatothestorage(shift-register)whileyouintheReadstatewillreadtheDatafromthe Storage. SeeExamplebelow: Tutorial:AnIntroductiontoLabVIEW 79 DesignTechniques WriteaTestprogramthattesttheSubVI,e.g., Thisexampleshowshowyoucanuseashift-registerasatemporarystorage,whichisvery usefulinmanysituations. Exercise:StateMachine UsetheStateMachineprincipleononeofyourpreviousexercises. Exercise:ParallelProgramming CreateaVIthatconsistsof2parallelloops.Uselocalvariablesandothermechanismsin ordertosharedatabetweenthe2loops. Exercise:Templates StripsomeofyourspreviousVisandsavethemasreusableTemplates. Tutorial:AnIntroductiontoLabVIEW 12 UserInterface Thischapterexplainsthebasicconceptsofcreatinguser-friendlyGraphicalUserInterfaces (GUI)inLabVIEW. Topics: • • • • • Decorations TabControl Splitter SubPanel Etc. BelowweseeaFrontPanel(GUI)witha“poor”design. Theinformation(ControlsandIndicators)ontheFrontPanelisnotstructured.Youshould groupelementsthatnaturallybelongtogetherandusedifferentcolorswithcare. WhencreatingGraphicalUserInterfaces(GUI)youshouldusethecontrolsfromtheSystem paletteandnotfromtheModernorClassicpalettes.ModernControlsmaybeusedinSub ViswithnovisibleUserInterface(fortheuser). 80 81 UserInterface TheappearanceofthecontrolsintheSystempaletteisstandardMSWindowslookand feelingandthislookisfamiliarformostusers.Thesecontrolsalsochangeappearancedueto changesintheappearanceintheoperationsystem. 12.1 VIProperties InordertomaketheappearanceoftheWindowthathostsyourapplication,youshould alwaysmakesomechangesinthe“VIProperties”. Youfindthe“VIProperties”byright-clickontheiconintheupperrightcornerofyourVI. Tutorial:AnIntroductiontoLabVIEW 82 UserInterface Thefirstthingyoushouldchangeisthe“Windowtitle”.Hereyoumaytypeappropriate nameofyourapplicationorSubVI. Thenextyoushoulddoistothe“Customize”buttoninordertocustomizetheWindow appearance. BelowweseeanapplicationwithasimpleandneatUserInterfaceandwithaCustomized Windowsappearance. Tutorial:AnIntroductiontoLabVIEW 83 UserInterface BelowweseeaprofessionalapplicationcreatedinLabVIEWthatimplementcommonGUI objectssuchasaToolbar,aTreeview,aListview,etc.. Tutorial:AnIntroductiontoLabVIEW 84 UserInterface Exercises Exercise:UserInterface CreateaDialogBoxwhereyouusesomeoftheControlsfromtheSystempalette.Makethe necessarysettingsinVIPropertiesinordertohidemenus,buttons,createaTitle,etc. CreateaTestVIfromwhereyouopenthisDialogBox,entersomedataintheDialogBox, andthenretrievethesedatainthecallingVI. Example: Tutorial:AnIntroductiontoLabVIEW 13 PlottingData ThischapterexplainsthebasicconceptswhenplottingdatainLabVIEW. LabVIEWofferspowerfulfunctionalityforplottingdata.IntheGraphpalettewehavelotsof usefulcontrolsforplottingandvisualizationofdata. Themostusefulare: • • • WaveformChart WaveformGraph XYGraph Example: Thissimpleexamplecreatesagraphwithsomerandomvalues. 85 86 PlottingData Theexamplebelowshowthebasicdifferencebetweena“Chart”anda“Graph”. Tutorial:AnIntroductiontoLabVIEW 87 PlottingData Youusethe“Graph”ifyouwanttoplotasetofdata,e.g.,anarraywithdata,plotdatafrom afile,etc.Usethe“Chart”ifyouwanttoplotonedatapointatatime,e.g.,insidealoop, etc. 13.1 Customizing ThedifferentChartcomponentsinLabVIEWofferagreatdealofcustomizing. Youmayclickonthe“PlotLegend”inordertosetcolors,differentline styles,etc. Ifyouright-clickontheGraph/Chart,youmaysetpropertiessuchasauto-scaling,etc. Tutorial:AnIntroductiontoLabVIEW 88 PlottingData IfyouselectProperties,yougetthefollowingdialog: Youmayalsoselectwhichitemsthatshouldbevisibleornot. Tutorial:AnIntroductiontoLabVIEW 89 PlottingData The“GraphPalette”letsyouzoominandoutontheGraph,etc. Exercises Exercise:Graph CreateaVIthatreadsdatafromafileandplotthedatainaGraphcomponent. Exercise:Chart CreateaVIwhereyouuseDataBindinginordertoretrievedatafromanOPCdemo. DataBindingissetintheProperties→DataBindingtab: Tutorial:AnIntroductiontoLabVIEW 90 PlottingData Exercise:Customizing CustomizetheGraphandtheChartintheexamplesaboveinordertosetcolors,line thickness,etc. Tutorial:AnIntroductiontoLabVIEW 14 Tips&Tricks ThischaptergivesyousomeusefulTips&TricksregardingLabVIEW. 14.1 10functionsyouneedtoknow about Thesearethe10mostusefulfunctionsinLabVIEW,soyoucouldalreadynowlearnhowto usethemandwheretofindthem! BuildArray ThisexampleusingtheBuildArrayfunctioninsideaForloopinorderbuildanarraywith10 elements. IndexArray 91 92 Tips&Tricks Itisalwaysusefultofindaspecificvalueinanarray: TheIndexArrayisextendible,soyoucandragitouttofindmorethanoneelements: ArraySize Findthesizeofanarbitraryarray: Select Tutorial:AnIntroductiontoLabVIEW 93 Tips&Tricks Dependingontheinputdata,gototheAlarmcaseortheWriteDatacase. ConcatenateStrings Thisfunctionconcatenateseveralstringsintoonstring: SearchandReplaceString Tutorial:AnIntroductiontoLabVIEW 94 Tips&Tricks Usethiswhenyouwanttoreplaceorremoveacertaintextinastring. MatchPattern Thisisthemostusefulfunctionwhenitcomestostringmanipulation. FormatIntoString Tutorial:AnIntroductiontoLabVIEW 95 Tips&Tricks Example: Fract/ExpStringtoNumber Thisfunctionconvertsastringintoanumber: Example:NumberToFractionalString Example: Tutorial:AnIntroductiontoLabVIEW 96 Tips&Tricks 14.2 The10mostusefulShort-cuts Thesearethe10mostusefulshort-cutsinLabVIEW,soyoucouldalreadynowlearnhowto usethem! Short-Cut Ctrl+B Ctrl+. Ctrl+E Tab Ctrl+Mouse wheel Ctrl+H Ctrl+Mouse Double-clickona SubVI Ctrl+Arrows (→←←↓) Ctrl+W Double-clickona wire Description DeletesallbrokenwiresinaVI StopstheRunningVI TogglebetweentheFrontPanelandBlockDiagram CyclesthroughthemostcommonTools(AutomaticToolSelection shouldbedisabled!) ScrollsthroughsubdiagramsinCase,EventorSequencestructures DisplaystheContextHelpwindow OpenstheBlockDiagramdirectly Movefaster.YoufirsthavetoselectaSubVI,aFunction,Object,etc ClosetheSubVI Selectstheholewire Tutorial:AnIntroductiontoLabVIEW 15 ExampleApplication Inthisexamplewewillgothroughanexampleapplication.Theapplicationusesmostofthe LabVIEWfeaturesyouhavelearnedinthisTutorial. Theapplicationiscalled“Glossary”.Itisasimpleapplicationthatlearnskid’swordsin English.Sincetheapplicationisforkids,theuserinterfaceiscreatewitha“childish”look andfeel. Thisisanexampleofhowtocreateauser-friendlyapplicationinLabVIEWthatusesmostof thefunctionalityinLabVIEW,suchasState-machineprinciples,readingandwritingtofiles, dialogboxes,graphicsandsoundeffects.Basicfunctionsforstringandarraymanipulation, andofcoursewhileloops,casestructures,subVIs,etc.TheexamplealsousestheProject Explorertocollectallthefilesinoneplaceandtocreateanexecutablefileofthesolution. FinallyitusestheProjectExplorertocreateasetuppackageyoucanusetoinstallthe applicationeasilyonothercomputers. 97 98 ExampleApplication IcreatedthisapplicationformykidsinthePrimaryschoolwhohadproblemswithlearning theirhomeworkinEnglish. UsethecodeasanexampleforcreatingyourownstunningLabVIEWapplications.Thecode isavailablefordownloadatmyblog:http://home.hit.no/~hansha. BelowweseetheGlossaryList: Ifyouclickonthelittlebooksymbolinyourapplication,thiswindowwillpopup: Clicktissymbolandyoucanenternewwords: Tutorial:AnIntroductiontoLabVIEW 99 ExampleApplication TheapplicationusestheProjectExplorer: Tutorial:AnIntroductiontoLabVIEW 100 ExampleApplication Thismakesiteasytokeepanoverviewofallyourfilesinyourproject.Youmayalsousethe ProjectExplorertocreateanexecutablefileofyourapplication.Inadditionyoumayalso createaninstallationpackagesoyoucaneasilyinstalltheapplicationonothercomputers. AspartoftheinstallationtheLabVIEWRun-timeenginewillbeinstalled. BlockDiagram: Theapplicationusesthestatemachineprinciple,whichmakesiteasytocreatelarge applications: Tutorial:AnIntroductiontoLabVIEW 16 AdditionalExercises Thischapterlistslotsofadditionalexercisesyoucouldtryoutinordertoimproveyour LabVIEWskills. Exercise:vCardReader CreateanapplicationthatreadsinformationfromavCard. vCardisafileformatstandardforelectronicbusinesscards.vCardsareoftenattachedtoemailmessages,butcanbeexchangedinotherways,suchasontheWorldWideWeb.They cancontainnameandaddressinformation,phonenumbers,URLs,logos,photographs,and evenaudioclips. Example: BEGIN:VCARD VERSION:2.1 N:Gump;Forrest FN:Forrest Gump ORG:Bubba Gump Shrimp Co. TITLE:Shrimp Man TEL;WORK;VOICE:(111) 555-1212 TEL;HOME;VOICE:(404) 555-1212 ADR;WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America LABEL;WORK;ENCODING=QUOTED-PRINTABLE:100 Waters Edge=0D=0ABaytown, LA 30314=0D=0AUSA ADR;HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America LABEL;HOME;ENCODING=QUOTED-PRINTABLE:42 Plantation St.=0D=0ABaytown, LA 30314=0D=0AUSA EMAIL;PREF;INTERNET:[email protected] REV:20080424T195243Z END:VCARD FormoreinformationaboutthevCardformat,seehttp://en.wikipedia.org/wiki/VCard. Theapplicationshouldlooksomethinglikethis: WhentheuserclickOpen,thenadialogboxlikethisshouldappear: 101 102 AdditionalExercises Requirements: • • • • • • UsetheProjectExplorer UsetheStateMachineprinciple UsetheEventStructure UseSystemControls SettheappropriatesettingsintheVIProperties. Createaexecutableapplication(vCard.exe) Exercise:vCardWrite&Read Extendtheapplicationinthepreviousexample.Youshouldnowbeabletobothwriteand readvCardfiles.Theapplicationcouldlooksomethinglikethis: Tutorial:AnIntroductiontoLabVIEW 103 AdditionalExercises WhentheuserclicksNew,thedialogboxinthepreviousexerciseappears.Theusermay enteranewvCard.IftheuserclicksEdit,adialogboxwiththeselectedcontactshould appear. Exercise:Read/Writefrom.inifiles Read/Writefrom.inifiles.UsetheConfigurationFileVIs: Exercise:ActiveX CreateasimpleWebBrowserusingActiveXandtheInternetExplorerActiveXcontrol (MicrosoftWebBrowser) UsetheActiveXContainerfromtheContainerscontrolpalette: Tutorial:AnIntroductiontoLabVIEW 104 AdditionalExercises UsetheActiveXfunctionpalette: Theapplicationcouldlooksomethinglikethis: Exercise:Themes Tutorial:AnIntroductiontoLabVIEW 105 AdditionalExercises Ine.g.,ASP.NETwehavesomethingcalledThemes.Themesareusedtochangethe appearanceofyourwholeapplicationregardingtocolor,font,pictures,etc. LabVIEWdonotoffersuchafunctionality,buttrytocreateyourownThemeConfigurator, soyoucanchangetheappearanceofyourVIinstantly. HereisanexampleofhowWindowsXPhandlesdifferentThemes: CreateasimilarThemeConfiguratorsoyoumayeasilychangetheappearanceofyourVis. Tutorial:AnIntroductiontoLabVIEW 17 What’sNext? 17.1 MyBlog FormoreinformationaboutLabVIEW,visitmyBlog:http://home.hit.no/~hansha/ LabVIEWBasics: http://home.hit.no/~hansha/video/labview_basics.php LabVIEWTrainingandResources: http://home.hit.no/~hansha/?training=labview 17.2 Tutorials ThisTutorialisapartofaserieswithotherTutorialsIhavemade,suchas: • • • • • • • • • IntroductiontoLabVIEW DataAcquisitioninLabVIEW ControlandSimulationinLabVIEW LabVIEWMathScript LinearAlgebrainLabVIEW DataloggingandSupervisoryControlinLabVIEW ModelPredictiveControlinLabVIEW WirelessDataAcquisitioninLabVIEW etc. TheseTrainingKitsareavailablefordownload(.pdffiles,sourcecode,additionalresources, etc.)frommyblog:http://home.hit.no/~hansha 17.3 AdditionalResources YoufindlotsofinformationaboutLabVIEWinNationalInstrumentswebsite: www.ni.com 106 107 17.4 What’sNext? Examples IntheNIexampleFinder(Help→FindExamples…)youfindlotsofusefulexamplesthatyou canplaywithoruseasastartwhencreatingyourownapplications. Tutorial:AnIntroductiontoLabVIEW QuickReference 108 QuickReference Tutorial:AnIntroductiontoLabVIEW Hans-PetterHalvorsen,M.Sc. E-mail:[email protected] Blog:http://home.hit.no/~hansha/ UniversityCollegeofSoutheastNorway www.usn.no