All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim :- Develop a MATLAB Simulink Model for Adaptive Cruise Control feature used in Automotive Vehicle Objective:- To develop a Adaptive Cruise Control feature as per the Requirement Document using MATLAB Simulink. While Developing the Adaptive Cruise Control Simulink Model, we have follow all the MBD related processes…
SIDDHESH PARAB
updated on 22 Jan 2022
Aim :- Develop a MATLAB Simulink Model for Adaptive Cruise Control feature used in Automotive Vehicle
Objective:-
Theory :-
ADAPTIVE CRUISE CONTROL (ACC) :-
Control is based on sensor information from on-board sensors. Such systems may use a radar or laser sensor or a camera setup allowing the vehicle to brake when it detects the car is approaching another vehicle ahead, then accelerate when traffic allows it to.
fig.1 Radar Detection in Adaptive Cruise Control
fig. 2 Cruise Control Button of Steering Wheel
ACC technology is widely regarded as a key component of future generations of intelligent cars. They impact driver safety and convenience as well as increasing road capacity by maintaining optimal separation between vehicles and reducing driver errors. Vehicles with autonomous cruise control are considered a Level 1 autonomous car, as defined by SAE International.
When combined with another driver assist feature such as lane centering, the vehicle is considered a Level 2 autonomous car.
Adaptive cruise control does not provide full autonomy: the system only provides some help to the driver, but does not drive the car by itself.
ACC functions by sensory technology installed within vehicles such as cameras, lasers, and radar equipment, which creates an idea of how close one car is to another, or other objects on the roadway. For this reason, ACC is the basis for future car intelligence.
These sensory technologies allow the car to detect and warn the driver about potential forward collisions. When this happens, red lights begin to flash, and the phrase 'brake now!' appears on the dashboard to help the driver slow down. There might also be an audible warning.
Types of Adaptive Cruise Control :-
(1) Radar-Based Systems :-
According to eInfoChips, radar-based systems work by placing radar-based sensors on or around plastic fascias to detect your vehicle's surroundings. Each radar sensor works together to create a comprehensive picture of the vehicle's proximity to other cars or potentially hazardous objects. This type of sensor can look different depending on the design and model of the car.
(2) Laser-Based Systems :-
As mentioned by Electronic Design, this type of ACC system operates out of a large black box typically placed in the grille of your vehicle. It uses laser technology to detect the proximity of objects to your car. It does not operate well during rainstorms and other weather conditions.
(3) Binocular Computer Vision Systems (Optical) :-
According to ExtremeTech, this is a relatively new ACC system put into use in 2013. It uses small cameras that are placed on the back of a vehicle's rearview mirror to detect front-facing objects.
(4) Assisting Systems :-
Assisting systems are radar-based add-ons that customers can buy together. These pre-crash systems can offer lane control, brake assistance, cruise control, proximity alerts to objects like corners, and steering power.
(5) Multi-Sensor Systems :-
According to Fierce Electronics, adaptive cruise control systems sometimes integrate more than one type of sensor to aid in a vehicle's operation. Multi-sensor systems incorporate several different sensor types to provide a driver with advanced information. These sensors might include GPS data equipment or cameras to gather information about a vehicle's geographic environment and proximity to other cars.
(6) Predictive Systems :-
As mentioned by Autoblog, prediction systems are a type of ACC that uses sensory data to predict the actions of neighboring vehicles. This means that your car might slow down to brace for another vehicle suddenly switching lanes and, in doing so, promotes passenger safety.
Adaptive cruise control is evolving each year. Car companies are continuously making adjustments to this technology and, in doing so, creating more common and affordable options that can be purchased with a new car or added to older car models, making driving safer for everyday people.
Advantages of Adaptive Cruise Control :-
Limitations of Adaptive Cruise Control :-
Development of Adaptive Cruise Control Model :-
fig.3 Main subsystem of Adaptive_Cruise_Control
fig.4 Inside the main subsystem of Adaptive Cruise Control
Requirement1 - Lead Vehicle :-
fig. 5 Lead Vehicle Subsystem
Requirement 2 – Drive Vehicle:-
fig. 6 Drive Vehicle Subsystem
Requirement 3 - Adaptive Cruise Control Algorithm :-
fig.7a Cruise_Control_Algorithm Subsystem
fig.7b ACC_logic of flow chart
Requirement 3a –ACC_OFF_MODE state logic :-
Requirement 3b – ACC_STANDBY_MODE state logic :-
Requirement 3c – ACC_ON_MODE state logic:
There are 6 sub states to this state logic: They are:
Requirement 3c (i) :– LeadVehicle_Detected_Follow (ACC_ON_MODE)
Requirement 3c (ii) – LeadVehicle_Not_Detected (ACC_ON_MODE)
Requirement 3c (iii) – LeadVehicle_Detected_Resume (ACC_ON_MODE)
Requirement 3c (iv) - LeadVehicle_Not_Detected_Resume (ACC_ON_MODE)
Requirement 3c (v) - LeadVehicle_Speed_lessthan_Set_Speed (ACC_ON_MODE)
Requirement 3c (vi) - LeadVehicle_Speed_equal_Set_Speed (ACC_ON_MODE)
Further, we have defined the number of input signals and output signal required in this Simulink stateflow logic in the 'Symbol Pane' option as under;
Changes in Configuration Parameters :-
We have changed the configuration parameters by firstly changing the solver settings by clicking on 'Model Settings'. After opening the 'Model Settings', converting the type as fixed step and solver as discrete (no continous)and changed the sample time as 0.01 sec.
Then, we have changed the System Target File to 'ert.tlc' under code generation section as under;
Further, in the configuration parameter under Code generation settings, we have select 'floating point number' checkbox as under;
Creation of Simulink Data Dictionary (SLDD) File :-
A Simulink Data Dictionary (SLDD) file is created so that it contains input, output signals and caliberation parameters used in the given model instead of using Init file for initilalizing caliberation values everytime.
Step 1 :-
We have to go under Modelling section and select on 'Link to Data Dictionary' as under;
Step 2 :-
Create a new data directory in the given folder and named it by giving .sldd extension.
Step 3 :-
We have been given the input signal, output signal and Caliberation values/ constant and the same are as under;
Signal / Calibration Name |
Signal Type |
Data Type |
Dimension |
Min |
Max |
Initial Value |
Units |
CameraInput_LeadVehicle |
Input |
Uint8 |
1 |
0 |
255 |
- |
- |
RadarInput_LeadVehicle |
Input |
Uint8 |
1 |
0 |
255 |
- |
- |
CameraInput_DriveVehicle |
Input |
Uint8 |
1 |
0 |
255 |
- |
- |
RadarInput_DriveVehicle |
Input |
Uint8 |
1 |
0 |
255 |
- |
- |
Time_Gap |
Input |
Uint8 |
1 |
0 |
255 |
- |
- |
Set_Speed |
Input |
Uint8 |
1 |
0 |
255 |
- |
- |
Set_Gap |
Input |
Uint8 |
1 |
0 |
255 |
- |
- |
CruiseSwitch |
Input |
Boolean |
1 |
0 |
1 |
- |
- |
SetSwitch |
Input |
Boolean |
1 |
0 |
1 |
- |
- |
Acceleration_Mode |
Output |
Uint8 |
1 |
0 |
255 |
- |
- |
LeadVehicle_Speed |
Output |
Uint8 |
1 |
0 |
255 |
- |
- |
DriveVehicle_Speed |
Output |
Uint8 |
1 |
0 |
255 |
- |
- |
LeadVehicle_Detected |
Output |
Uint8 |
1 |
0 |
255 |
- |
- |
Accordingly, we have created the Simulink Data Dictionary (SLDD) by clicking on file name i.e adaptive_cruise_control_dd.sldd and select Design data. Then, we have to select add signal and add simulink parameter depending on whether the values are input signal, output signal or constant/caliberation values
Requirement Tagging of Simulink Model:-
The requirements ‘Requirement 1’ , ‘Requirement 2’ , and ‘Requirement 3’ as provided in the Requirements Word document are tagged to their corresponding subsystem in the Simulink Model.
Steps for tagging a requirement in Simulink model :-
We have considered above steps while tagging the Requirement1,Requirement2 and Requirement3 and the same are as under;
Tagging for Requirement - 1 (Lead Vehicle):-
Tagging for Requirement - 2 (Drive Vehicle):-
Tagging for Requirement -3 Adaptive Cruise Control Algorithm:-
After successful tagging for requirements 1, requirements 2 and requirements 3, we observed that Matlab Traceability file is automatically generated in the same Matlab folder path. (The same is attached)
Steps for Checking MAB Guidelines :-
Step 1:-
We have to go into 'Modelling option' and then select 'Model Advisor'
Step 2:-
We have to choose the system for checking guidelines. In this case, we are checking full system check as under as per MAB guidelines;
Step 3 :-
Therafter, below screen appears. In this, we have to select as per Modelling standards for MAB guidelines.
Then, we have to click on 'Run Selected Check' option as under;
After running the model as per MAB Guidelines, we observed that it is sucessfully passed with value of 120 and total 24 nos. of warnings. However, there is no fail condition. Hence, we can conclude that above model is technically/logically correct.
After successful running of model as per MAB guidelines, we observed that guideline report is generated in the same Matlab folder path. (The same is attached)
Steps for Generation of Code from model:-
Step 1 :-
Go to Apps section and under Code Generation section, select Embedded Coder option.
Step 2 :-
Then, under Embedded C Code section, Click on Generate Code option as under;
Step 3 :-
In the generation of code, there is one main c file, 4 nos. of model files, 2 data files, 1 one utility file is generated as under;
After sucessful completion of Code generation, adaptive_cruise_control_ert_rtw folder is created in the Matlab path as under;
The Generated C code for adaptive_cruise_control.c file is as under;
C Code :-
/*
* File: adaptive_cruise_control.c
*
* Code generated for Simulink model 'adaptive_cruise_control'.
*
* Model version : 1.43
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Sat Jan 22 13:03:54 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "adaptive_cruise_control.h"
#include "adaptive_cruise_control_private.h"
/* Named constants for Chart: '/ACC_Logic' */
#define IN_LeadVehicle_Detected_Follow ((uint8_T)1U)
#define IN_LeadVehicle_Detected_Resume ((uint8_T)2U)
#define IN_LeadVehicle_Not_Detected_Res ((uint8_T)4U)
#define IN_LeadVehicle_Speed_equal_Set_ ((uint8_T)5U)
#define IN_LeadVehicle_Speed_lessthan_S ((uint8_T)6U)
#define ada_IN_LeadVehicle_Not_Detected ((uint8_T)3U)
#define adaptive_cr_IN_ACC_STANDBY_MODE ((uint8_T)3U)
#define adaptive_cru_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
#define adaptive_cruise_IN_ACC_OFF_MODE ((uint8_T)1U)
#define adaptive_cruise__IN_ACC_ON_MODE ((uint8_T)2U)
/* Block states (default storage) */
DW_adaptive_cruise_control_T adaptive_cruise_control_DW;
/* External outputs (root outports fed by signals with default storage) */
ExtY_adaptive_cruise_control_T adaptive_cruise_control_Y;
/* Real-time model */
static RT_MODEL_adaptive_cruise_cont_T adaptive_cruise_control_M_;
RT_MODEL_adaptive_cruise_cont_T *const adaptive_cruise_control_M =
&adaptive_cruise_control_M_;
real_T rt_roundd_snf(real_T u)
{
real_T y;
if (fabs(u) < 4.503599627370496E+15) {
if (u >= 0.5) {
y = floor(u + 0.5);
} else if (u > -0.5) {
y = u * 0.0;
} else {
y = ceil(u - 0.5);
}
} else {
y = u;
}
return y;
}
/* Model step function */
void adaptive_cruise_control_step(void)
{
/* local block i/o variables */
uint8_T LeadVehicle_Speed;
uint8_T DriveVehicle_Speed;
uint8_T LeadVehicle_Detected;
int32_T tmp;
int32_T tmp_0;
uint8_T tmp_1;
uint8_T tmp_2;
/* Sum: '/Add' incorporates:
* Inport: '/CameraInput_LeadVehicle'
* Inport: '/RadarInput_LeadVehicle'
*/
LeadVehicle_Speed = (uint8_T)((uint32_T)CameraInput_LeadVehicle +
RadarInput_LeadVehicle);
/* UnitDelay: '/Unit Delay' */
Acceleration_Mode = adaptive_cruise_control_Y.Acceleration_Mode_h;
/* Sum: '/Add' incorporates:
* Inport: '/CameraInput_DriveVehicle'
* Inport: '/RadarInput_DriveVehicle'
*/
DriveVehicle_Speed = (uint8_T)((uint32_T)(uint8_T)((uint32_T)
CameraInput_DriveVehicle + RadarInput_DriveVehicle) + Acceleration_Mode);
/* SignalConversion: '/Signal Conversion' incorporates:
* Inport: '/RadarInput_DriveVehicle'
*/
LeadVehicle_Detected = RadarInput_DriveVehicle;
/* Chart: '/ACC_Logic' incorporates:
* Inport: '/CruiseSwitch'
* Inport: '/SetSwitch'
* Inport: '/Set_Gap'
* Inport: '/Set_Speed'
* Inport: '/Time_Gap'
* UnitDelay: '/Unit Delay'
*/
if (adaptive_cruise_control_DW.is_active_c3_adaptive_cruise_co == 0U) {
adaptive_cruise_control_DW.is_active_c3_adaptive_cruise_co = 1U;
adaptive_cruise_control_DW.is_c3_adaptive_cruise_control =
adaptive_cruise_IN_ACC_OFF_MODE;
adaptive_cruise_control_Y.Acceleration_Mode_h = 0U;
} else {
switch (adaptive_cruise_control_DW.is_c3_adaptive_cruise_control) {
case adaptive_cruise_IN_ACC_OFF_MODE:
adaptive_cruise_control_Y.Acceleration_Mode_h = 0U;
if (CruiseSwitch) {
adaptive_cruise_control_DW.is_c3_adaptive_cruise_control =
adaptive_cr_IN_ACC_STANDBY_MODE;
adaptive_cruise_control_Y.Acceleration_Mode_h = 1U;
}
break;
case adaptive_cruise__IN_ACC_ON_MODE:
if (!CruiseSwitch) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
adaptive_cru_IN_NO_ACTIVE_CHILD;
adaptive_cruise_control_DW.is_c3_adaptive_cruise_control =
adaptive_cruise_IN_ACC_OFF_MODE;
adaptive_cruise_control_Y.Acceleration_Mode_h = 0U;
} else if (!SetSwitch) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
adaptive_cru_IN_NO_ACTIVE_CHILD;
adaptive_cruise_control_DW.is_c3_adaptive_cruise_control =
adaptive_cr_IN_ACC_STANDBY_MODE;
adaptive_cruise_control_Y.Acceleration_Mode_h = 1U;
} else {
switch (adaptive_cruise_control_DW.is_ACC_ON_MODE) {
case IN_LeadVehicle_Detected_Follow:
adaptive_cruise_control_Y.Acceleration_Mode_h = 2U;
if (LeadVehicle_Detected == 0) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
ada_IN_LeadVehicle_Not_Detected;
adaptive_cruise_control_Y.Acceleration_Mode_h = 1U;
} else if (((LeadVehicle_Detected == 1) && (LeadVehicle_Speed <
Set_Speed)) || (Time_Gap < Set_Gap)) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
adaptive_cruise_control_Y.Acceleration_Mode_h = 4U;
}
break;
case IN_LeadVehicle_Detected_Resume:
adaptive_cruise_control_Y.Acceleration_Mode_h = 3U;
if (LeadVehicle_Detected == 0) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Not_Detected_Res;
adaptive_cruise_control_Y.Acceleration_Mode_h = 1U;
} else if ((DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >=
Set_Speed) && (Time_Gap >= Set_Gap)) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_Follow;
adaptive_cruise_control_Y.Acceleration_Mode_h = 2U;
} else if ((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
DriveVehicle_Speed) && (Time_Gap >= Set_Gap)) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_equal_Set_;
adaptive_cruise_control_Y.Acceleration_Mode_h = 5U;
}
break;
case ada_IN_LeadVehicle_Not_Detected:
adaptive_cruise_control_Y.Acceleration_Mode_h = 1U;
if ((LeadVehicle_Detected == 1) && (DriveVehicle_Speed == Set_Speed) &&
(LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_Follow;
adaptive_cruise_control_Y.Acceleration_Mode_h = 2U;
} else if (((LeadVehicle_Detected == 1) && (LeadVehicle_Speed <
Set_Speed)) || (Time_Gap < Set_Gap)) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
adaptive_cruise_control_Y.Acceleration_Mode_h = 4U;
}
break;
case IN_LeadVehicle_Not_Detected_Res:
adaptive_cruise_control_Y.Acceleration_Mode_h = 1U;
break;
case IN_LeadVehicle_Speed_equal_Set_:
adaptive_cruise_control_Y.Acceleration_Mode_h = 5U;
if ((LeadVehicle_Detected == 0) || (DriveVehicle_Speed <= Set_Speed))
{
adaptive_cruise_control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Not_Detected_Res;
adaptive_cruise_control_Y.Acceleration_Mode_h = 1U;
} else if (((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
DriveVehicle_Speed)) || (Time_Gap >= Set_Gap)) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_Resume;
adaptive_cruise_control_Y.Acceleration_Mode_h = 3U;
} else if (((LeadVehicle_Speed < Set_Speed) && (LeadVehicle_Speed <
DriveVehicle_Speed)) || ((int32_T)rt_roundd_snf(0.75 *
(real_T)Set_Gap) == Time_Gap)) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
adaptive_cruise_control_Y.Acceleration_Mode_h = 4U;
}
break;
default:
/* case IN_LeadVehicle_Speed_lessthan_Set_Speed: */
adaptive_cruise_control_Y.Acceleration_Mode_h = 4U;
if ((LeadVehicle_Detected == 0) && (DriveVehicle_Speed == Set_Speed))
{
adaptive_cruise_control_DW.is_ACC_ON_MODE =
ada_IN_LeadVehicle_Not_Detected;
adaptive_cruise_control_Y.Acceleration_Mode_h = 1U;
} else {
tmp = (int32_T)rt_roundd_snf((real_T)LeadVehicle_Speed * 1.25);
tmp_0 = (int32_T)rt_roundd_snf(1.25 * (real_T)Set_Gap);
if (tmp < 256) {
tmp_1 = (uint8_T)tmp;
} else {
tmp_1 = MAX_uint8_T;
}
if (tmp_0 < 256) {
tmp_2 = (uint8_T)tmp_0;
} else {
tmp_2 = MAX_uint8_T;
}
if ((tmp_1 >= DriveVehicle_Speed) && ((int32_T)rt_roundd_snf((real_T)
LeadVehicle_Speed * 0.75) <= DriveVehicle_Speed) &&
(DriveVehicle_Speed < Set_Speed) && (Time_Gap <= tmp_2) &&
(Time_Gap >= (int32_T)rt_roundd_snf(0.75 * (real_T)Set_Gap))) {
adaptive_cruise_control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_equal_Set_;
adaptive_cruise_control_Y.Acceleration_Mode_h = 5U;
}
}
break;
}
}
break;
default:
/* case IN_ACC_STANDBY_MODE: */
adaptive_cruise_control_Y.Acceleration_Mode_h = 1U;
if (!CruiseSwitch) {
adaptive_cruise_control_DW.is_c3_adaptive_cruise_control =
adaptive_cruise_IN_ACC_OFF_MODE;
adaptive_cruise_control_Y.Acceleration_Mode_h = 0U;
} else if (SetSwitch) {
adaptive_cruise_control_DW.is_c3_adaptive_cruise_control =
adaptive_cruise__IN_ACC_ON_MODE;
adaptive_cruise_control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_Follow;
adaptive_cruise_control_Y.Acceleration_Mode_h = 2U;
}
break;
}
}
/* End of Chart: '/ACC_Logic' */
}
/* Model initialize function */
void adaptive_cruise_control_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void adaptive_cruise_control_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Project 2-Highway Assistant-Lane Changing Assistant
Aim :- Model Based Development of Highway Assistant – Lane Changing Assistant Objective :- To develop one specific requirement of Highway Assistant – Lane Changing Assistant algorithm. Please note that the whole Highway Assistant – Lane Changing Assistant is a very huge algorithm & only one small…
14 Feb 2022 04:19 PM IST
Project 1- Traffic Jam Assistant Feature
Aim :- Traffic Jam Assistant Feature Objective :- This model must be developed in MATLAB Simulink as per MBD guidelines according to the requirements given. Tag the requirements to the Simulink model, Requirements 1 & Requirement 2 are tagged into their corresponding subsystems. Creation of Simulink Data Dictionary…
05 Feb 2022 06:55 PM IST
Design of an Electric Vehicle
AIM:- Create a MATLAB model of an electric car that uses a battery and a DC motor. Choose suitable blocks from the Powertrain block set. Prepare a report about your model including the following: ABSTRACT:- In this project, we going to build the MATLAB model of ELECTRIC CAR by using a DC motor and a suitable battery for…
01 Feb 2022 06:47 AM IST
Project 2 Adaptive Cruise Control
Aim :- Develop a MATLAB Simulink Model for Adaptive Cruise Control feature used in Automotive Vehicle Objective:- To develop a Adaptive Cruise Control feature as per the Requirement Document using MATLAB Simulink. While Developing the Adaptive Cruise Control Simulink Model, we have follow all the MBD related processes…
22 Jan 2022 08:13 AM IST
Related Courses
8 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.