Professional Documents
Culture Documents
How To Connect Simulink To Labview in Order To Collect System Data
How To Connect Simulink To Labview in Order To Collect System Data
C:\TAFiles\364TAFiles\2009C\HowToConnectSimulinkToLabView85.doc
SimulinkProcedure:
1.) 2.) 3.) 4.) 5.) 6.) OpenMatlab OpenSimulink IntheSimulinkLibraryBrowser,gotoFile>New>Model(orCtrl+N). CreateaSimulinkblockdiagrambyusingblocksfromtheLibraryBrowser. Labelblockswithauniqueanddescriptivename. Givegainsandconstantsnominalvalueswhereappropriate(thenumberinthegainorconstant willbedefault).
NOTE:BesuretoinsertaNISignalProbeintothemodel(SimulinkLibraryBrowser>NISignal Probe>SignalProbe) 7.) Oncetheblockdiagramiscomplete,SAVEthemodeltoanewfolderonthedesktop. 8.) OntheSimulinkModeltoolbar,changethesimulationfromaNORMALsimulationtoan EXTERNALsimulation(Figure1). 9.) OntheMenutab,selectSIMULATION,thenCONFIGURATIONPARAMETERS. i) UndertheSOLVERtab,changethefollowing(Figure2): (1) SolverOptions>TypetoFIXEDSTEP (2) SolverOptions>SolvertothedesiredODE NOTE:ODE5istypicallythebestonetochoose.SomeprogramsmalfunctionifODE5 isnotused.) (3) SolverOptions>FixedStepSize(Fundamentalsampletime):changeto0.01seconds (4) APPLYthechanges ii) UndertheDATAIMPORT/EXPORTtab,changethefollowing(Figure3): (1) UncheckALLboxes (2) APPLYthechanges iii) UndertheOPTIMIZATIONtab,changethefollowing(Figure4): (1) UncheckBLOCKREDUCTIONOPTIMIZATION (2) UncheckSIGNALSTORAGEREUSE (3) APPLYthechanges iv) UndertheREALTIMEWORKSHOPtab,changethefollowing(Figure5): (1) TargetSelection>RTWSystemTargetFile:BROWSEforNIDLL.TLC (2) APPLYthechanges 10.) Onceallofthechangeshavebeenmade,SelectOK. 11.) ResavetheSimulinkFile 1
12.) GototheMATLABMainScreen 13.) OntheMATLABtoolbar,BROWSEtheCURRENTDIRECTORYforthefileyousavedyourmodelto andselectit(Figure6). 14.) GobacktotheSimulinkModelandBUILDthemodelbypressingCtrl+B. 15.) Matlabwillthenbeginbuildingthemodel.Yourprocesscanbecheckedbyobservingthe COMMANDWINDOW. NOTE:IfthefinalstatementintheCOMMANDWINDOWafterthedatastopsindicatesaSUCCESS,you mayprogress.Ifthefinalstatementindicatesanythingelse,yourmodelmaybeincorrectoritmay simplyneedtobeclosedandthenreopened. 16.) RESAVEyourSimulinkmodel.
LABVIEWProcedure:
Note:BesurethatyourPXIisupandrunningalongwithanypowersupplypresent. 1.) OnceyourSimulinkmodelhasbeenbuilt,gotoLABVIEWandopenanewVI.Thedefault settingisaRealTimeVI;however,ensurethisisthecase. 2.) BuildyourVIwiththedesiredindicatorsandcontrols(Figure8). 3.) SAVEthefiletothesamelocationtowhichyousavedtheSimulinkfile. 4.) GototheLABVIEWtoolbarandgotoTOOLSandthenSITCONNECTIONMANAGER(Figure7). 5.) OncetheMANAGERopens(Figure9),selectREALTIMETARGET(Figure10). 6.) Oncethisisselected,amenuwillpopupthatasksyoutoSELECTTHEMODELDLLfilefromyour folder.Searchthroughyourfolderandselectthe.dllfile(Figures10). 7.) Oncethe.dllfileisselected,anothermenuwillopenthatwillaskyoutoADDTARGETSAND DEVICES(Figure11). 8.) SelectexistingdeviceonremotesubnetandenterIPaddress(youwillfindtheIPaddressonthe topofremoteDAQ). 9.) SelectOK. 10.) NextBROWSEforyourmodelbyselectingtheiconnexttotheCURRENTMODELspace(Figures 1213). 11.) AnothermenuwillpopupcalledSELECTMODELFILE.YouneedtogoUPONELEVELinorder tolocateyourSimulink.MDLfile(Figures1213). 12.) Selectthe.MDLfileandselectOK(Figures1213). 13.) The.DLLand.MDLlocationsshouldbeinthespacesprovidedunderMODELDLLandCURRENT MODEL,respectively(Figure14). 14.) RemainingintheSITCONNECTIONMANAGER,selecttheMAPPINGStabnearthetop. 15.) DoubleclickthegivenspacesunderMAPPEDPARAMETER/SIGNAL.Amenuwillpopupwhere youaretoselectthecorrectSimulinkparameterthatgoesalongwiththeLABVIEWLABELand TYPE. 2
NOTE:Thisisacrucialstepinthatiftheparametersaremappedwrong,thedatawillbeincorrectorthe VIwillnotfunction.ThisiswhyitisagoodideatogiveLABVIEWindicatorsandcontrolssimilarnames toyourSimulinkblocksthatwillbemapped(Figure15). 16.) Onceyourparametershavebeenmapped,clickontheHARDWAREI/Otab. 17.) ChecktheboxnexttoNIDAQ(Figure16). 18.) ClickthebuttonthatsaysCONFIGURENIDAQ. 19.) ClickingCONFIGURENIDAQwillopenanothermenuthatsaysCONFIGURENIDAQDEVICES. Thecorrectdeviceshouldalreadybehighlighted,soclickNEXT(Figure17). 20.) AnothermenuwillpopupthatsaysCONFIGUREDAQMAPPINGS.Thisiswhereyouselectyour inputandoutputchannels(Figure18). 21.) SelectaninputoroutputfromDAQCHANNELSthatyouwillbeusing.Selectthecorresponding Simulinkinput/outputfromMODELINPUTS/OUTPUTS.Whenbothboxescontainahighlighted item,selectADD.Thiswillmaptheinput/output(Figures19and20). 22.) Continuestep21foreachinputandoutputthatyoursystemwillutilize. 23.) Onceallofyourinputs/outputshavebeenmapped,clickFINISH. 24.) ThiswillbringyoubacktothemainSITCONNECTIONMANAGERscreen.Atthispointitwould bewisetodoublecheckallofyourentriesinthemanager. 25.) ClickOK. 26.) LabviewwillaskifyouwanttoBUILDyourVI.SelectYES. 27.) LabviewwillthenbuildtheVI.Thismaytakeawhile. 28.) OnceLabviewisdonebuilding,anewfeaturewillbedisplayedonthefrontpanel. NOTE:Thisisacontrolboxwhichstartsorstopsyourprograminthecollectionofdata.TheRUNkey (arrow)willstillneedtobeclickedinorderfortheVItowork.TostoptheVIordatacollection,press theREDSQUARE(Figure21). 29.) TheVIblockdiagramwillalsohavenewfeatures.Manynewblockshavebeenaddedinorder tohelpruntheprogram.DONOTALTERTHEBLOCKSUNLESSINSTRUCTEDTODOSO(Figure 22). 30.) Inordertocollectthedatafromdifferenttrials,ablockneedstobeaddedtotheblock diagram. 31.) InthebottomCASESTRUCTURE,changethecasefromFALSEtoTRUE(Figures22and23). 32.) AnotherCASESTRUCTUREwillcomeupwithallofyourindicators(Figure23). NOTE:Controlsarenotwiredtothenewblockdiagramfeatures.Thisisnormalandwillnotpreventthe controlsfromworking. 3
33.) Makesurethatalldesiredindicatorsarepresent(digital,charts,meters,etc.). 34.) RightclicktheblockdiagramtobringuptheFUNCTIONSPALLETTE. 35.) ClickonFILEI/O. 36.) SelecttheblockWRITEMEASFILE(Figure24). 37.) Amenu(CONFIGUREWRITETOMEASUREMENTFILE)willpopup(Figure25). 38.) UnderFILENAME,selecttheBROWSEiconandsearchforthesamefileforwhichyouhave beensavingallofyourfilesthusfar. 39.) Enteradescriptivenameintotheprovidedspace(CHOOSEAFILETOWRITE).Donotendthe filenameinanumber(Figures26and27). 40.) SelectOKonceyouhavenamedandfoundalocationforyourfile. 41.) IntheCONFIGUREWRITETOMEASUREMENTFILEmenu,underthesectionIFAFILEALREADY EXISTS,chooseUSENEXTAVAILABLEFILENAME(Figure28). 42.) UnderthesectionSEGMENTHEADERS,chooseONEHEADERONLY(Figure28). 43.) UnderthesectionXVALUECOLUMNS,chooseONECOLUMNONLY(Figure28). 44.) SelectOK. 45.) Droptheblockintothedesiredindicatorcase(ortheindicatorsfromwhichyouwanttocollect yourdata). 46.) ConnectawirefromtheSIGNALSinputoftheblocktothewirethatgoesintothedesired indicator(Figure29). 47.) Repeatsteps34to46foreachindicatoryouwanttocollectdatafrom. 48.) Youcannowrunyourprogram.
CommonProblems:
Youhavebuiltandrebuilttheprogramsandcannotgetyourprogramstofunctionproperly. o Possiblesolutions TurnyourPXIofffor20secondsandthenbackonagain.Toensurenotransfer ofcorruptinformation,rebuildbothyourLabviewandSimulinkfilesoncemore. Youmissedastepthatissmallandnotnoticeable. Commonmistakes: o YoudidnotchangeyourSimulinkfilefromNormaltoExternal o YoudidnotsetyourmainfileasthelocationinMATLABs CurrentDirectory o YoudidnotbuildyourSimulinkmodel(orthebuildfailed). o YoumappedthewrongSimulinkblockstothelabview indicatorsandcontrols. o Youmappedtothewronginputandoutputchannels. Yourprogramisworkingbutthedataisslowarecorrupted. o Possiblesolutions/mistakes 4
Yousavedyourfilestoaflashdriveinsteadoftothecomputer.Resaveyour filestothecomputer.
Figure1
Figure2
Figure3
Figure4
Figure5
Figure6
Figure7
10
Figure8
11
Figure9
12
Figure10
13
Figure11
14
Figure12
15
Figure13
16
Figure14
17
Figure15
18
Figure16
19
Figure17
20
Figure18
21
Figure19
22
Figure20
23
Figure21
24
Figure22
Figure23
25
Fig ure
26
24 Figure25
27
Figure26
28
Figure27
29
Figure28
30
Figure29
31