您好,欢迎来到客趣旅游网。
搜索
您的当前位置:首页Exercises1 (5)

Exercises1 (5)

来源:客趣旅游网
Exercise5-1

Objective:

ArrayExerciseVI

CompletethefollowingstepstobuildaVIthatcreatesanarrayofrandomnumbers,scalestheresultingarray,andtakesasubsetofthatfinalarray.

TocreatearraysandbecomefamiliarwiththeArrayfunctions.

FrontPanel

1.OpenanewVIandbuildthefollowingfrontpanel.

a.PlaceanarraylocatedontheControls»Array&Clusterpalette.b.LabelthearrayRandom Array.

c.PlaceadigitalindicatorlocatedontheControls»Numericpaletteinthearrayshell.d.UsethePositioningtooltoresizethearraycontroltocontain10digitalindicators.e.PressthekeywhileyouclickanddragtheRandomArraycontroltocreatetwocopiesofthecontrol.f.LabelthecopiesFinal ArrayandSubset Array.g.PlacethreedigitalcontrolsandlabelthemScaling Factor,Start Subset,and# of Elements.h.Right-clicktheStartSubsetand#ofElementscontrols,selectRepresentationfromtheshortcutmenu,andselectI32.i.Donotchangethevaluesofthefrontpanelcontrolsyet.

BlockDiagram

2.Buildthefollowingblockdiagram.

a.PlacetheRandomNumber(0-1)functionlocatedonthe

Functions»Numericpalette.Thisfunctiongeneratesarandomnumberbetween0and1.b.PlaceaForLooplocatedontheFunctions»Structurespalette.Thisloopaccumulatesanarrayof10randomnumbersattheoutputtunnel.Createaconstantof10forthecountterminal.c.PlacetheArraySubsetfunctionlocatedontheFunctions»Arraypalette.ThisfunctionreturnsaportionofanarraystartingatStartSubsetandcontaining#ofElementselements.3.SavetheVIasArray Exercise.vi.

4.Displaythefrontpanel,changethevaluesofthecontrols,andruntheVIafewtimes.TheForLooprunsfor10iterations.Eachiterationgeneratesarandomnumberandstoresitattheoutputtunnel.RandomArraydisplaysanarrayof10randomnumbers.TheVImultiplieseachvalueinRandomArraybyScalingFactortocreateFinalArray.TheVItakesasubsetofFinalArraystartingatStartSubsetfor#ofElements,anddisplaysthesubsetinSubsetArray.5.ClosetheVI.

EndofExercise5-1

Exercise5-2

Objective:

GraphWaveformArrayVI

Tocreateanarraybyauto-indexingaForLoopandtoplotthearrayonawaveformgraph.

FrontPanel

BlockDiagram

CompletethefollowingstepstobuildaVIthatgeneratesandplotsanarrayonawaveformgraphandmodifytheVItographmultipleplots.

1.OpenanewVIandbuildthefollowingfrontpanel.

a.PlaceanarraylocatedontheControls»Array&Clusterpalette.b.LabelthearrayWaveform Array.

c.PlaceadigitalindicatorlocatedontheControls»Numericpaletteinthearrayshell.d.PlaceawaveformgraphlocatedontheControls»Graphpalette.

2.Buildthefollowingblockdiagram.

Tip

Whenyouwiredatatochartsandgraphs,usetheContextHelpwindowto

determinehowtowirethem,includingwhethertouseaBuildArrayorBundlefunction,theorderoftheinputterminals,andsoon.Ingeneral,useawaveformchartforsinglescalarpoints,awaveformgraphforanarrayofyvalues,andanXYgraphforanarrayofxvaluesandanarrayofyvalues.Forexample,ifyoumovethecursoroverawaveformgraphterminalontheblockdiagram,thefollowinginformationappearsintheContextHelpwindow.SelectHelp»ExamplesandFundamentals»GraphsandChartstoaccesstheexampleWaveformGraphVI.RefertoLesson8,DataAcquisitionandWaveforms,formoreinformationaboutthewaveformdatatype.

a.SelectFunctions»SelectaVI,navigatetoc:\\exercises\\LV

Basics I,double-clicktheThermometerVI,whichyoubuiltinExercise3-2,andplacetheVIontheblockdiagram.ThisVIreturnsonepointofsimulatedtemperaturedataduringeachForLoopiteration.b.PlaceaForLooplocatedontheFunctions»Structurespalette.EachForLoopiterationgeneratesatemperaturevalueandstoresitinthetunnel.Createaconstantof100forthecountterminal.3.SavetheVIasGraph Waveform Array.vi.

4.DisplaythefrontpanelandruntheVI.TheVIplotstheauto-indexedwaveformarrayonthewaveformgraph.5.EntertheindexofanyelementintheWaveformArrayindexdisplaytoviewthevalueofthatelement.Ifyouenteranumbergreaterthanthearraysizeof100,thedisplaydims.6.UsethePositioningtooltoresizeWaveformArraytoviewmorethanoneelement.Theindicatordisplayselementsinascendingindexorder,beginningwiththeindexyouentered.7.Displaytheblockdiagram.

Inthisblockdiagram,youusethedefaultvalueoftheinitialxand∆xvalueforthewaveform.Incaseswheretheinitialxand∆xvaluearea

specificvalue,usetheBundlefunctiontospecifyaninitialxand∆xvalueforawaveformarray.8.Buildthefollowingblockdiagram.

a.PlacetheBundlefunctionlocatedontheFunctions»Clusterpalette.Thisfunctionassemblestheplotelementsintoasinglecluster.Theelementsincludetheinitialxvalue(20),the∆xvalue(0.5),andtheyarrayofwaveformdata.b.PlacetwonumericconstantslocatedontheFunctions»Numericpalettefortheinitialxvalueand∆xvalue.c.Labelthe∆xconstantbytypingDx.UsetheLabelingtooltoselecttheDandselecttheSymbolfontfromtheTextSettingspull-downmenuonthetoolbar.Dconvertstothedeltasymbol(∆).9.Displaythefrontpanel.10.SaveandruntheVI.

Thegraphdisplaysthesame100pointsofdatawithastartingvalueof20anda∆xof0.5foreachpointonthex-axis.Inatimedtest,thisgraphwouldcorrespondto50secondsworthofdatastartingat20seconds.

11.Right-clickthewaveformgraphandselectVisibleItems»GraphPalettefromtheshortcutmenutodisplaythegraphpalette.ClicktheZoombuttontoseethedataonthegraphinmoredetail.12.Right-clickthegraphandselectVisibleItems»ScaleLegendfromtheshortcutmenutodisplaythescalelegend.13.Displaytheblockdiagram.

14.Changex0and∆xto0and1,respectively.

15.Displaythefrontpanelandchangethescaleformatting,asshowninthefollowingfrontpanel.

Changetheinitialxand∆xvaluesinonlyonelocation,eithertheBundlefunctionorXScale»Formatting.

Note

a.Right-clickthewaveformgraphandselectXScale»Formattingfromtheshortcutmenu.b.ChangeFormattoTime&Date.c.MakesureHH:MM:SSisselected.

d.ChangetheScalingFactorstoanXoof7:30:00.00 AM

01/15/2000andadXof0:10:00.00.e.ClicktheOKbuttontoapplythechanges.

Ifthex-axistextisnotvisible,usethePositioningtooltodecreasethesizeoftheinnerdisplay(blackarea)ofthegraph.f.SaveandruntheVI.

Multiple-PlotGraphs

Completethefollowingstepstocreateamultiple-plotwaveformgraphbybuildinga2Darrayofthedatatypenormallypassedtoasingle-plotgraph.16.Buildthefollowingblockdiagram.

a.PlacetheSinefunctionlocatedontheFunctions»Numeric»

Trigonometricpalette.Usethisfunctiontobuildanarrayofpointsthatrepresentsonecycleofasinewave.b.PlacetheBuildArrayfunctionlocatedontheFunctions»Arraypalette.Thisfunctioncreatesthedatastructuretoplottwoarraysonawaveformgraph.c.PlacethepiconstantlocatedontheFunctions»Numeric»AdditionalNumericConstantspalette.d.PlacetheNumericfunctionsandcreatethenumericconstants,asshowninthepreviousblockdiagram.17.Displaythefrontpanel.

18.SaveandruntheVI.Thetwowaveformsplotonthesamewaveformgraph.19.Displaytheblockdiagram.

20.Right-clickthewiretoWaveformArray,selectCustomProbe»

Graphfromtheshortcutmenu,andselectawaveformgraphtoplaceagraphprobeonthewire.21.DisplaythefrontpanelandruntheVI.Theprobeshowsonlythedataarray.Thesinewaveisnotpresentbecauseyoudidnotplacetheprobeonthewiretowhichthesinewaveisbundled.22.ClosetheProbewindow.23.Zoominonaportionofthegraph.

a.ClicktheZoombuttononthegraphpalette,shownatleft,todisplaythefollowingpull-downmenu.

b.SelectZoombyXRectangle,asshown.

c.Clickanddragaselectionrectangleonthegraph.Whenyoureleasethemousebutton,thegraphdisplayzoomsinontheselectedarea.d.YoualsocanselectZoombyYRectangleorZoombySelectedArea.Experimentwiththeseoptions.e.SelectUndoZoomfromthelowerleftcornerofthepull-downmenutoundoazoomorclickthex-axissinglefitbuttonandthey-axissinglefitbuttononthescalelegend,shownatleft.

24.UsethePanningtool,shownatleft,toclickanddragthegraphdisplay.Clickthex-axisandy-axissinglefitbuttonsagaintorestorethedisplaytoitsoriginalposition.25.UsetheCursorMovementtool,shownatleft,toreturnthecursortostandardmode.26.SaveandclosetheVI.

EndofExercise5-2

Exercise5-3

Objective:

TemperatureAnalysisVI

Tographandanalyzedata.

FrontPanel

CompletethefollowingstepstobuildaVIthatmeasurestemperatureevery0.25sfor10s.Duringtheacquisition,theVIdisplaysthemeasurementsinrealtimeonawaveformchart.Aftertheacquisitioniscomplete,theVIplotsthedataonagraphandcalculatestheminimum,maximum,andaveragetemperatures.TheVIdisplaysthebestfitofthetemperaturegraph.

1.OpenanewVIandbuildthefollowingfrontpanelusingthefollowingtips.

•Setthepointstyleofthewaveformchartplottoasmallx.•Hidetheplotlegendofthewaveformchart.

Right-clickthewaveformchart,selectXScale»Formattingfromtheshortcutmenu,andchangedXto0.25andDigitsofPrecisionto2.

•UsethePositioningtooltoresizetheplotlegendofthewaveformgraph.

UsetheLabelingtooltorenamePlot 0toTempandPlot 1toFitted.

••

SetthepointstyleofthewaveformgraphTempplottoasmallsquare.

DonotcreatetheMean,Max,andMinindicatorsyet.

BlockDiagram

2.Buildthefollowingblockdiagram.

a.SelectFunctions»SelectaVI,navigatetoc:\\exercises\\LV

Basics I,double-clicktheThermometerVI,whichyoubuiltinExercise3-2,andplacetheVIontheblockdiagram.ThisVIreturnsonepointofsimulatedtemperaturedata.b.PlacetheWaitUntilNextmsMultiplefunctionlocatedontheFunctions»Time&Dialogpaletteandcreateaconstantof250.ThisfunctioncausestheForLooptoexecuteevery0.25s(250ms).c.PlacetheArrayMax&MinfunctionlocatedontheFunctions»Arraypalette.Thisfunctionreturnsthemaximumandminimumtemperature.d.PlacetheMeanVIlocatedontheFunctions»Mathematics»ProbabilityandStatisticspalette.ThisVIreturnstheaverageofthetemperaturemeasurements.e.Right-clicktheoutputterminalsoftheArrayMax&MinfunctionandMeanVIandselectCreate»IndicatorfromtheshortcutmenutocreatetheMax,Min,andMeanindicators.f.PlacetheGeneralPolynomialFitVIlocatedontheFunctions»Mathematics»CurveFittingpalette.ThisVIreturnsanarraythatisapolynomialfittothetemperaturearray.

g.PlacetheBundlefunctionlocatedontheFunctions»Cluster

palette.Pressthekeywhileyoudragthefunctiontocopyit.Thisfunctionassemblestheplotelementsintoasinglecluster.Theelementsincludetheinitialxvalue(0),the∆xvalue(0.25),andtheyarrayoftemperaturedata.The∆xvalueof0.25isrequiredsothattheVIplotsthetemperaturearraypointsevery0.25sonthewaveformgraph.h.PlacetheBuildArrayfunctionlocatedontheFunctions»Arraypalette.Thisfunctioncreatesanarrayofclustersfromthetemperatureclusterandthebestfitcluster.3.SavetheVIasTemperature Analysis.vi.4.DisplaythefrontpanelandruntheVI.

Thegraphdisplaysboththetemperaturedataandbestfitcurveofthetemperaturewaveform.

5.TrydifferentvaluesforthepolynomialorderconstantontheblockdiagramandruntheVIagain.6.Changetheappearanceofplotsbymodifyingtheplotstylesandfillstyles.a.Right-clicktheTempplotdisplayintheplotlegendandselectCommonPlots»ScatterPlotfromtheshortcutmenu,thetopmiddleoption.b.Right-clicktheFittedplotdisplayintheplotlegend,selectBarPlotsfromtheshortcutmenu,andselectthesecondoptioninthemiddlerow.Thewaveformgraphshouldappearsimilartothefollowingwaveformgraph.

7.SaveandclosetheVI.

EndofExercise5-3

Exercise5-4

Objective:

GraphCircleVI(Optional)

CompletethefollowingstepstobuildaVIthatplotsacircleusingindependentxandyarrays.

ToplotdatausinganXYGraph.

FrontPanel

1.OpenanewVIandbuildthefollowingfrontpanel.

a.PlaceanXYGraphlocatedontheControls»Graphpalette.b.LabelthegraphXY Circle Graph.c.ChangePlot 0toCircleintheplotlegend.

d.Right-clicktheplotintheplotlegend,selectPointStylefromthe

shortcutmenu,andselectthesmallsquare.e.Changethescalelabelsandranges,asshowninthepreviousfrontpanel.

BlockDiagram

2.Buildthefollowingblockdiagram.

a.PlacetheSine&CosinefunctionlocatedontheFunctions»

Numeric»Trigonometricpalette.Thisfunctionbuildsanarrayofpointsthatrepresentsonecycleofasinewaveandacosinewave.b.PlacetheBundlefunctionlocatedontheFunctions»Cluster

palette.Thisfunctionassemblesthesinearrayandthecosinearraytoplotthesinearrayagainstthecosinearraytoproduceacircle.c.PlacethePiMultipliedby2constantlocatedontheFunctions»Numeric»AdditionalNumericConstantspalette.3.SavetheVIasGraph Circle.vi.4.DisplaythefrontpanelandruntheVI.5.ClosetheVI.

EndofExercise5-4

Exercise5-5

Objective:

ClusterExerciseVI

TocreateclustersonthefrontpanelandusetheClusterfunctionstoassembleanddisassembleclusters.

FrontPanel

1.OpenanewVIandbuildthefollowingfrontpanel.

a.PlaceaStopbutton,digitalindicator,androundLED.

b.PlaceaclusterlocatedontheControls»Array&Clusterpalette.c.Placethefourfrontpanelobjectsinthecluster.

d.CreateModifiedClusterbyduplicatingCluster,relabelingit,andright-clickingtheshell,andselectingChangetoIndicatorfromtheshortcutmenu.e.RepeatstepdtocreateSmallClusterandchangetheindicatorsasshowninthepreviousfrontpanel.2.VerifytheclusterorderofClusterandSmallCluster.ModifiedClustershouldhavethesameorderasCluster.a.Right-clicktheboundaryofeachclusterandselectReorderControlsinClusterfromtheshortcutmenu.b.Setthefollowingclusterorders.

BlockDiagram

3.Buildthefollowingblockdiagram.

a.PlacetheUnbundlefunctionlocatedontheFunctions»Clusterpalette.ThisfunctiondisassemblesCluster.Resizethisfunctiontofouroutputterminalsorwiretheinputclustertoresizethefunctionautomatically.b.PlacetheBundlefunctionlocatedontheFunctions»Clusterpalette.ThisfunctionassemblesSmallCluster.c.PlacetheUnbundlebyNamefunctionlocatedontheFunctions»Clusterpalette.ThisfunctionreturnstwoelementsfromCluster.Resizethisfunctiontohavetwooutputterminals.Ifthelabelnamesarenotcorrect,right-clickthenameandselectthecorrectonefromtheSelectItemshortcutmenu.d.PlacetheIncrementfunctionlocatedontheFunctions»Numericpalette.ThisfunctionaddsonetothevalueofNumeric.

e.PlacetheNotfunctionlocatedontheFunctions»Booleanpalette.

ThisfunctionreturnsthelogicaloppositeofthevalueofBoolean.f.PlacetheBundlebyNamefunctionlocatedontheFunctions»Clusterpalette.ThisfunctionreplacesthevaluesofNumericandBooleaninClusterandcreatesModifiedCluster.Resizethisfunctiontohavetwoinputterminals.Ifthelabelnamesarenotcorrect,right-clickthenameandselectthecorrectonefromtheSelectItemshortcutmenu.g.Right-clicktheconditionalterminaloftheWhileLoopandselectStopIfTruefromtheshortcutmenu.TheVIstopswhenyouclicktheStopbutton.4.SavetheVIasCluster Exercise.vi.5.DisplaythefrontpanelandruntheVI.

6.EnterdifferentvaluesinClusterandruntheVIagain.7.ClosetheVI.

EndofExercise5-5

Exercise5-6

Objective:

ClusterScalingVI(Optional)

TobuildaVIthatusespolymorphismwithclusters.

FrontPanel

BlockDiagram

CompletethefollowingstepstobuildaVIthatscalesvaluesstoredinacluster,whereeachclusterelementhasadifferentscalefactor.Assumethatthevoltagesweremeasuredfromtransducersthatmeasurethepressure,flowrate,andtemperature.TheVIthenscalesthesevaluestogettheactualvaluespresentinthesystem.

1.OpentheClusterScalingVI.Thefrontpanelisalreadybuilt.2.Changethefrontpanelcontrolsasshown.

3.Buildthefollowingblockdiagram.MakesureyouapplythecorrectscalefactorstoeachelementintheRawDatacluster.

4.SaveandruntheVI.

5.ChangethefrontpanelcontrolsandruntheVIagain.6.ClosetheVI.

EndofExercise5-6

AdditionalExercises

5-7

BuildaVIthatreversestheorderofanarraycontaining100randomnumbers.Forexample,array[0]becomesarray[99],array[1]becomesarray[98],andsoon.

Tip

UsetheReverse1DArrayfunctionlocatedontheFunctions»Arraypalettetoreversethearrayorder.

SavetheVIasReverse Random Array.vi.5-8

BuildaVIthatfirstaccumulatesanarrayoftemperaturevaluesusingtheThermometerVI,whichyoubuiltinExercise3-2.Setthearraysizewithacontrolonthefrontpanel.InitializeanarrayusingtheInitializeArrayfunctionofthesamesizewhereallthevaluesareequalto10.Addthetwoarrays,calculatethesizeofthefinalarray,andextractthemiddlevaluefromthefinalarray.DisplaytheTemperatureArray,InitializedArray,FinalArray,andMidValue.

SavetheVIasFind Mid Value.vi.

5-9

BuildaVIthatgeneratesa2Darrayofthreerowsby10columnscontainingrandomnumbers.Aftergeneratingthearray,indexeachrowandploteachrowonitsowngraph.Thefrontpanelshouldcontainthreegraphs.

SavetheVIasExtract 2D Array.vi.5-10

Challenge

BuildaVIthatsimulatestherollofadiewithpossiblevalues1–6andrecordsthenumberoftimesthatthedierollseachvalue.Theinputisthenumberoftimestorollthedieandtheoutputsincludethenumberoftimesthediefallsoneachpossiblevalue.Useonlyoneshiftregister.

SavetheVIasDie Roller.vi.

5-11

Challenge

BuildaVIthatgeneratesa1Darrayandthenmultipliespairsofelementstogether,startingwithelements0and1,andreturnstheresultingarray.Forexample,theinputarraywithvalues1 23 10 5 7 11resultsintheoutputarray23 50 77.

TipUsetheDecimate1DArrayfunctionlocatedontheFunctions»Arraypalette.

SavetheVIasArray Pair Multiplier.vi.

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- kqyc.cn 版权所有 赣ICP备2024042808号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务