Simulink model configuration¶
This section describes Simulink model configuration settings relevant for code generation for PMP.
Versioning¶
In order to track changes in the model with the corresponding binary in PMP, the Simulink model version is exported into the PMP binary. The model version can be set in the model properties which can be found in the File menu of Simulink. The default is to increment the version every time the model is saved, however this may be changed considering the following rule: The version must consist of at most four groups of integers and they must be separated by a dot. Example version numbers are 1.2; 9.8.7.6 and 533.24.9327.
For precompiled processing blocks provided in the PMP installer, the version corresponds with the major, minor, patch and build numbers in PMP, respectively. If less than four groups are used in Simulink, the major, minor and patch are used in this order, where the unused numbers are zero. For example, if the Simulink version is 1.2, this corresponds with a major of 1 and a minor of 2. The patch and build number are zero.
If the version number does not adhere to this format, the following error is shown during code generation: Version must be in the format a.b.c.d.
The model version will be stored in the Updatable to which the exported binary is uploaded. The version can be retrieved using the updatable version.
Note that no binaries of older versions are preserved by PMP and that binaries are lost after a reboot of the system. PMP only lists the version number and is not a version control system.
Solvers¶
The following solvers are supported by Simulink models exported to PMP:
Fixed-step discrete
Fixed-step continuous - ode1
Fixed-step continuous - ode3
Variable-step solvers are incompatible with code generation for PMP. The following error message is given when selecting a variable-step solver: ‘Only fixed-step solvers are supported for this target.’
The solver is overridden when running PmpRunCodeGen.m.
Sample period¶
An exported model can be executed synchronously in PMP or asynchronously, see Execution type. In the case of synchronous execution, the sample period of the Simulink model must match the sample period of the PMP parent component, e.g. AxisControl or Controller.
The sampleperiod argument overrides the default step size of the simulation. When loading the exported model, the sample period of the model is verified with the sample period of PMP component. If the model is sample time independent, this check can be disabled by setting the sampleperiod argument to ‘auto’. This allows changing the sample period of the PMP parent component without re-exporting the model. Note that models with continuous-time blocks or source blocks are always sample period-dependent. Also hard-coded parameters may cause a sample time dependency. Only use ‘auto’ when you are sure that there is no sample period dependency in your model, otherwise the generated code may not behave as expected. Note that PMP Filters are not sample time dependent, since they inherit their sample time from the PMP component.
The sample period is overridden when running PmpRunCodeGen.m.