Main Content

Parameter Tuning Interfaces

Some components require interface support for tunable parameters, which enable you to change the parameter value that is stored in memory during program execution. For example, you might use a tunable parameter to determine an optimal value by changing the value and monitoring the results or to adapt an algorithm to different execution conditions. An example of a block parameter value that you might want to be tunable is a the Gain parameter of the Gain block.

To represent a parameter in a component model and configure the parameter to be tunable in generated code:

  1. Set up the parameter data for the model. For example, you might define MATLAB® variables in the model or base workspace.

  2. In the Model Explorer, convert MATLAB variables that represent the parameters to Simulink.Parameter objects.

  3. In the Embedded Coder app, open the Code Mappings editor. In the C Code tab, select Code Interface > Default Code Mappings. The Code Mappings editor opens to the Data Defaults tab.

  4. Expand the Parameters category.

  5. Check the link text to the right of Model parameters . That link text informs you whether parameters are configured to be inlined or tunable. If the text is 'Auto' will be inlined, click it.

  6. In the Model Configuration Parameters dialog box, set parameter Default parameter behavior to Tunable. In the Code Mappings editor, the link text changes to 'Auto' will be tunable.

  7. In the Code Mappings editor or by using the code mappings programming interface, configure the code interface for the model parameters to be tuned. At a minimum, set these properties:

    • Storage Class, which controls the appearance and placement of the state or signal data in the generated code.

    • Identifier, which names the model element in the generated code.

    For a list of storage classes supported by Embedded Coder®, see Choose Storage Class for Controlling Data Representation in Generated Code.

Alternatively, you can use these programming interfaces to tune parameters without using external model:

  • C application programming interface (API)

  • Target Language Compiler programming interface

After you configure the parameter interface, you can:

  • Set up and run external mode simulations that use a communication channel between Simulink® on your development computer (host) and your generated program executable that runs on the target platform by using the Run on Custom Hardware app.

  • Generate and customize an ASAP2 file and a Calibration Data Format (CDF) file by using the Generate Calibration Files tool.

Related Topics