Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop Embedded Coder   

Standard Methods to Prepare a Model for Code Generation

Configuring Signals

  1. Create a model in Simulink. See Creating a Model in the Simulink documentation.

  2. Right-click a signal line. Select Signal Properties. A Signal Properties dialog box opens. See Signal Properties Dialog Box for more information.

  3. Specify a signal name.

  4. On the same Signal Properties dialog box, select the Real-Time Workshop tab and specify a storage class for the signals. (Examples use models with signals that are Exported Global).

Configuring Input and Output Ports

  1. In your model,

    Double-click an Inport or Outport block. A block parameters dialog box opens.

  2. Select the Signal Attributes tab.

  3. Specify the Port dimensions and Data type.

Initializing States

  1. Double-click a block.

  2. In the block parameters dialog box, select the Main tab.

  3. Specify the Initial conditions and Sample time. See Working with Sample Times.

  4. Select the State Attributes pane. Specify the state name. See Block State Storage and Interfacing Considerations

  5. You can also use the Data Object Wizard for creating data objects. A part of this process initializes states. See Creating Simulink Data Objects with Data Object Wizard.

Setting Up Configuration Parameters for Code Generation

  1. Open the Configuration Parameter dialog box by selecting Simulation > Configuration parameters. You can also use the keyboard shortcut Ctrl + E.

  2. Open the Solver pane and select

    • Solver type: Fixed-Step

    • Solver: Discrete (no continuous states)

  3. Open the Optimization pane, and select the Inline parameters parameter.

  4. Open the Real-Time Workshop pane, and specify ert.tlc as the System Target File.

  5. Clear Generate makefile.

  6. Select Generate code only.

  7. Enable the HTML report generation by opening the Real-Time Workshop > Report pane and selecting Generate HTML Report, Launch report automatically, and Code-to-block highlighting. Enabling the HTML report generation is optional.

  8. Click Apply and then OK to exit.

Configuring Stateflow Charts

If you have a Stateflow chart in your model, initialize the inputs, outputs, local variables, and parameters of the Stateflow chart for code generation.

  1. In your model, double-click a Stateflow. If you are not familiar with Stateflow, see the Stateflow Getting Started Guide.

  2. Select Tools > Explore or Ctrl+R to launch the Chart Explorer.

  3. On the Chart Explorer, select Add > Data or enter Ctrl+D. From the drop-down list, select an input, output, local variable, parameter, or function call. You see a Data dialog box.

  4. In the Data dialog box, enter the Name of the data.

  5. Specify the Scope.

  6. Specify the Type. Choose a built-in data type or inherit the data type.

  7. Click Apply and close the dialog box.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS