My Note for MatlabSimulink.docx
- 文档编号:11586028
- 上传时间:2023-03-19
- 格式:DOCX
- 页数:22
- 大小:982.82KB
My Note for MatlabSimulink.docx
《My Note for MatlabSimulink.docx》由会员分享,可在线阅读,更多相关《My Note for MatlabSimulink.docx(22页珍藏版)》请在冰豆网上搜索。
MyNoteforMatlabSimulink
HydraulicSimulationUsingSimulink
1.Simulink-S-PSandPS-SConverter
(1)S-PSconverter
It’sfunctionisconvertingsimulink(S)signalintophysical(P)signal.
(2)PS-Sconverter
IthastheoppositefunctiontoS-PS.
Youcanlookatthefollowingdiagram.
2.Asimplesymbol
”~=”meansunequal.
3.Switchblock(signalrouting)
Theswitchblockpassesthroughthefirstinputorthethirdinputbasedonthevalueofthesecondinput.Thefirstandthirdinputsarecalleddatainputs.Thesecondinputiscalledcontrolinput.Specifytheconditionunderwhichtheblockpassedthefirstinputbyusingthecriteriaforpassingfirstinputandthresholdparameters.
Selecttheconditionunderwhichtheblockpassesthefirstinput.Ifthecontrolinputmeetstheconditionsetinthecriteriaforpassingfirstinputparameter,theblockpassesthefirstinput.Otherwise,theblockpassesthethirdinput.
☺自己的对switch模块的理解:
(1)中间端口(port2)是判定,另外两个端口(port1andport3)是输入。
(2)在模块设置中选择判定条件(数据输入):
默认选择是u>=threshold,可以设定门限值。
如果设定门限值为0,然后判断port2的输入与0的大小关系,若port2>=0,则输出port1的输入;若port2<0,则输出port3的输入。
如果选择判断条件为u>threshold,结果类似。
如果选择判断条件为u~=0(意思是非零),若port2非零,则输出port1的输入;若port2为零,则输出port3的输出。
(3)若port2输入是布尔运算输入(Booleancontrolinput):
若port2的布尔运算结果为1,则输出port1的输入;
若port2的布尔运算结果为0,则输出port3的输入。
(4)Example
下面举个例子,将一个简单的判断语句用switch模块来表示。
Ifa>1
b=3;
else
b=5;
end
4.ConnectionofSimulinkandMatlab
(1)由Matlab工作空间变量设置Simulimk模块参数:
一般情况下可以通过打开模块参数设置对话框来设置参数,但是当参数比较多时,就比较麻烦了。
如果各个参数有一定的函数关系,那么就更适合这种方法了。
具体过程如下:
A.将模块中的参数用字母表示,比如k,然后其他的参数写成关于k的函数;
B.在工作空间中给定k一个值,那么模块就会自动从工作空间中读取参数的值。
Example:
(2)将信号输出到Matlab工作空间中:
一般是使用scope示波器显示输出结果,但这只能定性的分析输出结果,要想定量的分析且希望把几组结果画在同一张图中进行比较,就需要(三种方法:
a.使用ToWorkspace模块;b.在示波器模块设置中将数据输出到工作空间;c.使用SimulinkConfigurationParameter对话框中的Dataimportandexport)先将数据输出到工作空间中,然后再进行数据处理(我习惯于用Origin进行数据分析和画图)。
Example:
(3)使用Matlab工作空间变量作为系统的输入信号:
使用FromWorkspace模块可以将Matlab工作空间中的变量作为Simulink系统仿真模块的输入信号。
Example:
t=[036910];
x=[-11-111/3];
input=[t’,x’];
系统输入是一个三角波,从结果可以看出Simulink对Matlab工作空间中的input进行了线性插值。
(4)调用M文件中定义的参数(自己摸索出来的):
在一个M文件中罗列定义出simulink模型中所要用到的参数,然后在运行simulink模块之前,先运行M文件,这样参数就写入matlab工作空间中,然后再运行simulink系统仿真。
Example:
点击
运行M文件;
然后运行simulink系统仿真
Warning:
根据个人试验,M文件和simulink模型不能取相同的名字,原因可能是simulink运行时会自动产生一个同名文件,如果M文件取相同的名字,则可能会引起冲突。
(Iamnotsure.Ijusttakesometentativetest.)。
并且M文件命名时,名字里面不可以有“空格键”,要不然M文件没法运行(可能这只是一个很小的知识点,但是花了我好长时间才摸索出来)。
5.HydraulicCircuitwithLoad-SensingVelocityControl
Thecircuitisequippedwiththeload-sensingvelocityregulatorinstalledbetweenthepumpanddirectionalvalve.Unlikeaconventionalmeter-invelocitycontrol,theload-sensingdeviceautomaticallyadjustsoutputpressureofthepumpinsuchawaythatitequalsthesumofthepresetpressuredropacrossthepressure-compensatedflowcontrolvalveandthepressureinducedbyload.Thepilot-operatedpressure-reliefvalveintheload-sensingblockisbuiltofthePoppetValveandtheHydraulicDouble-ActingValveActuatorblocks.
6.CreatingaSimpleModel
BuildingaSimHydraulicsDiagram
ModifyingInitialSettings
RunningtheSimulation
AdjustingtheParameters
BuildingaSimHydraulicsDiagram
Inthisexample,youaregoingtomodelasimplehydraulicsystemandobserveitsbehaviorundervariousconditions.Thistutorialillustratestheessentialstepstobuildingahydraulicmodel,describedintheprevioussection,andmakesyoufamiliarwithusingthebasicSimHydraulicsblocks.
Thefollowingschematicrepresentsthemodelyouareabouttobuild.Itcontainsasingle-actinghydrauliccylinder,whichiscontrolledbyanelectricallyoperated3-waydirectionalvalve.Thecylinderdrivesaloadconsistingofamass,viscousfriction,andpreloadedspring.
Thepowerunitconsistsofamotor,apositive-displacementpump,andapressurereliefvalve.Dependingonitscharacteristics,suchapowerunitcanbemodeledinavarietyofways,asdescribedinModelingPowerUnits.Inthisexample,thepumpunitisassumedtobepowerfulenoughtomaintainconstantpressureatthevalveinlet.Therefore,wearegoingtorepresentitinthediagrambyaHydraulicPressureSourceblock.
TocreateanequivalentSimHydraulicsdiagram,followthesesteps:
1.OpentheSimscapeandSimulinkblocklibraries,asdescribedinIntroducingtheSimHydraulicsBlockLibraries.
2.Createanewmodel.Todothis,clicktheNewbuttonontheLibraryBrowser'stoolbarorchooseNewfromthelibrarywindow'sFilemenuandselectModel.Thesoftwarecreatesanemptymodelinmemoryanddisplaysitinanewmodeleditorwindow.
Note Alternately,youcantypessc_newattheMATLABCommandprompt,tocreateanewmodelprepopulatedwithcertainrequiredandcommonly-usedblocks.Formoreinformation,seeCreatingaNewSimscapeModel.
3.OpentheSimscape>FoundationLibrary>Hydraulic>HydraulicSourceslibraryanddragtheHydraulicPressureSourceblockintothemodelwindow.
4.OpentheSimscape>SimHydraulics>HydraulicCylinderslibraryandplacetheSingle-ActingHydraulicCylinderblockintothemodelwindow.
5.Tomodelthevalve,opentheSimscape>SimHydraulics>Valveslibrary.Placethe3-WayDirectionalValveblock,foundintheDirectionalValvessublibrary,andthe2-PositionValveActuatorblock,foundintheValveActuatorssublibrary,intothemodelwindow.
6.Connecttheblocksasshowninthefollowingillustration.
7.PortsToftheHydraulicPressureSourceand3-WayDirectionalValveblockshavetobeconnectedtothetank,atatmosphericpressure.Tomodelthisconnection,opentheSimscape>FoundationLibrary>Hydraulic>HydraulicElementslibraryandaddtheHydraulicReferenceblocktoyourdiagram,asshownbelow.Todothis,connecttheonlyportoftheHydraulicReferenceblocktoportToftheHydraulicPressureSourceblock,thenright-clickthisconnectionlinetocreateabranchingpoint,andconnectthispointtoportTofthe3-WayDirectionalValveblock.
8.Modelthemechanicalloadforthecylinder.OpentheSimscape>FoundationLibrary>Mechanical>TranslationalElementslibraryandaddtheMass,TranslationalSpring,TranslationalDamper,andthreeMechanicalTranslationalReferenceblockstoyourdiagram.
Toindicatethatthecylindercaseisfixed,connectportCoftheSingle-ActingHydraulicCylinderblocktooneoftheMechanicalTranslationalReferenceblocks.TorotatetheMechanicalTranslationalReferenceblock,selectitandpressCtrl+R.YoucanalsoshortentheblocknametoMTRtomakethediagrameasiertoread.
ConnecttheotherblockstoportRoftheSingle-ActingHydraulicCylinderblock,asshownbelow.
9.Nowyouneedtoaddthesourcesandscopes.TheyarefoundintheregularSimulinklibraries.OpentheSimulink>SourceslibraryandcopytheConstantblockandtheSineWaveblockintothemodel.ThenopentheSimulink>SinkslibraryandcopytwoScopeblocks.RenameoneoftheScopeblockstoValve.Itwillmonitorthevalveopeningbasedontheinputsignalvariation.TheotherScopeblockwillmonitorthepositionofthecylinderrod;renameittoPosition.
10.Double-clicktheValvescopetoopenit.Inthescopewindow,clicktoaccessthescopeparameters,changeNumberofaxesto2,andclickOK.Thescopewindownowdisplaystwosetsofaxes,andtheValvescopeinthediagramhastwoinputports.
11.EverytimeyouconnectaSimulinksourceorscopetoaSimHydraulicsdiagram,youhavetouseanappropriateconverterblock,toconvertSimulinksignalsintophysicalsignalsandviceversa.OpentheSimscape>UtilitieslibraryandcopytwoSimulink-PSConverterblocksandtwoPS-SimulinkConverterblocksintothemodel.Connecttheblocksasshownbelow.
12.Tospecifythefluidproperties,addtheHydraulicFluidblock,foundintheSimscape>SimHydraulics>HydraulicUtilitieslibrary,toyourdiagram.YoucanaddthisblockanywhereonthehydrauliccircuitbycreatingabranchingpointandconnectingittotheonlyportoftheHydraulicFluidblock.
13.EachtopologicallydistinctphysicalnetworkinadiagramrequiresexactlyoneSolverConfigurationblock,foundintheSimscape>Utilitieslibrary.Copythisblockintoyourmodelandconnectittothecircuit,similartotheHydraulicFluidblock.Yourdiagramnowshouldlooklikethis.
14.Yourblockdiagramisnowcomplete.Saveitassimple_hydro1.mdl.
BacktoTop
ModifyingInitialSettings
Afteryouhaveputtogetherablockdiagramofyourmodel,asdescribedintheprevioussection,youneedtoselectasolverandprovidethecorrectvaluesforblockparameters.Alltheblockshavedefaultparametervaluesthatallowthemtorun"outofthebox,"butyoumayneedtochangesomeofthemtosuityourparticularapplication.
Toprepareforsimulatingthemodel,followthesesteps:
1.SelectaSimulinksolver.Onthetopmenubarofthemodelwindow,selectSimulation>ConfigurationParameters.TheConfigurationParametersdialogboxopens,showingtheSolvernode.
UnderSolveroptions,setSolvertoode15s(Stiff/NDF)andMaxstepsizeto0.2.
AlsonotethatSimulationtimeisspecifiedtobebetween0and10seconds.Youcanadjustthissettinglater,ifneede
ClickOKtoclosetheConfigurationParametersdialogbox.
2.Selectafluid.Double-clicktheHydraulicFluidblock.IntheBlockParametersdialogbox,setHydraulicFluidtoSkydrol5andsettheotherblockparametersasshownbelow.
ClickOKtoclosetheBlockParametersdialogbox.
3.Specifytheunitsforthepressureinputsignal.Simulinksignalsareunitless.Whenyouconvertthemtophysicalsignals,youcansupplyunitsbyusingtheconverterblocks.Double-
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- My Note for MatlabSimulink