Main Content

Create Simulink Behavior Model

Create Simulink behavior models from the architecture model created in the previous step for the main application and service components. The behavior models serve as empty shells where the algorithms for each component are inserted. Copy the necessary logic for functionality of the new software component from the signal-based model to the corresponding behavior model.

To open the completed model, run this command.

open("EVPwrCntrllrEMSysFinal.slx");

Create Behavior Model for Service Components

To create the Simulink behavior models for the service components:

  1. To create the empty shell with blocks that represent the client-server interface, right-click a service component box and select Create Simulink Behavior.

    Right-click menu for the AccelPdlTrqRequest_ServiceCmp software component with the Create Simulink Behavior option selected.

  2. In the Create Simulink behavior dialog box specify a filename and location to save the shell model. Click OK.

    Create Simulink behavior dialog box.

  3. Open the shell model subsystem.

    Empty Simulink behavior model.

  4. Paste the logic required for the service component functionality from the signal-based model to the shell model.

    Original function content copied into the Simulink behavior model shell.

  5. Repeat these steps for each service component.

You can find the completed service component behavior models for this example in the CreateSimulinkBehaviorModel/ServiceComponent folder.

Create Behavior Model for Main Application

To create the behavior model for the main application:

  1. To create the empty shell with blocks that represent the client-server interface, right-click on the application component box and select Create Simulink Behavior.

    Right-click menu for the EnergyMgmtAppCmp software component with the Create Simulink Behavior option selected.

  2. In the Create Simulink behavior dialog box specify a filename and location to save the shell model. Click OK.

    Create Simulink behavior dialog box.

  3. Open the shell model subsystem.

    Empty Simulink behavior model.

    Subsystems for each service are created in the application behavior model that contain a Function Caller block.

    Function caller subsystem containing a Function Caller block.

    The Function prototype parameter is set according to the function prototype definitions added to the Interface Editor in the previous step.

    Function Caller block parameters dialog box

  4. Copy the required logic from the signal-based model to the Simulink behavior model.

    In this example, the logic needed to generate brake and torque commands is copied to the Simulink behavior model.

  5. Connect the service call outs to the application component logic.

    In this example, the service call outs are grouped in pre-algorithm and post-algorithm subsystems and connected to the energy management logic to match the original software intent.

    Note

    This example creates the behavior model using an export-function model. You can also create the behavior model using a rate-based model when implementing a call to a synchronous service. For more information, see Implement Behavior of Functions Using Simulink (System Composer).

    In this high-level overview of the connected subsystems, the pre-algorithm and post-algorithm subsystems are highlighted in blue, and the main application subsystem is highlighted in green.

    Overview of the main application coponent behavior model connections.

You can find the completed application component behavior model for this example in the CreateSimulinkBehaviorModel/ApplicationComponent folder.

See Also

Topics