Exercise 0 - Open and Run a Virtual Instrument 练习0-打开并运行虚拟仪器_第1页
Exercise 0 - Open and Run a Virtual Instrument 练习0-打开并运行虚拟仪器_第2页
Exercise 0 - Open and Run a Virtual Instrument 练习0-打开并运行虚拟仪器_第3页
Exercise 0 - Open and Run a Virtual Instrument 练习0-打开并运行虚拟仪器_第4页
Exercise 0 - Open and Run a Virtual Instrument 练习0-打开并运行虚拟仪器_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Exercise0-OpenandRunaVirtualInstrument(Slide12)ExaminetheSignalGenerationandProcessingVIandrunit.Changethefrequenciesandtypesoftheinputsignalsandnoticehowthedisplayonthegraphchanges.ChangetheSignalProcessingWindowandFilteroptions.AfteryouhaveexaminedtheVIandthedifferentoptionsyoucanchange,stoptheVIbypressingtheStopbutton.1.SelectStart»Programs»NationalInstruments»LabVIEW7.0»LabVIEWtolaunchLabVIEW.TheLabVIEWdialogboxappears.2.SelectHelp»FindExamples.ThedialogboxthatappearslistsandlinkstoallavailableLabVIEWexampleVIs.3.OntheBrowseTab,selectbrowseaccordingtotask.ChooseAnalyzingandProcessingSignals,thenSignalProcessing,thenSignalGenerationandProcessing.vi.ThiswillopentheSignalGenerationandProcessingVIFrontPanel.NoteYoualsocanopentheVIbyclickingtheOpenVIbuttonandnavigatingtolabview\examples\apps\demos.llb\SignalGenerationandProcessing.vi.FrontPanel 4.ClicktheRunbuttononthetoolbar,shownatleft,torunthisVI.ThisVIdeterminestheresultoffilteringandwindowingageneratedsignal.Thisexamplealsodisplaysthepowerspectrumforthegeneratedsignal.Theresultingsignalsaredisplayedinthegraphsonthefrontpanel,asshowninthefollowingfigure.5.UsetheOperatingtool,shownatleft,tochangetheInputSignalandtheSignalProcessing,usetheincrementordecrementarrowsonthecontrol,anddragthepointertothedesiredFrequency.6.PresstheMoreInfo…buttonor[F5]toreadmoreabouttheanalysisfunctions.7.PresstheStopbuttonor[F4]tostoptheVI.BlockDiagram8.SelectWindow»ShowDiagramorpressthe<Ctrl-E>keystodisplaytheblockdiagramfortheSignalGenerationandProcessingVI.(MacOS)Pressthe<Command-E>keys.(Sun)Pressthe<Meta-E>keys.(Linux)Pressthe<Alt-E>keys.Thisblockdiagramcontainsseveralofthebasicblockdiagramelements,includingsubVIs,functions,andstructures,whichyouwilllearnaboutlaterinthiscourse.9.SelectWindow»ShowPanelorpressthe<Ctrl-E>keystoreturntotheFrontPanel.10.ClosetheVIanddonotsavechanges.EndofExercise

Exercise1–ConvertCtoFBuildaVICompletethefollowingstepstocreateaVIthattakesanumberrepresentingdegreesCelsiusandconvertsittoanumberrepresentingdegreesFahrenheit.Inwiringillustrations,thearrowattheendofthismouseiconshowswheretoclickandthenumberonthearrowindicateshowmanytimestoclick.FrontPanelSelectFile»Newtoopenanewfrontpanel.(Optional)SelectWindow»TileLeftandRighttodisplaythefrontpanelandblockdiagramsidebyside.Createanumericdigitalcontrol.YouwillusethiscontroltoenterthevaluefordegreesCentigrade.SelectthedigitalcontrolontheControls»NumericControlspalette.IftheControlspaletteisnotvisible,right-clickanopenareaonthefrontpaneltodisplayit.Movethecontroltothefrontpanelandclicktoplacethecontrol.TypedegCinsidethelabelandclickoutsidethelabelorclicktheEnterbuttononthetoolbar.Ifyoudonottypethenameimmediately,LabVIEWusesadefaultlabel.YoucaneditalabelatanytimebyusingtheLabelingtool.Createanumericdigitalindicator.YouwillusethisindicatortodisplaythevaluefordegreesFahrenheit.SelectthedigitalindicatorontheControls»NumericIndicatorspalette.Movetheindicatortothefrontpanelandclicktoplacetheindicator.TypedegFinsidethelabelandclickoutsidethelabelorclicktheEnterbutton.LabVIEWcreatescorrespondingcontrolandindicatorterminalsontheblockdiagram.Theterminalsrepresentthedatatypeofthecontrolorindicator.Forexample,aDBLterminalrepresentsadouble-precision,floating-pointnumericcontrolorindicator.NoteControlterminalshaveathickerborderthanindicatorterminals.BlockDiagramDisplaytheblockdiagrambyclickingitorbyselectingWindow»ShowDiagram.Note:BlockDiagramterminalscanbeviewedasiconsorasterminals.TochangethewayLabVIEWdisplaystheseobjectsrightclickonaterminalandselectViewAsIcon.SelecttheMultiplyandAddfunctionsontheFunctions»Numericpaletteandplacethemontheblockdiagram.IftheFunctionspaletteisnotvisible,right-clickanopenareaontheblockdiagramtodisplayit.SelectthenumericconstantontheFunctions»Numericpaletteandplacetwoofthemontheblockdiagram.Whenyoufirstplacethenumericconstant,itishighlightedsoyoucantypeavalue.Type1.8inoneconstantand32.0intheother.Ifyoumovedtheconstantsbeforeyoutypedavalue,usetheLabelingtooltoenterthevalues.UsetheWiringtooltowiretheiconsasshowninthepreviousblockdiagram.Towirefromoneterminaltoanother,usetheWiringtooltoclickthefirstterminal,movethetooltothesecondterminal,andclickthesecondterminal,asshowninthefollowingillustration.Youcanstartwiringateitherterminal.Youcanbendawirebyclickingtotackthewiredownandmovingthecursorinaperpendiculardirection.Pressthespacebartotogglethewiredirection.Toidentifyterminalsonthenodes,right-clicktheMultiplyandAddfunctionsandselectVisibleItems»Terminalsfromtheshortcutmenutodisplaytheconnectorpane.Returntotheiconsafterwiringbyright-clickingthefunctionsandselectingVisibleItems»Terminalsfromtheshortcutmenutoremovethecheckmark.WhenyoumovetheWiringtooloveraterminal,theterminalareablinks,indicatingthatclickingwillconnectthewiretothatterminalandatipstripappears,listingthenameoftheterminal.Tocancelawireyoustarted,pressthe<Esc>key,right-click,orclickthesourceterminal.DisplaythefrontpanelbyclickingitorbyselectingWindow»ShowPanel.SavetheVIbecauseyouwillusethisVIlaterinthecourse.SelectFile»Save.Navigatetoc:\exercises\LVIntro.NoteSavealltheVIsyoueditinthiscourseinc:\exercises\LVIntro.TypeConvertCtoF.viinthedialogbox.ClicktheSavebutton.EnteranumberinthedigitalcontrolandruntheVI.UsetheOperatingtoolortheLabelingtooltodouble-clickthedigitalcontrolandtypeanewnumber.ClicktheRunbuttontoruntheVI.TryseveraldifferentnumbersandruntheVIagain.SelectFile»ClosetoclosetheConvertCtoFVI.EndofExercise

Exercise2a–CreateaSubVIFrontPanelSelectFile»Openandnavigatetoc:\exercises\LVIntrotoopentheConvertCtoFVI.IfyouclosedallopenVIs,clicktheOpen…buttonontheLabVIEWdialogbox.TipClickthearrownexttoOpen…buttonontheLabVIEWdialogboxtoopenrecentlyopenedfiles,suchasConvertCtoF.vi.Thefollowingfrontpanelappears.Right-clicktheiconintheupperrightcornerofthefrontpanelandselectEditIconfromtheshortcutmenu.TheIconEditordialogboxappears.Double-clicktheSelecttoolontheleftsideoftheIconEditordialogboxtoselectthedefaulticon.Pressthe<Delete>keytoremovethedefaulticon.Double-clicktheRectangletooltoredrawtheborder.Createthefollowingicon.UsetheTexttooltoclicktheeditingarea.TypeCandF.Double-clicktheTexttoolandchangethefonttoSmallFonts.UsethePenciltooltocreatethearrow.NoteTodrawhorizontalorverticalstraightlines,pressthe<Shift>keywhileyouusethePenciltooltodragthecursor.UsetheSelecttoolandthearrowkeystomovethetextandarrowyoucreated.SelecttheB&Wiconandselect256ColorsintheCopyfromfieldtocreateablackandwhiteicon,whichLabVIEWusesforprintingunlessyouhaveacolorprinter.Whentheiconiscomplete,clicktheOKbuttontoclosetheIconEditordialogbox.Theiconappearsintheupperrightcornerofthefrontpanelandblockdiagram.Right-clicktheicononthefrontpanelandselectShowConnectorfromtheshortcutmenutodefinetheconnectorpaneterminalpattern.LabVIEWselectsaconnectorpanepatternbasedonthenumberofcontrolsandindicatorsonthefrontpanel.Forexample,thisfrontpanelhastwoterminals,degCanddegF,soLabVIEWselectsaconnectorpanepatternwithtwoterminals.Assigntheterminalstothedigitalcontrolanddigitalindicator.SelectHelp»ShowContextHelptodisplaytheContextHelpwindow.VieweachconnectionintheContextHelpwindowasyoumakeit.Clicktheleftterminalintheconnectorpane.ThetoolautomaticallychangestotheWiringtool,andtheterminalturnsblack.ClickthedegCcontrol.Theleftterminalturnsorange,andamarqueehighlightsthecontrol.Clickanopenareaofthefrontpanel.Themarqueedisappears,andtheterminalchangestothedatatypecolorofthecontroltoindicatethatyouconnectedtheterminal.ClicktherightterminalintheconnectorpaneandclickthedegFindicator.Therightterminalturnsorange.Clickanopenareaonthefrontpanel.Bothterminalsareorange.Movethecursorovertheconnectorpane.TheContextHelpwindowshowsthatbothterminalsareconnectedtofloating-pointvalues.SelectFile»SavetosavetheVIbecauseyouwillusethisVIlaterinthecourse.SelectFile»ClosetoclosetheConvertCtoFVI.EndofExercise

Exercise2b-DataAcquisitionTocompletethisexercise,youwillneedtheICtemperaturesensoravailableoneithertheBNC-2120,SCB-68,orDAQSignalAccessory.FrontPanelSelectFile»Newtoopenanewfrontpanel.Createthethermometerindicator,asshownonthefollowingfrontpanel.SelectthethermometerontheControls»NumericIndicatorspaletteandplaceitonthefrontpanel.TypeTemperatureinsidethelabelandclickoutsidethelabelorclicktheEnterbuttononthetoolbar.Right-clickthethermometerandselectVisibleItems»DigitalDisplayfromtheshortcutmenutodisplaythedigitaldisplayforthethermometer.Createtheverticalswitchcontrol.SelecttheverticaltoggleswitchontheControls»Buttonspalette.TypeTempScaleinsidethelabelandclickoutsidethelabelorclicktheEnterbutton.UsetheLabelingtooltoplaceafreelabel,degC,nexttotheTRUEpositionoftheswitch,asshowninthepreviousfrontpanel.Placeafreelabel,degF,nexttotheFALSEpositionoftheswitch.BlockDiagramSelectWindow»ShowDiagramtodisplaytheblockdiagram.Buildthefollowingblockdiagram.PlacetheDAQAssistantExpressVIlocatedontheFunctions»Inputpalette.MakethefollowingconfigurationsintheDAQAssistantconfigurationwizard.SelectAnalogInputasthemeasurementtype.SelectVoltage.Selectai0asthechannelfromyourdataacquisitiondevice.IntheTaskTimingsection,selectAcquire1sample.PlacetheConvertfromDynamicDatafunctionlocatedontheFunctions»SignalManipulationandselectSingleScalarastheResultingdatatype.PlacetheMultiplyfunctionlocatedontheFunctions»Numericpalette.ThisfunctionmultipliesthevoltagethattheAISampleChannelVIreturnsby100.0toobtaintheCelsiustemperature.SelectFunctions»SelectaVI,navigatetotheConvertCtoFVI,whichyoubuiltinExercise2a,andplacetheVIontheblockdiagram.ThisVIconvertstheCelsiusreadingstoFahrenheit.PlacetheSelectfunctionlocatedontheFunctions»Comparisonpalette.ThisfunctionreturnseithertheFahrenheit(FALSE)orCelsius(TRUE)temperaturevalue,dependingonthevalueofTempScale.Right-clicktheyterminaloftheMultiplyfunction,selectCreate»Constant,type100,andpressthe<Enter>keytocreateanothernumericconstant.UsethePositioningtooltoplacetheiconsasshowninthepreviousblockdiagramandusetheWiringtooltowirethemtogether.TipToidentifyterminalsonthenodes,right-clicktheiconandselectVisibleItems»Terminalfromtheshortcutmenutodisplaytheconnectorpane.DisplaythefrontpanelbyclickingitorbyselectingWindow»ShowPanel.ClicktheContinuousRunbutton,shownatleft,toruntheVIcontinuously.Putyourfingeronthetemperaturesensorandnoticethetemperatureincrease.ClicktheContinuousRunbuttonagaintostoptheVI.Createthefollowingicon,soyoucanusetheTemperatureVIasasubVI.Right-clicktheiconintheupperrightcornerofthefrontpanelandselectEditIconfromtheshortcutmenu.TheIconEditordialogboxappears.Double-clicktheSelecttoolontheleftsideoftheIconEditordialogboxtoselectthedefaulticon.Pressthe<Delete>keytoremovethedefaulticon.Double-clicktheRectangletooltoredrawtheborder.UsethePenciltooltodrawaniconthatrepresentsthethermometer.UsetheForegroundandFilltoolstocolorthethermometerred.NoteTodrawhorizontalorverticalstraightlines,pressthe<Shift>keywhileyouusethePenciltooltodragthecursor.Double-clicktheTexttool,shownatleft,andchangethefonttoSmallFonts.SelecttheB&Wiconandselect256ColorsintheCopyfromfieldtocreateablackandwhiteicon,whichLabVIEWusesforprintingunlessyouhaveacolorprinter.Whentheiconiscomplete,clicktheOKbutton.Theiconappearsintheupperrightcornerofthefrontpanel.SelectFile»SavetosavetheVI.ChoosealocationonyourharddriveandsavetheVIasThermometer.vi.SelectFile»ClosetoclosetheVI.EndofExercise

Exercise3–UsingLoopsUseawhileloopandawaveformcharttobuildaVIthatdemonstratessoftwaretiming.FrontPanelOpenanewVI.Buildthefollowingfrontpanel.SelectthehorizontalpointerslideontheControls»NumericControlspaletteandplaceitonthefrontpanel.Youwillusetheslidetochangethesoftwaretiming.TypemilliseconddelayinsidethelabelandclickoutsidethelabelorclicktheEnterbuttononthetoolbar,shownatleft.PlaceaStopButtonfromtheControls»Buttonspalette.SelectawaveformchartontheControls»GraphIndicatorspaletteandplaceitonthefrontpanel.Thewaveformchartwilldisplaythedatainrealtime.TypeValueHistoryinsidethelabelandclickoutsidethelabelorclicktheEnterbutton.ThewaveformchartlegendlabelstheplotPlot0.UsetheLabelingtooltotriple-clickPlot0inthechartlegend,typeValue,andclickoutsidethelabelorclicktheEnterbuttontorelabelthelegend.Therandomnumbergeneratorgeneratesnumbersbetween0and1,inaclassroomsettingyoucouldreplacethiswithadataacquisitionVI.UsetheLabelingtooltodouble-click10.0inthey-axis,type1,andclickoutsidethelabelorclicktheEnterbuttontorescalethechart.Change–10.0inthey-axisto0.Labelthey-axisValueandthex-axisTime(sec).BlockDiagramSelectWindow»ShowDiagramtodisplaytheblockdiagram.EnclosethetwoterminalsinaWhileLoop,asshowninthefollowingblockdiagram.SelecttheWhileLoopontheFunctions»ExecutionControlpalette.Clickanddragaselectionrectanglearoundthetwoterminals.UsethePositioningtooltoresizetheloop,ifnecessary.SelecttheRandomNumber(0-1)ontheFunctions»ArithmeticandComparison»Numericpalette.AlternativelyyoucoulduseaVIthatisgatheringdatafromanexternalsensor.Wiretheblockdiagramobjectsasshowninthepreviousblockdiagram.SavetheVIasUseaLoop.vibecauseyouwillusethisVIlaterinthecourse.DisplaythefrontpanelbyclickingitorbyselectingWindow»ShowPanel.RuntheVI.ThesectionoftheblockdiagramwithintheWhileLoopborderexecutesuntilthespecifiedconditionisTRUE.Forexample,whiletheSTOPbuttonisnotpressed,theVIreturnsanewnumberanddisplaysitonthewaveformchart.ClicktheSTOPbuttontostoptheacquisition.TheconditionisFALSE,andtheloopstopsexecuting.FormatandcustomizetheXandYscalesofthewaveformchart.Right-clickthechartandselectPropertiesfromtheshortcutmenu.Thefollowingdialogboxappears.ClicktheScaletabandselectdifferentstylesforthey-axis.Youalsocanselectdifferentmappingmodes,gridoptions,scalingfactors,andformatsandprecisions.NoticethatthesewillupdateinteractivelyonthewaveformchartSelecttheoptionsyoudesireandclicktheOKbutton.Right-clickthewaveformchartandselectDataOperations»ClearChartfromtheshortcutmenutoclearthedisplaybufferandresetthewaveformchart.IftheVIisrunning,youcanselectClearChartfromtheshortcutmenu.AddingTimingWhenthisVIruns,theWhileLoopexecutesasquicklyaspossible.Completethefollowingstepstotakedataatcertainintervals,suchasonceeveryhalf-second,asshowninthefollowingblockdiagram.PlacetheTimeDelayExpressVIlocatedontheFunctions»ExecutionControlpalette.Inthedialogboxthatappears,insert0.5.Thisfunctionwouldmakesurethateachiterationoccurseveryhalf-second(500ms).Dividethemilliseconddelayby1000togettimeinseconds.ConnecttheoutputofthedividefunctiontotheDelayTime(s)inputoftheTimeDelayExpressVI.Thiswillallowyoutoadjustthespeedoftheexecutionfromthepointerslideonthefrontpanel.SavetheVI,becauseyouwillusethisVIlaterinthecourse.RuntheVI.TrydifferentvaluesforthemilliseconddelayandruntheVIagain.Noticehowthiseffectsthespeedofthenumbergenerationanddisplay.ClosetheVI.EndofExercise

Exercise4-AnalyzingandLoggingDataCompletethefollowingstepstobuildaVIthatmeasurestemperatureevery0.25sfor10s.Duringtheacquisition,theVIdisplaysthemeasurementsinrealtimeonawaveformchart.Aftertheacquisitioniscomplete,theVIplotsthedataonagraphandcalculatestheminimum,maximum,andaveragetemperatures.TheVIdisplaysthebestfitofthetemperaturegraph.FrontPanelOpenanewVIandbuildthefollowi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论