Simulink code generation¶
PMP provides a MATLAB / Simulink toolbox that exports Simulink models to PMP motion controllers or PMP EtherCAT SubDevicess. This section describes the specifics about code generation for PMP from a Simulink model.
Workflow¶
Simulink code generation workflow gives an overview of the workflow of using a Simulink model in PMP. See Considerations for general considerations, prerequisites, limitations and naming conventions and restrictions.
Design Simulink model¶
A Simulink model can recursively consist of several subsystems, basic building blocks, and PMP specific blocks. In general, most functionality that is supported by Simulink Coder is also supported in PMP code generation. In Block compatibility an overview is given of standard Simulink library blocks for which compatibility is explicitly tested for every release. The code generation toolchain also contains a library with blocks that are specific for PMP integration. These are described in PMP Simulink library.
Generate code¶
Generating a binary for PMP is done either for the complete model or for a subsystem. See Simulink model configuration how the model should be configured for code generation and Mapping to PMP objects how Simulink concepts are mapped to PMP interfaces.
A PMP processing block binary file is generated via the PmpRunCodeGen.m function. This function and other relevant functions are explained in PMP functions. Simulink code generation for PMP should be executed via script. Code generation via the Simulink GUI is not advised nor documented, due to the large amount of required manual configurations.
Upload to PMP¶
The binary is uploaded to one or more motion platforms using the PMP Template mechanisms. Based on a single uploaded binary multiple template instantiations, i.e. Processing blocks, can be created. Using this mechanism allows for example to use the same processing block for multiple axes without having to upload the same binary multiple times.