PmpRunCodeGen

This section describes how to correctly choose the code generation arguments and generate a binary file that can be uploaded into PMP. Run your model configuration script prior to the code generation to ensure that the required PmpParameter, PmpSignal, PmpBus and PmpUpdatable definitions for your model are in the workspace.

The function PmpRunCodeGen() allows to set the configuration parameters and generate the code for PMP from an m-file or the command window. The possible syntaxes for this function are:

PmpRunCodeGen(modelname,targetplatform,solver)
PmpRunCodeGen(modelname,subsystemname,targetplatform,solver)
PmpRunCodeGen( ,outputdir,binfilename)

Depending whether optional arguments are specified, the full model is built or only a specific subsystem is built and the generated binary file can be renamed and moved to a user-defined output directory. The inputs are stated in PmpRunCodeGen inputs.

PmpRunCodeGen inputs

Input

Description

modelname

String containing the name of the Simulink model.

targetplatform

PmpTargetPlatform class object with possible enumerations:

  • bb_armv8a_64

  • bb_x86_64

  • lnx_x86_64

  • win_x86_32

  • win_x86_64

solver

PmpSolver class object with possible enumerations:

  • discrete

  • ode1

  • ode3

This setting overwrites the setting of the Simulink model.

sampleperiod

Numeric or string containing the sample period used to generate code of the model. If the model is sample time independent, the sampleperiod can be set to ‘auto’. This allows changing the sample period of the PMP parent component without re-exporting the model. Also see Sample period.

subsystemname

(Optional) string containing the name of the subsystem if it is unique or full (model) path in case is not unique.

outputdir

(Optional) string containing the user defined output directory for the binary file.

binfilename

(Optional) string containing the user defined name of the binary file.

The enumeration values of the class objects (PmpTargetPlatform and PmpSolver) can be obtained via the command:

enumeration('PmpTargetPlatform')
enumeration('PmpSolver')

Enumerations feature auto-completion. I.e. when typing PmpTargetPlatform. and pressing the TAB key all options are displayed.

Note

The binary name is equal to the subsystem name or model name. If the subsystem name contains spaces the binary file is renamed substituting spaces for underscores. This is done to ensure a unique name of the generated binary file.

The output of the building process is displayed in the Command Window. If no errors occurred the message ‘### Successful completion of build procedure for model: <model name>’ is displayed in the Command Window, followed by ‘Model version generated with code generation version ().’. The version is the Simulink model version, by default this is incremented every time the model is saved, see Versioning. For traceability the model version can be obtained via PMP after the binary files is uploaded to a PMP controller using the Updatable version.