Add a cruise control feature to a car model
PRESENTATION
This tutorial has to be done from the Include a matlab activity in a model: Emergency Braking.
Prerequisites
Import the following model: File -> New -> Example -> Sim4Sys Model Examples -> Sim4Sys - Automotive.
Select Tutorial6.
News skills that you will acquire
On Designer:
- Add a performance to an internal activity,
- Concept on Interservice,
- Generate a document.
On Virtual Bench:
- Use a new Context elements: Toggle button, Slider range input, Number, Picto, Curve graph, Button.
Duration
4h
INTRODUCTION
In this tutorial we're going to design a Cruise control system. The cruise control system allows the car to maintain a cruising speed. When the user makes a speed request, we want the car to automatically increase or decrease the throttle to reach the defined speed. The service SpeedManagement will handle the action on the throttle depending on the request taken. With the implementation of such a system we want to be able to:
- Enable/Disable the cruise control.
- Pause/Resume the cruise control.
- Get a speed request from the user.
- Determine if the car needs to accelerate or brake.
- Accelerate or brake accordingly.
- Maintain a steady speed.
Similarly to the Include a matlab activity in a model tutorial, we will have interService interactions. A new service called CruiseControl will take the user request, process it, and pass the information to the SpeedManagement service which will accelerate or brake in order to maintain a cruising speed.
CREATE NEW SERVICE AND USE CASES
- Papyrus
First, we need to create a new service called CruiseControl.
- Open the Car structure diagram.
- Drag & drop a new service in the car structure. Name it CruiseControl.
- Click on the new service, then in the Relevant Phase Diagram add a New Life Phase: Standard Use
The next step is to create all the use cases for our cruise control service:
-
Go to the UCD diagram.
-
Create the following cases:
- Activate cruise control.
- Deactivate cruise control.
- Pause cruise control.
- Resume cruise control.
- Request speed.
- Manage request.
-
Add a new actor named user and associate it with the use cases previously created.
We are now going to add user stories to each use case we created.
Create the following User story:
- Activate cruise control
- The_user_requests_cruise_control.
- Deactivate cruise control
- The_user_requests_no_cruise_control.
- The_user_requests_no_cruise_control_during_pause.
- Pause cruise control
- The_user_pause_cruise_control.
- Resume cruise control
- The_user_resume_cruise_control.
- Request speed
- The_user_requests_a_speed.
- Manage request
- The_request_is_accelerating.
- The_request_is_braking.
- The_request_acceleration_is_done.
- The_request_brake_is_done.

CREATE NEW TYPE
- Papyrus
We need to create a new type to handle the cruise control state.
Add a new enumeration CruiseControlType and drag & drop 4 new literals:
- accelerate.
- brake.
- pending.
- none.

CREATE NEW STATE
- Papyrus
The Cruise control service can have 4 different states depending on its usage:
- Available: a composite state representing the availability of the Cruise Control Service.
- Inactive: the cruise control is not engaged.
- Active: the cruise control is engaged and controls the vehicle's speed.
- Interrupt: an interrupt state, likely for situations where the cruise control is temporarily disengaged (such as during manual braking).
Following the car model, we can have different types of cruise control. In this tutorial we will implement a cruise control that can memorize speed requests even if it's not turned on. Hence the Available state: it will listen to the user request whether it is turned on or off.
In this Available state, we have 3 sub-states:
- Inactive: the user has turned the cruise control off.
- Active: the user has turned the cruise control on .
- Interrupt: the user paused the cruise control by pressing the brakes.
Our state structure will look like this:
- Available
- Inactive.
- Active.
- Interrupt.
To create this, go to the CruiseControl state machine:
- Rename FirstState to Available.
- Add a new Inactive state inside the Available state.
- Add an initial point inside the Available state.
- Trace a transition between the initial point and the state Inactive.
- Add a new Active state inside the Available state.
- Add a new Interrupt state inside the Available state.
Your CruiseControl state machine should now look like this:
