Anda di halaman 1dari 10

TUTORIAL

SimCouplerModule
October2016

1
SimCouplerModule

TheSimCouplerModuleprovidesthelinkbetweenPSIMandMatlab/Simulink*forcosimulation.
TheobjectiveofthistutorialistoshowhowtousetheSimcouplerModuleandsetitupinPSIM
andSimulink.

Asimplebuckconverterwithcurrentfeedbackcontrol(filechop1q_ifb.sch),asshownbelowin
the PSIM environment, will be used as the example. In this circuit, the inductor current is
measured and compared with a reference. The error signal is sent to a PI controller, and the PI
output is compared with a carrier waveform to generate the gating signal for the switch in the
powercircuit.

Inthistutorial,wewillillustratehowtosplitthecircuitsothatpartofthecontrolcircuit(asshown
inside the dotted rectangle) is implemented in the Simulink environment, and the rest of the
circuitstaysinPSIM.

Note that this tutorial is for PSIM Version 9.0 and above, and that this circuit can be simulated
withthePSIMdemoversion.


The circuit inside the rectangle
will be implemented in Simulink.

*:MatlabandSimulinkareregisteredtrademarksofMathWorks,Inc

2
SimCouplerModule

1.SettingupforCoSimulation
BelowarethestepstosetupthecosimulationinPSIM:

- IfmultiplecopiesofPSIMareinstalledonthecomputer,inordertoassociatethePSIM
copythatyoucurrentlyusetoMatlab/Simulinkforcosimulation,fromthespecificPSIM
copy,gotothemenuUtilities>>SimCouplerSetup.Notethatthisneedstobedoneonly
onceuntilnexttimeyouwishtoassociateanothercopyofPSIMwithMatlab/Simulink.

- LaunchPSIM,andopenthefilechop1q_ifb.sch.Thefilecanbefoundinthesubfolder
examples\SimCouplerinthePSIMdirectory.

- Savethefiletoadifferentname,chop1q_ifb_psim.sch,inthedirectoryc:\test.

- Modifythecircuitbydeletingthereferencesource,thesummer,andthePIcontroller.
Afterthemodification,thecircuitlooksasfollows:


- GotoElements>>Control>>SimCouplerModuleasshownbelow:

3
SimCouplerModule

Select the Out Link Node. Connect it to the current sensor output, and rename it to iL.
Similarly, select the In Link Node. Connect it to the comparator input, and rename it to
Vm.

The SimCoupler Module uses the SLink nodes to establish the interface between PSIM and
Simulink. In Link Nodes receive values from Simulink, and Out Link Nodes send values to
Simulink.

Multiple In/Out Link Nodes can be used in a circuit to exchange values between PSIM and
Simulink. In this case, for example, we are going to measure and send the load voltage to
Simulink by connecting a voltage sensor across the load resistor and placing an Out Link
Node at the voltage sensor output. The Out Link Node will be renamed as Vo. After this,
the circuit will look as below.

4
SimCouplerModule

Please note that the PSIM demo version only allows one In Link Node and one Out Link
Node. If you are using the demo version, do not add this extra link node for the output
voltage.

- IftherearemorethanoneInLinkNodeorOutLinkNode(suchasinthiscase),youmay
wishtoarrangetheorderofthelinknodes.GotoSimulate>>ArrangeSLINKNodes,anda
dialog window will appear, as shown below. Arrange the order of the In nodes and Out
nodes to be the same as how the input/output ports would appear in the SimCoupler
model block in the Simulink environment. The order of the ports is from the top to the
bottom. In this case, the output port corresponding to iL will be on the top, and the
outputportcorrespondingtoVowillbeonthebottom.

Torearrangethenodesequence,highlightthenameofthenode,andclickontheupor
downarrow.

- Savetheschematicfile.Inthisexample,thefilewillbesavedto
c:\test\chop1q_ifb_psim.sch.

Atthispoint,thesetupinPSIMiscomplete,andwewillstartthesetupinSimulink.

- StartMatlab.

- LaunchSimulink,andcreateanewfilecorrespondingtothecontrolcircuitthatwas
deletedfromthePSIMcircuitinStep4,asshownbelow.

5
SimCouplerModule

- Savethefiletoc:\test\chop1q_ifb_simulink.mdl.

- InSimulink,gotothelibrarybrowser,andyouwillseetheSimCouplerblockunderthe
menuSfunctionSimCoupler,asshownbelow:


- HighlighttheSimCouplerblock,anddragitintotheschematicofthefile
chop1q_ifb_simulink.mdl.DoubleclickontheSimCouplerblock,andthefollowingdialog
windowwillappear:

6
SimCouplerModule

ClickontheBrowsebuttontofindandselectthefilec:\test\chop1q_ifb_simulink.mdl.
ClickontheShowSchematicbuttonwilllaunchPSIManddisplaytheschematicfile
c:\test\chop1q_ifb_psim.sch.ClickonApplytoacceptthefile,andthenOKtoclosethis
window.

TheimageoftheSimCouplerblockwillchangetomatchthenumberofinput/outputports
tothenumberofIN/OUTLinkNodesasdefinedinthePSIMschematic.Inthiscase,there
areoneinputport(correspondingtotheInlinknodeVm)andtwooutputports
(correspondingtotheOutlinknodesiLandVo)(exceptifyouhavethedemoversionand
youdidnotaddtheOutlinknodeVo).Thelinknodenameswillappearnexttothe
input/outputports.

InordertodifferentiatetheSimCouplerblockfromtherestoftheSimulinkelements,the
blockbackgroundcolorischangedtoyellow.


IfthenumberoflinknodesinthePSIMschematicischangedlater,inSimulink,gotoEdit
>>UpdateDiagramtoupdatetheblockports.

- Complete the connection in Simulink, then go to Simulation >> Simulation Parameters.


UndertheSolverOptions,theTypecanbesettoeitherFixedsteporVariablestep.Ifthe
fixedsteptypeischosen,thefixedstepsizeshouldbethesameasorclosetoPSIMstime
step(inthisexample,thePSIMstimestepis2us).TheSimulinkcircuitwilllookasfollows.

7
SimCouplerModule

Alternatively, we can use the variablestep solver option. However, in this case, a zero
orderholdmustbeinsertedtoeachinputportoftheSimCouplermodelblock,asshown
below,andthesamplingtimeofthezeroorderholdmustbeequalorclosetoPSIMstime
step(2usinthiscase).Pleaseseeadditionalremarksattheendofthisdocumentregarding
theselectionofthesolvertype.

- ThesetupinSimulinkisnowcompleteforthecosimulation.InSimulink,gotoSimulation
>>Start,andstartthesimulation.

8
SimCouplerModule

2.HowtoPassParametersfromSimulinktoPSIM
TosetsomeparametervaluesinSimulinkandpassthemtoPSIM,inthePSIMschematicfile,
changethedesiredvaluetoavariablename.Forexample,tosettheinductanceoftheinductorL1
inSimulink,changeittovarL1.
InSimulink,doubleclickontheSimCouplerblocktoopenthepropertydialog,andclickonAdd
Variable.Clickonthenewlyaddedrowinthelistandtypethevariablenameandvalue,asshown
below.



Examplefileschop1q_ifb_simulink_r13_param.mdlandchop1q_ifb_psim_param.psimschin
theexamples\SimCouplerfolderdemonstratethisfeature.
ItisalsopossibletosetthevariablevaluesinaMatlabMFileasdemonstratedinsamplefiles
chop1q_ifb_param.mandchop1q_ifb_param2.m,asshownbelow.

9
SimCouplerModule

3.AdditionalRemarks
Each time that you use the SimCoupler Module from a different PSIM folder, or if the
Matlabfolderhaschanged,youneedtorunthemenucommand Utilities>>SimCoupler
SetupfromPSIM.

Forexample,ifyouhaveboththePSIM9.1demoversionandPSIM9.1Professionalversion
on the same computer, to use the SimCoupler Module in the demo version, run the
command SimCoupler Setup from the PSIM demo version. Alternatively, if you wish to
usetheSimCouplerModuleintheprofessionalversion,runSimCouplerSetupfromthe
PSIMProfessionalversion.

Similarly,ifSimCouplerwassettoworkwithyourexistingMatlab7.13(R2011b),andyou
justinstalledMatlab7.14(R2012a)onthecomputer,TohavetheSimCouplerModulework
withthenewversion,runSimCouplerSetup,andchooseMatlab7.14.

CircuitsthatarecreatedbyPSIMVersion6.1orearlierwillnotworkinPSIMVersion9.0.
Users need to replace the old SimCoupler block with the new block from the Simulink
librarybrowser,anddefinethePSIMschematicfilefortheblock.

When the SimCoupler model block is used in a feedback system in Simulink, the
SimCoupler model block may be part of an algebraic loop. Some versions of
Matlab/Simulinkcannotsolvethesystemcontainingalgebraicloops,whileotherscansolve
thesystembutwithdegradedperformance.Tobreakan algebraicloop,placea memory
blockateachoutputoftheSimCouplermodelblock.Thememoryblockwillintroduceone
timestepdelay.

Certain restriction is imposed on the selection of the solver type and the time step in
SimulinkwhenperformingthePSIMMatlab/Simulinkcosimulation.Simulinkcanbesetup
tohavetheSolverTypeaseitherFixedsteporVariablestep.WhentheSolveTypeisfixed
step,thetimestepmustbethesameorclosetothePSIMtimestep.IftheSolverTypeis
variablestep,azeroorderholdmustbeusedateachinputoftheSimCouplermodelblock
withthesamplingtimetobethesameasorclosetoPSIMstimestep.

Because Simulink and PSIM can have different time steps, it is not recommended to
exchangelogicsignals(0and1)betweenthetwoprograms.

10

Anda mungkin juga menyukai