Quickstart

If you already have the generated model code, skip to step 2. If you get the joy of generating the model source, well start from the top.

Step 1: Generate the Model’s Code.

This is likely the hardest part of the whole process. But we’ve tried to make it simple for you. You just need to check a few settings and build the model. If you’re feeling bold, you can copy-paste a script to do it for you!

Here’s said script:

model = 'MyAwesomeModel';        % <-- The name of your model...change this!
configs = getActiveConfigSet(model);
mustProp=false;
if isa(configs, 'Simulink.ConfigSetRef')
    configs = eval(configs.SourceName);
    mustProp=true;
end

set_param(configs, 'ConcurrentTasks', 'off');
set_param(configs, 'EnableMultiTasking', 'off');
set_param(configs, 'SystemTargetFile', 'grt.tlc');
set_param(configs, 'GenerateMakefile', 'off');
set_param(configs, 'GenCodeOnly', 'on');
set_param(configs, 'PackageGeneratedCodeAndArtifacts', 'on');
set_param(configs, 'RTWCAPIParams', 'on');
set_param(configs, 'RTWCAPISignals', 'on');
set_param(configs, 'RTWCAPIRootIO', 'on');
set_param(configs, 'RTWCAPIStates', 'on');
set_param(configs, 'GRTInterface', 'off');
set_param(configs, 'CombineOutputUpdateFcns', 'on');

if mustProp
    Simulink.BlockDiagram.propagateConfigSet(model);
end
slbuild(model);

What’s going on here?

It’s just changing a few settings in your model’s config. These are the minimum settings required for PySimlink, and should not affect your model’s ability to build (knock on wood)…

Want to do this manually? Check out the How-To guide for details.