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

Exercises1 (6)

来源:客趣旅游网
Exercise6-1

Objective:

SquareRootVI

CompletethefollowingstepstobuildaVIthatcheckswhetheranumberispositive.Ifitis,theVIcalculatesthesquarerootofthenumber.Otherwise,theVIreturnsanerrormessage.

TousetheCasestructure.

CautionDonotrunthisVIcontinuously.

FrontPanel

BlockDiagram

1.OpenanewVIandbuildthefollowingfrontpanel.

2.Buildthefollowingblockdiagram.

a.PlaceaCasestructurelocatedontheFunctions»Structurespalette.b.ClickthedecrementandincrementarrowbuttonstoselecttheFALSEcase.c.PlacetheGreaterorEqualto0?functionlocatedontheFunctions»Comparisonpalette.ThisfunctionreturnsTRUEifNumericisgreaterthanorequalto0.d.Right-clickthenumericconstantandselectFormat&Precisionfromtheshortcutmenu.SetDigitsofPrecisionto1,selectFloatingPointNotation,andclicktheOKbutton.e.PlacetheOneButtonDialogfunctionlocatedontheFunctions»Time&Dialogpalette.ThisfunctiondisplaysadialogboxthatcontainsthemessageError...Negative Number.f.Right-clickthemessageterminaloftheOneButtonDialogfunction,

selectCreate»Constantfromtheshortcutmenu,type

Error...Negative Number,andpressthekey.RefertoLesson7,StringsandFileI/O,formoreinformationaboutstrings.

g.SelecttheTRUEcaseandplacetheSquareRootfunctionlocatedontheFunctions»Numericpalette,asshowninthefollowingblockdiagram.ThisfunctionreturnsthesquarerootofNumeric.

3.SavetheVIasSquare Root.vi.4.DisplaythefrontpanelandruntheVI.

IfNumericispositive,theVIexecutestheTRUEcaseandreturnsthesquarerootofNumeric.IfNumericisnegative,theVIexecutestheFALSEcase,returns–99999.0,anddisplaysadialogboxwiththemessageError...Negative Number.5.ClosetheVI.

EndofExercise6-1

Exercise6-2

Objective:

TemperatureControlVI

CompletethefollowingstepstobuildaVIthatdetectswhenatemperatureisoutofrange.Ifthetemperatureexceedsthelimit,anLEDturnsonandabeepsounds.

TousetheCasestructure.

FrontPanel

1.OpentheTemperatureRunningAverageVI,whichyoubuiltinExercise4-5.2.Modifythefrontpanelasfollows.

3.Right-clickthechartdisplayandselectVisibleItems»DigitalDisplay

fromtheshortcutmenutodisplaythedigitalvalues.4.SavetheVIasTemperature Control.vi.

BlockDiagram

5.Modifytheblockdiagramasfollows.TheFALSEcaseoftheCasestructureisempty.

a.PlacetheGreater?functionlocatedontheFunctions»Comparisonpalette.ThisfunctionreturnsTRUEifthetemperatureexceedsHighLimit.Otherwise,thefunctionreturnsFALSE.b.PlacetheBeepVIlocatedontheFunctions»Graphics&

Sound»Soundpalette.ThisVIsoundsabeepiftheselectorterminaloftheCasestructurereceivesTRUE.c.(Macintosh)ProvidevaluesfortheBeepVIinputterminals.6.SavetheVI,becauseyouwillusethisVIlaterinthecourse.7.Displaythefrontpanel,enter80inHighLimit,andruntheVI.IftheVIreturnsatemperaturegreaterthanHighLimit,Warningturnson,theVIexecutestheTRUEcase,andabeepsounds.Ifthe

temperatureislessthanHighLimit,Warningturnsoff,theVIexecutestheFALSEcase,andnobeepsounds.8.ClosetheVI.

EndofExercise6-2

Exercise6-3

Objective:

TimetoMatchVI

TousetheSequencestructure.

FrontPanel

BlockDiagram

CompletethefollowingstepstobuildaVIthatcomputesthetimeittakestogeneratearandomnumberthatmatchesanumberyouspecify.

1.OpentheAutoMatchVI,whichyoubuiltinExercise4-3.2.Modifythefrontpanelasfollows.

a.ChangeNumbertoMatch,CurrentNumber,and#ofiterationstoI32representation.b.ChangeTimetoMatchtoDBLrepresentationand3digitsofprecision.3.SavetheVIasTime to Match.vi.

4.Modifytheblockdiagramasfollows.

a.PlaceaSequencestructurelocatedontheFunctions»Structurespalette.b.Right-clickthestructureborderandselectAddFrameAfterfromtheshortcutmenutoaddaframe.c.PlacetheTickCount(ms)functionlocatedontheFunctions»Time&Dialogpalette.Thisfunctionreadsthecurrentvalueoftheoperatingsystemclockandreturnsthevalueinmilliseconds.5.SavetheVI.

6.Displaythefrontpanel,enteranumberinNumbertoMatch,andruntheVI.Inframe0,theVIexecutestheWhileLoopwhileCurrentNumberdoesnotmatchNumbertoMatch.Inframe1,theTickCount(ms)functionreadstheoperatingsystemclock.TheVIsubtractsthenewvaluefromtheinitialtimereadandreturnstheelapsedtimeinseconds.

IfTimetoMatchisalways0.000,theVImightberunningtooquickly.EitherruntheVIwithexecutionhighlightingenabledorincreasethenumericconstantwiredtotheMultiplyfunctioninframe0toalargevalue,suchas1000000.

Note

7.ClosetheVI.

EndofExercise6-3

Exercise6-4

Objective:

FormulaNodeExerciseVI

CompletethefollowingstepstobuildaVIthatusestheFormulaNodetoperformacomplexmathematicaloperationandgraphstheresults.

TousetheFormulaNode.

FrontPanel

1.OpenanewVIandbuildthefollowingfrontpanel.

BlockDiagram

2.Buildthefollowingblockdiagram.

a.PlacetheFormulaNodelocatedontheFunctions»Structurespalette.b.Createthexinputterminalbyright-clickingtheleftborderandselectingAddInputfromtheshortcutmenu.c.Createtheyandaoutputterminalsbyright-clickingtherightborderandselectingAddOutputfromtheshortcutmenu.Youmustcreateoutputterminalsfortemporaryvariableslikea.

Whenyoucreateaninputoroutputterminal,youmustuseavariablenamethatexactlymatchestheoneintheequation.Variablenamesarecasesensitive.

Note

d.TypethefollowingequationsintheFormulaNode,where**istheexponentiationoperator.RefertotheLabVIEWHelpformoreinformationaboutsyntaxfortheFormulaNode.

a = tanh(x) + cos(x);y = a**3 + a;

3.SavetheVIasFormula Node Exercise.vi.

4.DisplaythefrontpanelandruntheVI.Thegraphdisplaystheplotoftheequationy=f(x)3+f(x),wheref(x)=tanh(x)+cos(x).Duringeachiteration,theVIdividestheiterationterminalvalueby15.0.ThequotientiswiredtotheFormulaNode,whichcalculatesthefunctionvalue.TheVIplotsthearrayasagraph.5.ClosetheVI.

EndofExercise6-4

AdditionalExercises

6-5

6-6

6-7

6-8

Challenge

BuildaVIthatusestheFormulaNodetocalculatethefollowingequations:y1=x3+x2+5y2=mx+b

UseonlyoneFormulaNodeforbothequationsanduseasemicolon(;)aftereachequationinthenode.SavetheVIasEquations.vi.BuildaVIthatfunctionslikeacalculator.Onthefrontpanel,usedigitalcontrolstoinputtwonumbersandadigitalindicatortodisplaytheresultoftheoperation(Add,Subtract,Divide,orMultiply)thattheVIperformsonthetwonumbers.Useaslidecontroltospecifytheoperationtoperform.SavetheVIasCalculator.vi.ModifytheSquareRootVI,whichyoubuiltinExercise6-1,sotheVIperformsallcalculationsandconditioncheckingusingtheFormulaNode.

SavetheVIasSquare Root 2.vi.BuildaVIthathastwoinputs,ThresholdandInputArray,andoneoutput,OutputArray.OutputArraycontainsvaluesfromInputArraythataregreaterthanThreshold.SavetheVIasArray Over Threshold.vi.

CreateanotherVIthatgeneratesanarrayofrandomnumbers

between0and1andusestheArrayOverThresholdVItooutputanarraywiththevaluesgreaterthan0.5.

SavetheVIasUsing Array Over Threshold.vi.

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

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

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

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