Main Content

Configure and Simulate AUTOSAR Classic Models with Simulink Real-Time

By using Simulink® Real-Time™ and Speedgoat I/O Blockset, you can simulate and fine-tune your AUTOSAR Classic component models using rapid control prototyping and hardware-in-the-loop testing.

This workflow requires a Simulink Test™ license to create a test harness.

To learn more about system requirements for deploying a Simulink Real-Time model onto a Speedgoat® target computer, see Product Requirements & Platform Availability for Simulink Real-Time.

Generate Simulink Real-Time Test Harness and Model from AUTOSAR Component Models for Rapid-Prototyping and Simulation

This example shows how to open, convert, and update an AUTOSAR model using the Simulink Real-Time environment.

  1. Open the example model autosar_swc_expfcns.

    openExample("autosar_swc_expfcns");

  2. Validate and simulate the model.

  3. Open the AUTOSAR Component Designer app. On the AUTOSAR tab click Share and then select Generate Simulink Real-Time Model and Test Harness.

    AUTOSAR tab with the Share menu open. The option Generate Simulink Real-Time Model and Test Harness highlighted.

  4. In the Export AUTOSAR Model for Simulink Real-Time Testing dialog box, in the Simulink Real-Time model folder box, specify the full file path of an output folder to store the Simulink Real-Time generated files and test harness model. This output folder must be empty before generating Simulink Real-Time files.

    Simulink closes all open models and creates a Simulink Real-Time model autosar_swc_expfcns_slrt, and a test harness autosar_swc_expfcns_harness, which references autosar_swc_expfcns_slrt.

    Test harness for AUTOSAR compliant Simulink Real-Time model.

Set Up Speedgoat Target Computer and Configure Simulink Real-Time

This example shows how to connect to a target computer using Simulink Real-Time Explorer (Simulink Real-Time).

  1. In the Simulink Editor, open the Simulink Real-Time Explorer. In the Real-Time tab, from the targets list, click SLRT Explorer.

  2. From the Target Computers list, select the target computer node.

    • To add a node representing another target computer, in the Targets pane, click Add target.

    • To remove a node representing a target computer, select the node and click Remove target.

  3. If the target computer has not been previously configured, select the Target Configuration tab and set the target computer IP address for the target computer definition by clicking Change IP Address button. Enter the IP address of the target computer. For example, Speedgoat target machines are preconfigured to address 192.168.7.5.

    Note

    The target network setting values are for demonstration purposes only. Consult your network administrator for actual values. For more information about network configuration, see Target Computer Settings (Simulink Real-Time).

  4. Start the target computer and wait until the target computer boots the real-time operating system (RTOS).

  5. Update the target computer by clicking Update Software in the Target Configuration tab.

  6. To connect Simulink Real-Time to the target computer, in the toolstrip, click the Disconnected button to toggle it to Connected.

Log Signals and Tune Parameters

This example shows how to create a Simulink Real-Time test harness and model for the example model autosar_swc_counter, and then tune parameters while seeing real-time updates by using Simulink Real-Time Explorer (Simulink Real-Time) and the Simulation Data Inspector (Simulink Real-Time).

  1. Connect to your Speedgoat target computer by following the steps in the previous section.

    Open the autosar_swc_counter model.

    model = "autosar_swc_counter";
    openExample(model);
  2. To tune parameters in referenced models Simulink Real-Time you can configure parameters as model arguments. For more information, see Configure Referenced Model to Use Model Arguments.

    To parameterize autosar_swc_counter on the Modeling tab, click Model Data Editor.

  3. In the Model Data Editor, select the Parameters tab.

  4. In the Value column next to INC, click the action button and select Create.

  5. In the Create New dialog box, set Value to Simulink.Parameter and Location to Model Workspace. Click Create.

  6. In the Simulink parameter INC property dialog box, select Argument.

    Simulink.Parameter INC dialog box is open and Argument is selected.

  7. Click Apply and then click OK.

  8. Repeat steps 4 through 8 for constants LIMIT and RESET.

  9. In the model, select the sum_out signal. Log the signal by pausing over the action bar that appears and selecting Log Selected Signal.

  10. Open the Configuration Parameters dialog box and navigate to Code Generation > Optimization. Set Default parameter behavior as Tunable and clock OK and save the model.

  11. Prepare the model for Simulink Real-Time by using the autosar.slrealtime.migrateModel function, where outputFolder is an empty folder on the MATLAB path. If the folder does not exist then, Simulink creates it.

    autosar.slrealtime.migrateModel(model,"outputFolder", ...
        HarnessModelName="myAUTOSAR_SLRT_harness", ...
        OpenFlag = true)

    Once the migration completes, myAUTOSAR_SLRT_harness opens.

  12. Check that the System target file is speedgoat.tlc. If System target file is slrealtime.tlc, install Speedgoat I/O Blockset and change System target file to speedgoat.tlc.

  13. On the Real-Time tab, select your target computer from the menu in the Connect to Target Computer section.

  14. To open the Target Platform Selector, in the Prepare section of the toolstrip, click Target Platform.

    Target Platform Selector user interface.

  15. In the Target Platform Selector, select your target computer from the drop-down list and then select the appropriate configuration. This example uses the Baseline configuration.

  16. On the Real-Time tab of the myAUTOSAR_SLRT_harness model, click Run on Target and then select Build application.

    On the Real-Time tab, Run on Target and Build Application are highlighted.

  17. Open Simulink Real-Time Explorer. In the Prepare section of the toolstrip, click Load application and then select the generated myAUTOSAR_SLRT_harness.mldatx file.

    Navigate to the Parameters tab where you can see parameters INC, LIMIT, and RESET.

    The parameters tab in Simulink Real-Time Explorer.

  18. Open the Simulation Data Inspector (Simulink Real-Time). In Simulink Real-Time Explorer click Start .

  19. In the Simulation Data Inspector the signal sum_out appears, check the box to begin plotting the signal.

    The signal sum_out is logged and changing in a sinusoidal fashion peaking at 16, the value of parameter LIMIT.

  20. While the application is running, change the LIMIT parameter from 16 to 22 and see the data change in the Simulink Data Inspector in real time.

    The limit of the graph changes to 22.

  21. In order for this change to appear in the original AUTOSAR model you will need to open autosar_swc_counter and change the value of the LIMIT parameter to 22.

See Also

Apps

Functions

Related Topics