View this page as PDF
The FMI (Functional Mock-up Interface) Module in PSIM provides the capability to generate an FMU (Functional Mock-up Unit), a file that contains the model that meets the FMI standard. There are two types of FMU: Model exchange FMU and Co-simulation FMU.
At the moment, PSIM’s FMI Module supports the co-simulation FMU in the slave mode. That means, PSIM will export the FMU model, and the other software will import the FMU model. The other software will initiate and run the simulation in the master mode, and PSIM will run in the slave mode.
The objective of this tutorial is to show how to set up and export an FMU in PSIM and run the co-simulation.
A simple buck converter with current feedback control (file “buck_ifb.psimsch”), as shown below in PSIM, will be used as an 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 power circuit.
As an illustration, we will use Matlab/Simulink as the other software to load the FMU model and run the simulation.
This tutorial illustrates how to split the circuit so that part of a control circuit (as shown below inside the dotted box) is implemented in Simulink, and the rest of the circuit stays in PSIM.
Setting up for FMU Export
Below are the steps to set up the circuit for FMU Export in PSIM:
- Launch PSIM, and open the file “buck_ifb.psimsch”. The file can be found in the sub‐folder “examples\FMI” in the PSIM directory.
- Save the file to a different name, “buck_ifb_psim.psimsch”, in the directory “c:\test”.
- Modify the circuit by deleting the reference, the summer, and the PI controller. After the modification, the circuit looks as follows:
- Go to Elements >> Control >> SimCoupler / FMI Module as shown below:
Select the Out Link Node option, connect it to the current sensor output, and rename it “iL”. Similarly, select the In Link Node, connect it to the comparator input, and rename it “Vm”.
The FMI Module uses the SLink nodes to establish an interface between PSIM and the other software. In Link Nodes receive values from the other software and Out Link Nodes send values to the other software.
Multiple In/Out Link Nodes can be used in a circuit to exchange values between PSIM and the other software. In this case, for example, we are going to measure and send the load voltage to the other software 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.
- If there is more than one In Link Node or Out Link Node (such as in this case), you can arrange the order of the link nodes. Go to Simulate >> Arrange SLINK Nodes and a 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 other software. 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 output port corresponding to “Vo” will be on the bottom.
To re‐arrange the node sequence, highlight the name of the node, and click on the up or down arrow.
- Save the schematic file. In this example, the file will be saved to “c:\test\buck_ifb_psim.psimsch”.At this point, the setup in PSIM for FMU export is completed, and we can export the FMU model.
Exporting the FMU Model
To export the FMU model, select Utilities >> Export FMU. If the schematic file is already loaded in PSIM, such as in this example, a dialog will appear with the schematic file already loaded, as shown below.
The dialog window has 3 main sections: Inputs, Outputs, and Parameters.
The Inputs section shows the In Links nodes for the signals that PSIM receives from the other software. In this example, it is the modulation signal Vm. A description can be added to the link nodes. By default, the description is the same as the node name.
The Outputs section shows the Out Links nodes for the signals that PSIM sends to the other software. In this example, they are the inductor current iL and the output voltage Vo.
The Parameters section defines parameters that can be passed from the other software to PSIM. For example, the buck converter input voltage can be defined as Vin. The variable Vin can then be defined in the other software and passed to PSIM. This example does not have any parameters.
To generate the FMU model, click on the button Generate FMU. The FMU model file “buck_ifb_psim.fmu” will be created in the same folder as the schematic. This file is ready to be used by the other software for co-simulation.
Simulating the FMU Model
As a demonstration, we will use Matlab/Simulink as the other software to load the FMU model generated by PSIM and perform co-simulation.
Below are the steps to set up in Simulink:
- In Simulink, create a new file corresponding to the control circuit in the dotted box in Section 1, as shown below.
- Save the file to “c:\test\buck_ifb_simulink_FMU.slx”.
- In the Simulink library browser, go to Simulink Extras >> FMU Import, and place the FMU Import block in the schematic. Double click on the block, browse and select the file “buck_ifb_psim.fmu” from the “c:\test” folder.
Connect the FMU Import block to the rest of the schematic. The schematic will show as below:
Note: The background color of the FMU Import block is set to yellow for easier identification.
- This completes the setup in Simulink, and the circuit is ready for simulation.
The FMI Module in PSIM provides the capability to export FMU models from PSIM and perform co-simulation with any software that supports the FMI standard. It provides the flexibility for users to use PSIM and other software in a complementary way.