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.
Below are the steps to set up the circuit for FMU Export in PSIM:
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.
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.
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:
Note: The background color of the FMU Import block is set to yellow for easier identification.
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.