Simulation of the CruiseControlSystem example

You can follow the CruiseControlSystem simulation example to activate and run the simulation of your dynamic models.

Before you begin

The following software is required for integrating Simulink components into a Rational® Rhapsody® model:
  • Matlab must be available and licensed (Matlab 7), with Simulink (version 6), and the Real-Time Workshop component which generates C and C++ code from Simulink models.
  • Version 7.0 or greater of the Rational Rhapsody product.

Procedure

  1. Open a new or existing Rational Rhapsody model in C or C++.
  2. Optional: Add the SysML profile.
  3. Add the Simulink, or SimulinkInC if C is the language of the profile.
  4. Create some new blocks, and give those blocks the SimulinkBlock stereotype. These blocks represent the continuous subsystems.
  5. Right click on each SimulinkBlock, and select Import/Sync Simulink model.

    Accept Time Event button

  6. In the Import/Synch Simulink Model, select the location of the Simulink model, and click the Import/Sync button.

    Accept Time Event button

  7. Create some new blocks and implement their behavior. These blocks are the discrete subsystems.
  8. Create a new block, that will be the builder block, and assign it with the SimulinkStructureBlock stereotype.
  9. Open the feature's dialog window of theSimulinkStructureBlock, open the Tags tab, and fill in the needed info for the Simulink simulation.

    Accept Time Event button

  10. Create an Internal Block Diagram (IBD) to the SimulinkStructureBlock, add parts of the Rhapsody and SimulinkBlocks, and connect the flowports of the parts via connectors (links).

    Accept Time Event button

  11. Right click on the SimulinkStructureBlock or in the Internal Block Diagram (IBD), and choose one of the four options under the Simulink submenu
    • Generate: generates the SimulinkStructureBlock as a Simulink model. The Rhapsody generated code is not going to be instrumented.
    • Generate and Simulate: generates the SimulinkStructureBlock as a Simulink model, and auto starts the Simulink simulation.
    • Generate for Animation: generates the SimulinkStructureBlockas a Simulink model. You will be able to see only the animation of the Rhapsody blocks.
    • Generate and Simulate for Animation: generates the SimulinkStructureBlock as a Simulink model, and auto starts the Simulink simulation.

    Accept Time Event button

    As a result, Matlab opens, a new SFunction is created and compiled, and a new Simulink model appears representing the SimulinkStructureBlock. The SimulinkBlocks, PropFeedback and EnvironmentReaction exist as regular Simulink subsystems, and all Rhapsody blocks are transformed into one SFunction, which is implemented via the Rhapsody generated code.

    Accept Time Event button

Results

Now, you can simulate the system in Simulink. The left scope image represents the desiredSpeed simulation example, and the right image represents the actualSpeed simulation example.

Accept Time Event button


Feedback