LabView An Easy Introduction.docx
- 文档编号:28631523
- 上传时间:2023-07-19
- 格式:DOCX
- 页数:10
- 大小:659.97KB
LabView An Easy Introduction.docx
《LabView An Easy Introduction.docx》由会员分享,可在线阅读,更多相关《LabView An Easy Introduction.docx(10页珍藏版)》请在冰豆网上搜索。
LabViewAnEasyIntroduction
LabView,AnEasyIntroduction
Day1
WhatisLabViewandWhydopeopleuseit?
LabViewisagraphicalprogramminglanguagedevelopedbyNationalInstrumentssometimeinthemidtolate80’sbyJeffKodosky.AprograminLabViewiscalledaVI,whichstandsforVirturalInstrument.TocreateaVI,theprogrammerusestheLabViewprogrammingenvironmenttomaketheuserinterfacebydragginganddroppingobjects,andarrangingthemasdesired.Toaddfunctionalitytotheinterface,thediagram,whichresemblesaflowchartis“wired”withthevariousstructuresandfunctions.So,inmostLabViewprograms,nolinesofcodearewritten,thefunctionalityoftheprogramisprovidedbythediagram.ForthisreasonLabViewiscalledagraphicalprogramminglanguage.
AnothernicetyofLabViewisthatitcloselysupportsamultitudeofprocessingcardsavailablefromNationalInstruments.OthervendorsalsobuildcardsthatareLabViewcompatible.ThecardsaresotightlycoupledtotheLabViewsystemthatitisnotuncommontobecollectingdatawithinafewhoursofreceivingthedatacollectioncardsinthemail.
Forthesereasons,LabViewhasbecomeoneofthemostpopulardatacollectionsystemsinrecentyears.WithintheframeworkofLabview,userinterfacescanbecreated,datacanbecollected,signalscanbegeneratedandtransmittedfromLabViewcards,datacanbeanalyzedandstored,etc.etc.IfLabViewdoesnotprovidewhatisneeded,CcodeorMatLabprogramscanbetiedtoittoprovidetherequiredfunctionality.
Insummary,LabViewisapowerfulgraphicalprogrammingsystemthatiscompatiblewithamultitudeofdatacollectioncardsandequipment.Peopleuseitbecauseitisconvenientandnoknowledgeofconventionalprogramminglanguagesisrequired.
1-1to1-2,GettingStartedwithLabView
1-2,LabViewTutorialManual
1,LabView,DataAcquisition&AnalysisfortheMovementSciences
GettingStarted
∙Demoofbasicrandom.vi
∙Userinterfaceofrandom.vi.Noticeeventhoughitissimple,tohandprogramthisinterfaceinCwouldrequirealittlework.Withoutgraphicslibrariesavailable,itwouldreaquirealotofwork.
∙Diagram.Hereiswhereto“coding”isdone.Allthevariablesandprogrammaticstructuresarerepresentedpictorially.Ifyouhadaccessarandomnumbergeneratorandagraphingfunction,couldyousketchoutthealgorithmforthisprogram?
∙DemonstrationoftheLabViewprogrammingenvironment.
oBuildtheuserinterface.(Watchtheinstructor)
oGototheDiagram.Noticetheobjectsthatwereplacedontothescreenintheuserinterfaceareinthediagramindifferentcolors.
▪Colorsaredifferentforeachdatatype.
▪Aboldbordermeansthatavariableisa“control”.Acontrolprovidesinput.
▪Anonboldbordermeansthatavariableisan“indicator”.Anindicatorprovidesoutput.
oWiretheDiagramusingthewiringtool.Noticethelittlearrowisbrokenwhentherearemistakes.
oRunit.(clickonthewhitearrowattheupperleftofthediagram)
DetailedinstructionsforaverysimilarVIaregivenonthepagesindicatedbelow.
Page2-4,GettingStartedwithLabView
Page3-3,LabViewTutorialManual
Numbers
ThebestwaytolearnLabViewisbydoingit.Agoodplacetostartisbywritingsomeprogramsusingthebasicdatatypes.Numberareprettybasicsothat’sagoodplacetostart.
Firstoff,numbers,whetherinmathorincomputers,comeinafewdifferentways.Forcomputers,wearemostlyconcernedwithintegerorrealnumbers.Realnumbershavedecimals,integersdon’t.
3.14….
Thisisarealnumberbecauseithasadecimal.Ifyouwereinalgebra2,theywouldsayitisirrational,butsincewehavetoestimatepi’svalue,werepresentitasarealnumber.(pi,oneofmyfavoritefoods,uhnumbers)
7
Thisaninteger.Itisalsotheminimumnumberoficecreamsahealthypersonshouldeatinaweek.
InLabViewtherearereal,integer,unsignedinteger,andcomplexnumbers.Thereareseveralsizesforeach.Bysizewemeanthenumberofbitsusedtorepresentthenumber.Thisisnothingtoworryabout.Whenindoubt,pickI32forintegers,anddoubleforrealnumbers.
∙Numbers.vi.Seethefigurebelow.Comparedtothebasicrandom.viitisdull,butitsdiagramshowshowtousesomeofthevariousnumericoperatorsprovidedbyLabView.
∙Lookingatthenumbers.viinterface,noticethatXandYhaveupdownarrowsnexttothem,thatmeanstheyarecontrols.Controlsacceptinputs.Sum,difference,productandquotientdonot.Theyareindicators,theydisplayoutput.
∙AllthecontrolscomefromtheControls/Numericpallet.XandYaredigitalcontrols.Sum,difference,product,andquotientaredigitalindicators.
∙Tomaketheinterface,youclickonadigitalcontrolanddropitontotheinterfacewhereyouwantit.Rightafteryoudropitonyoucangiveitaname.YoucanchangethenameanytimebyclickingontheAinthetoolspalletandhighlightingthenameandthenchangingit,orbyclickingonMr.Handinthetoolspalletandclickingonthevariablenameinthediagram.Acursorwillappearandthenamecanbechanged.
∙Lookatthediagram.XandYhaveboldboxesaroundthem,againindicatingtheyarecontrols.TheirboxessayI16,meaningthattheyare16bitintegers.Thatmeanstheyareintegerswitharangefrom–32kto+32k.Thelinesandboxesassociatedwiththemareblue,forinteger.
∙Thedotsonthewiresindicatejunctions.
∙Allthemathoperationsaccepttwoinputsandhaveoneoutput.
∙ThemathoperatorsarefoundundertheFunctions/Numericpalette.
∙Towirethediagramthelittlewirespoolfromthetoolspalletisselected.Towireyouclickonwhereyouwantthewiretostart(leftclick)andthentracethewiretoitdestinationandletgoofthemousebutton.Ifthewireiscorrectitstracewillbethecolorwhereitstarted.Ifnotitwillbeadashedline.
∙Runningitisfun.Onethingtoremember,whenoperatingaVI,youneedtouseMr.Handfromthetoolspalette.ThearrowwillruntheVI,butifyoutrytoputinputintoacontrolusingthearrowitwilljustmovethecontrolaround.Thatmaynotbewhatyouwanttodo.
Numbers(formula)
Sometimesusingthegraphicoperatorsofmathoperationscangethardtounderstand.Forexample,ifanequationhasmanyparts,thentherecouldbewiresgoingeverywhere.Anoteofcaution,whiledoingVI’sitiseasytounderstandwhatisbeingdoneatthemoment,butwhenlookingatcomplexVI’s,itcanbehardtounderstandlater.Thisappliesdoublywhenlookingatsomeoneelse’swork.Seefigurebelow.
Althoughthislooksridiculous,whatisshownisreallyonlyabout1/8thoftheVI’sdiagram.
Usingtheformulanode,complexmathoperationscanbetidiedupabit.Belowthenumbersformula.viisshownalongwithitsdiagram.Thisprogramdoesthesamethingasthenumbersprogram,butthediagramismuchdifferent.
∙Theuserinterfaceisthesameasnumbers.vi.
∙Theformulastructurereplacesthenumericoperators.
∙ItisfoundundertheFunctions/Stucturespalette.
∙Theformulastructurehasinputsandoutputs.Tomakethemyouhavetorightclickontheborderoftheboxandhitthe“addinput”or“addoutput”menuitem.
∙TotypeformulasintotheboxyouhavetoselectMr.HandfromtheToolspallete.Rememberanyvariablesusedintheformulaboxmustbedefined,meaningtheyhavetobeaninputoranoutputthatwasdefinedbyclickingontheedgeofthebox.
∙Aftertheformulasaretypedin,allthat’sleftiswiringuptheinputsandoutputs.
∙RunningitgivesthesameresultsastheearlierVI.
BasicBooleanLogic
ThenextVIistheBooleanequivalentofnumber.vi.Booleanlogicisakindoflogicthatisusuallyassociatedwithbinaryoperations.
ThebasicBooleanfunctionsareAND,OR,andNOT.TheonethatwillbeofconcernimmediatelyisNOT.
InLabViewtheNOTfunctionusuallyhasasinglebitinput.NOTcanthoughtofasafunctionthatproducestheoppositeofitsinput.
So
NOT(0)=1
NOT
(1)=0
UsuallytheNOTfunctionisusedtocontrolWHILEloops.Moreonthatsoon.BelowisthebasicBoolean.vianditsdiagram.
∙TheBooleaninterfaceobjectsandfunctionsarefoundunderControls/BooleanandFunctions/Boolean.Thecontrolsarepushbuttons,theindicatorsareroundLEDs.
∙InthediagramthefunctionsaretheAND,ORandNOTfunctions.
∙ThefollowingaretablesforBooleanfunctions.
oAND
▪1AND1=1
▪0AND1=0
▪1AND0=0
▪0AND0=0
oOR
▪1OR1=1
▪0OR1=1
▪1OR0=1
▪0OR0=0
oNOT
▪NOT
(1)=0
▪NOT(0)=1
Exercises
TrytomaketheseVI’s.Thediagramswillbepresentedinthenextlecture.
∙Addfivenumbers.
∙Addfivenumbers,inputwithsliders.
∙Averagefivenumbers,inputwithsliders,showsumwithadial,averagewithatempgauge.
∙Averagefivenumbers,inputwithsliders,showsumwithadial,averagewithatempgauge,tryaformulastructure.
∙MakeaFahrenheittoCelsius,andpoundstokilostoconverter.
Pounds=(2*Kilos)*1.1
Celsius=(F–32)*5/9
Heresthelastonetotry.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- LabView An Easy Introduction