Using MathWorks™ Simulink Coder® to Export a Simulink Model as an FMU
This section describes how to export a Simulink model as an FMU using MathWorks Simulink Coder. Simulink Coder generates the model-based C-code, and the necessary Makefile for Microsoft Visual C++. The generated code is compiled into a DLL supporting FMI 2.0 co-simulation interface (see the FMI Web site https://fmi-standard.org/ for detailed information). Along with the DLL and the model description provided as an XML file, an FMU file is created in the current Simulink working directory.
The generated FMU only supports the FMI 2.0 co-simulation interface. Even though the interface is type co-simulation, the model is self-consistent and does not have any interaction with MATLAB or Simulink during the simulation – it is very similar to Simulink Coder-generated Twin Builder C-Model, except for the interface.
The FMU export is provided through FMU Target by Ansys Twin Builder.
Features and Limitations
- Simulink solver type must be Fixed-step for the code generation.
- Target language must be C.
- All ports must be scalar of real type. Vector or complex ports are not supported.
- Data transfer to the FMU can only be performed through input and output interface ports. Variables defined in the original Simulink model will not appear as quantities on the generated model.
- Cannot support S-Function that call MATLAB such as Twin Builder's co-simulation S-Function block (AnsoftSFunction).
- The exported FMU does not need a Simulink license to run.
- Multiple instances of the FMU can be simulated in a single design.