Main Content

Compile Source Code for Functional Mock-up Units

When you build a model that includes FMU blocks, you must compile the FMU source code by using the QNX® Neutrino® compiler qcc or q++. This compiler creates shared object SO files that you include in the FMU. This process makes sure that the FMU contains the code to run on a Simulink® Real-Time™ target computer. For more information, see Apply Functional Mock-up Units by Using Simulink Real-Time.

Implement the FMU Block in Model

To implement the vanDerPol block in the Simulink model by using the FMU, specify the FMU name for the block. Open the model slrt_ex_vanderpol, double-click the FMU block vanDerPol, and select the vanDerPol.fmu file for the FMU name block parameter.

Build the model, load the real-time application on the target computer, and run the real-time application.

Compile FMU File That Contains Source Code

The slrealtime.fmu.compileFMUSources function compiles an FMU file that contains source code. The process outputs an FMU file and Simulink Real-Time binary file in the same folder as the input FMU file and appends an _slrt suffix to the output file name. This example selects an FMU file to compile and overwrites previous compiler output.

% copy an example file to the current working folder
mkdir tempdir myFmuDir
cd tempdir
cd myFmuDir
copyfile(...
    fullfile(matlabroot,'toolbox','slrealtime',... 
    'examples','slrt_ex_fmu_work'))
% create variable to provide path and file name
my_file = ['vanDerPol_slrt.fmu']
% compile the FMU file and overwrite previous output
slrealtime.fmu.compileFMUSources(my_file,'overwriteBinary',true)

See Also

|

Related Topics

External Websites