All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM: To develop the vehicle Adaptive Cruise Control feature using MATLAB Simulink. OBJECTIVE: Develop an Adaptive Cruise Control feature as per the Requirement Document available using MATLAB & Simulink. To Follow all the MBD related processes: Requirement Tagging & Traceability, SLDD creation, Configuration…
Bipin Lakshapati
updated on 07 Dec 2021
AIM: To develop the vehicle Adaptive Cruise Control feature using MATLAB Simulink.
OBJECTIVE:
Software/Tool Used: MATLAB R2021a
GENERAL OVERVIEW:
Adaptive Cruise Control Feature for passenger cars allows the host vehicle to adapt to the speed in line with the flow of traffic. Driving in heavy traffic or keeping a safe distance to the preceding vehicle calls for a high level of concentration. The Adaptive Cruise Control feature can reduce the stress on the driver by automatically controlling the vehicle speed & maintaining a predefined minimum distance to the preceding vehicle. As a consequence, the driver enjoys more comfort & can concentrate on the road little better.
A radar sensor is usually at the core of the Adaptive Cruise Control. Installed at the front of the vehicle, the system permanently monitors the road ahead. As long as the road ahead is clear, cruise control feature maintains the speed set by the driver. If the system spots a slower vehicle within its detection range, it gently reduces speed by releasing the accelerator or actively engaging the brake control system. If the vehicle ahead speeds up or changes lanes, the cruise control automatically accelerates to the driver’s desired speed.
Standard Adaptive Cruise Control can be activated from speeds of around 30 km/h (20 mph) upwards and supports the driver, primarily on cross-country journeys or on freeways. The cruise control stop & go variant is also active at speeds below 30 km/h (20 mph). It can maintain the set distance to the preceding vehicle even at very low speeds and can decelerate to a complete standstill. When the vehicle remains stopped longer, the driver needs only to reactivate the system, for example by briefly stepping on the gas pedal to return to cruise control mode. In this way, cruise control stop & go supports the driver even in heavy traffic and traffic jams.
Since Adaptive Cruise Control is a comfort and convenience system, brake interventions and vehicle acceleration only take place within defined limits. Even with Adaptive Cruise Control switched on, it remains the driver’s responsibility to monitor the speed and distance from the vehicle in front.
ACC systems use onboard computers and sophisticated sensors, such as radar or laser systems, to monitor the other vehicles on the road. Because of this, adaptive cruise control is also called radar cruise control or autonomous cruise control.
Once the driver locks his or her preferred speed into the ACC system, the vehicle will monitor its surroundings. The system runs a signal from its radar headway system through a digital signal processor to determine the distance to the nearest car, and it then uses a longitudinal controller to determine a safe following distance.
If the driver’s vehicle has too little following distance, the ACC system sends a signal to the engine or brakes, slowing the vehicle down. Once the path is clear, the ACC system will accelerate the vehicle back to the driver’s preferred speed. By restricting airflow to the engine when the vehicle is close to its speed setting and increasing airflow when the vehicle is below its speed setting, the cruise control system helps the car maintain a near-constant speed.
Signals & Calibration Data List:
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 |
- |
- |
Simulink Model:
Inside Adaptive_Cruise_Control subsystem:
PROCEDURE:
Requirement 1– Lead Vehicle:
Requirement 2 – Drive Vehicle:
Requirement 3 – Adaptive Cruise Control Algorithm:
Requirement 3a – ACC OFF MODE state logic:
Requirement 3b – ACC STANDBY MODE state logic:
Requirement 3c – ACC ON MODE state logic:
This state will be activated when input signal SetSwitch is equal to 1. 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):
Simulink Data Dictionary:
After creating the model, each signal, calibration parameters & variables are configured and stored in the Simulink Data Dictionary by the name ACC_SLDD.sldd
Configuration Parameter Changes:
Under code generation setting of configuration parameters, Embedded coder is used for code generation using code language as 'c' where system target file is selected as ert.tlc
Model Advisor Check & Model Report:
Model advisor checks are performed to ensure the warnings & errors present in the model & model setting should get minimized. And these errors & warnings are rectified/optimized accordingly on each Model Advisor run.
Model advisor checks are performed on Modeling Standards for MISRA C:2012 and eliminated all errors & warnings. After doing this model advisor report is obtained.
Model Advisor Report:
Code Generation:
After getting zero errors & warnings in model advisor report we proceed for code generation by selecting Apps>>Embedded Coder>>Build>>Generate Code and Build Model or else we can simply do Ctrl D (for updating model) and Ctrl B option for code generation.
Generated code files are attached for reference.
/*
* Trial License - for use to evaluate programs for possible purchase as
* an end-user only.
*
* File: Adaptive_Cruise_Control.c
*
* Code generated for Simulink model 'Adaptive_Cruise_Control'.
*
* Model version : 1.34
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Tue Dec 7 19:44:34 2021
*
* 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"
#include "rt_roundd_snf.h"
/* Named constants for Chart: '<S4>/Adaptive Cruise Control Algorithm' */
#define Ada_IN_LeadVehicle_Not_Detected ((uint8_T)4U)
#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)
#define IN_LeadVehicle_Detected_Follow ((uint8_T)1U)
#define IN_LeadVehicle_Detected_Not_Res ((uint8_T)2U)
#define IN_LeadVehicle_Detected_Resume ((uint8_T)3U)
#define IN_LeadVehicle_Speed_equal_Set_ ((uint8_T)5U)
#define IN_LeadVehicle_Speed_lessthan_S ((uint8_T)6U)
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
uint8_T Acceleration_Mode; /* '<S4>/Adaptive Cruise Control Algorithm' */
/* Definition for custom storage class: Localizable */
uint8_T DriveVehicle_Speed; /* '<S3>/Add' */
uint8_T LeadVehicle_Detected; /* '<S3>/Signal Conversion' */
uint8_T LeadVehicle_Speed; /* '<S2>/Add' */
/* Block states (default storage) */
DW_Adaptive_Cruise_Control_T Adaptive_Cruise_Control_DW;
/* 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_;
/* Model step function */
void Adaptive_Cruise_Control_step(void)
{
int32_T tmp;
int32_T tmp_0;
uint8_T tmp_1;
uint8_T tmp_2;
/* Outputs for Atomic SubSystem: '<Root>/Adaptive_Cruise_Control' */
/* Sum: '<S3>/Add' incorporates:
* Delay: '<S1>/Delay'
* Inport: '<Root>/CameraInput_DriveVehicle'
* Inport: '<Root>/RadarInput_DriveVehicle'
*/
DriveVehicle_Speed = (uint8_T)(((uint32_T)((uint8_T)(((uint32_T)
RadarInput_DriveVehicle) + ((uint32_T)CameraInput_DriveVehicle)))) +
((uint32_T)Adaptive_Cruise_Control_DW.Delay_DSTATE[0]));
/* Sum: '<S2>/Add' incorporates:
* Inport: '<Root>/CameraInput_LeadVehicle'
* Inport: '<Root>/RadarInput_LeadVehicle'
*/
LeadVehicle_Speed = (uint8_T)(((uint32_T)CameraInput_LeadVehicle) + ((uint32_T)
RadarInput_LeadVehicle));
/* SignalConversion: '<S3>/Signal Conversion' incorporates:
* Inport: '<Root>/RadarInput_DriveVehicle'
*/
LeadVehicle_Detected = RadarInput_DriveVehicle;
/* Chart: '<S4>/Adaptive Cruise Control Algorithm' incorporates:
* Inport: '<Root>/CruiseSwitch'
* Inport: '<Root>/SetSwitch'
* Inport: '<Root>/Set_Gap'
* Inport: '<Root>/Set_Speed'
* Inport: '<Root>/Time_Gap'
*/
if (((uint32_T)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;
Acceleration_Mode = 0U;
} else {
switch (Adaptive_Cruise_Control_DW.is_c3_Adaptive_Cruise_Control) {
case Adaptive_Cruise_IN_ACC_OFF_MODE:
Acceleration_Mode = 0U;
if (CruiseSwitch) {
Adaptive_Cruise_Control_DW.is_c3_Adaptive_Cruise_Control =
Adaptive_Cr_IN_ACC_STANDBY_MODE;
Acceleration_Mode = 1U;
}
break;
case Adaptive_Cruise__IN_ACC_ON_MODE:
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;
Acceleration_Mode = 1U;
} else {
switch (Adaptive_Cruise_Control_DW.is_ACC_ON_MODE) {
case IN_LeadVehicle_Detected_Follow:
Acceleration_Mode = 2U;
if (((int32_T)LeadVehicle_Detected) == 0) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
Ada_IN_LeadVehicle_Not_Detected;
Acceleration_Mode = 1U;
} else if (((((int32_T)LeadVehicle_Detected) == 1) &&
(LeadVehicle_Speed < Set_Speed)) || (Time_Gap < Set_Gap))
{
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
} else {
/* no actions */
}
break;
case IN_LeadVehicle_Detected_Not_Res:
Acceleration_Mode = 1U;
break;
case IN_LeadVehicle_Detected_Resume:
Acceleration_Mode = 3U;
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;
Acceleration_Mode = 2U;
} else if (((int32_T)LeadVehicle_Detected) == 0) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_Not_Res;
Acceleration_Mode = 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_Speed_equal_Set_;
} else {
/* no actions */
}
break;
case Ada_IN_LeadVehicle_Not_Detected:
Acceleration_Mode = 1U;
if (((((int32_T)LeadVehicle_Detected) == 1) && (LeadVehicle_Speed <
Set_Speed)) || (Time_Gap < Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
} else if ((((((int32_T)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;
Acceleration_Mode = 2U;
} else {
/* no actions */
}
break;
case IN_LeadVehicle_Speed_equal_Set_:
if ((((int32_T)LeadVehicle_Detected) == 0) || (DriveVehicle_Speed <=
Set_Speed)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_Not_Res;
Acceleration_Mode = 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;
Acceleration_Mode = 3U;
} else if (((LeadVehicle_Speed < Set_Speed) && (LeadVehicle_Speed <
DriveVehicle_Speed)) || (((int32_T)rt_roundd_snf(0.75 *
((real_T)Set_Gap))) == ((int32_T)Time_Gap))) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
} else {
/* no actions */
}
break;
default:
/* case IN_LeadVehicle_Speed_lessthan_Set_Speed: */
if ((((int32_T)LeadVehicle_Detected) == 0) && (DriveVehicle_Speed ==
Set_Speed)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
Ada_IN_LeadVehicle_Not_Detected;
Acceleration_Mode = 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)) <= ((int32_T)
DriveVehicle_Speed))) && (DriveVehicle_Speed < Set_Speed)) &&
(Time_Gap <= tmp_2)) && (((int32_T)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_;
}
}
break;
}
}
break;
default:
/* case IN_ACC_STANDBY_MODE: */
Acceleration_Mode = 1U;
if (!CruiseSwitch) {
Adaptive_Cruise_Control_DW.is_c3_Adaptive_Cruise_Control =
Adaptive_Cruise_IN_ACC_OFF_MODE;
Acceleration_Mode = 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;
Acceleration_Mode = 2U;
} else {
/* no actions */
}
break;
}
}
/* End of Chart: '<S4>/Adaptive Cruise Control Algorithm' */
/* Update for Delay: '<S1>/Delay' */
Adaptive_Cruise_Control_DW.Delay_DSTATE[0] =
Adaptive_Cruise_Control_DW.Delay_DSTATE[1];
Adaptive_Cruise_Control_DW.Delay_DSTATE[1] = Acceleration_Mode;
/* End of Outputs for SubSystem: '<Root>/Adaptive_Cruise_Control' */
}
/* 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 Adaptive Cruise Control
AIM: To develop the vehicle Adaptive Cruise Control feature using MATLAB Simulink. OBJECTIVE: Develop an Adaptive Cruise Control feature as per the Requirement Document available using MATLAB & Simulink. To Follow all the MBD related processes: Requirement Tagging & Traceability, SLDD creation, Configuration…
07 Dec 2021 02:34 PM IST
Project 1 (Mini Project on Vehicle Direction Detection
Requirement - 1: Steering wheel input as yaw rate (Signal name: SteeringWheel_YawDegreeInput) is the input for this system. This is compared against 3 angular values, one each for left turn, right turn & straight drive (Calibration Values: Right_Turn_AngularLimit, Left_Turn_AngularLimit, Straight_Drive_Steering_Angle)…
06 Dec 2021 02:23 PM IST
Project 2 Thermal modeling of battery pack
For a 10 cell series lithium ion battery model, simulate the thermal effects and compare life cycle performance at various temperatures, charge & discharge rates using MATLAB. ANS: Introduction: Lithium-ion battery A Li-ion battery or Lithium-ion battery is one of the type of rechargeable batteries.…
25 Nov 2021 01:58 PM IST
Project 1 Mechanical design of battery pack
Battery pack capacity: 18 kWh Cell: ANR26650M1-B Prepare a detailed battery pack drawing along with its enclosure. State your assumptions. ANS: AIM: To develop mechanical design of a battery pack based on the 18kWh energy capacity. The below image is of Nanophosphate High Power Li-ion cell ANR26650M1-B…
24 Nov 2021 04:18 PM 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.