Frequently Asked Question

How to export FMU file from Simulink model and import it in Typhoon HIL toolchain (for MATLAB release 2021a)?
Last Updated 2 years ago

From the 2021a version, Matlab enables its users to export a Simulink model to FMU along with C source code. Although FMU could be exported in previous versions as well, those versions didn't support exporting C source code along with FMU. 

Having C source code included in FMU is crucial for running real-time simulations in the Typhoon HIL toolchain. 

Exporting FMU from Simulink

1. Open your model in Simulink. It is recommended that the path to your model does not contain empty spaces, so we recommend that you place _ instead of empty space.

2. Comment out parts of the model you don't want to export. Place Inport components to the places inputs to the system and Outport components to the places where are outputs of the system.

3. There are two parameters that should be set in Model settings (Modeling tab)

  • Type of Solver (Model Settings->Solver->Solver Selection->Type), should be set to Fixed-step
    • Fixed step size (Model Settings->Solver->Solver details->Fixed step size), should be defined. (This value is important for parametrization of the FMU unit when it is imported in Typhoon HIL tool-chain)

    4. Next step is to export FMU. This can be done in Save drop-down menu in the section Export Model To. Pressing Standalone FMU... will open FMU Export window.

    5. In the FMU export model you have to select Save source code to FMU, while other parameters can be selected as you want. When everything is selected, press Create and FMU will be generated in the folder you set.

    Import FMU in Typhoon HIL tool-chain

    Before you can import created FMU file, a small adjustment to the FMU file must be done.

    1. Open FMU file as archive

    2. Edit "modelDescription.xml" file

    3. Remove line: with "File name="lccstub.c" (This library is not supported by the HIL device, so without removing it, the model will not be able to compile successfully.)

    4. Save "modelDescription.xml"

    5. Import it in Typhoon HIL by dragging FMU import from the core library (core/Signal Processing/Extras/FMU Import)

    6. In the properties of FMU Import, choose the FMU file you exported and modified.

    7. You should choose the Execution rate to be the same or larger than the one you selected the value of Fixed step size in Simulink. If the execution rate is smaller than the one you set in Simulink, FMU behavior will not be correct.

    This concludes the steps needed for the proper setup of the Functional Mock-up Unit. You can now start the simulation.

      Please Wait!

      Please wait... it will take a second!