Вы находитесь на странице: 1из 31

1

HOWTOCONNECTSIMULINKTOLABVIEWINORDERTOCOLLECT
SYSTEMDATA
C:\TAFiles\364TAFiles\2009C\HowToConnectSimulinkToLabView85.doc
SimulinkProcedure:
1.) OpenMatlab
2.) OpenSimulink
3.) IntheSimulinkLibraryBrowser,gotoFile>New>Model(orCtrl+N).
4.) CreateaSimulinkblockdiagrambyusingblocksfromtheLibraryBrowser.
5.) Labelblockswithauniqueanddescriptivename.
6.) 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
2

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.

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.
4

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
5

Yousavedyourfilestoaflashdriveinsteadoftothecomputer.Resaveyour
filestothecomputer.

Figure1

Figure2
7

Figure3
8

Figure4
9

Figure5

Figure6
10

Figure7
11

Figure8
12

Figure9
13

Figure10
14

Figure11
15

Figure12
16

Figure13
17

Figure14
18

Figure15
19

Figure16
20

Figure17
21

Figure18
22

Figure19
23

Figure20
24

Figure21
25

Figure22

Figure23
26

Fig
ure
27

24
Figure25
28

Figure26
29

Figure27
30

Figure28
31

Figure29

Вам также может понравиться