Real-Time Workshop® and Real-Time Workshop Embedded Coder® provide numerous configuration options for tailoring the generated code. Code generation options are accessed through the Simulink® Configuration Parameters, also referred to as the model's configuration set.
You will make configuration decisions and tradeoffs depending on how you use and interact with the generated code. In short, you will choose a configuration that best matches your needs for debugging, traceability, code efficiency, and safety precaution. Features, scripts, and documentation facilitate your creation of an ideal model configuration set for your application.
Although Real-Time Workshop provides a push-button facility to quickly configure and check a model for specified objectives, it is common to automate the model configuration procedure using a MATLAB script. The instructions in this demonstration illustrate:
With these basic skills you are well on your way to setting up an ideal automated configuration scheme for your project.
There are many workflows for Configuration Parameters that include persistence within a single model or persistence across multiple models. Depending on your needs, you may wish to work with configuration sets as copies or references. This example demonstrates the basic steps for working directly with the active configuration set of a model. For a comprehensive description of configuration set features and workflows, please see the Configuration Sets section of the Simulink documentation.
Configuration Wizard blocks automatically configure a model for code generation. Several goal-oriented configurations are available, and you can customize them to better suit your goals for the generated code. Automating the configuration of a model is very beneficial as it reduces manual steps and improves consistency between builds.
You can execute the following commands to open a model:
Next, you can execute the following command to obtain the model's active configuration set:
cs = getActiveConfigSet(model);
Real-Time Workshop exposes a subset of the code generation options. If you are using Real-Time Workshop, you can execute the following command to select the Generic Real-Time (GRT) target:
Real-Time Workshop Embedded Coder exposes the complete set of code generation options. If you are using Real-Time Workshop Embedded Coder, you can execute the following command to select the Embedded Real-Time (ERT) target:
To automate configuration of models that will be built for both GRT- and ERT-based targets, you will find the configuration set IsERTTarget attribute useful. You can execute the following command to determine if the model is configured for an ERT target:
isERT = strcmp(get_param(cs,'IsERTTarget'),'on');
You can interact with code generation options via the model or the configuration set. You can execute the following commands to get and set options indirectly via the model:
inlineParams = get_param(model,'InlineParams'); % Get InlineParams set_param(model,'InlineParams',inlineParams) % Set InlineParams
You can combine the above commands and execute the following to get and set options directly via the configuration set.
if isERT lifespan = get_param(cs,'LifeSpan'); % Get LifeSpan set_param(cs,'LifeSpan',lifespan) % Set LifeSpan end
You can find the full list of code generation options, including information on tradeoffs for debugging, traceability, code efficiency, and safety precaution, at the following links:
Real-Time Workshop provides an example configuration script that you can use as a starting point for your application. If you have the Real-Time Workshop or Real-Time Workshop Embedded Coder software, you can view the full list of relevant GRT and ERT code generation options in rtwconfiguremodel.m.
Real-Time Workshop Embedded Coder provides a set of Configuration Wizard blocks that automate configuration of a model for a specific goal. The predefined blocks provide configuration for:
Just drop the block into a model and double-click to configure the model. See Simulink model rtwdemo_configwizard for an interactive demonstration of these blocks.
Please see the Configuration Wizard section of the Real-Time Workshop Embedded Coder documentation for more information (login required).