Project 2 Adaptive Cruise Control
ADAPTIVE CRUISE CONTROL
Aim: To model the Adaptive Cruise Control in the Simulink by following the MBD process Requirement tagging and traceability, SLDD, etc.,
Objective:
a) To develop the Adaptive Cruise Control feature as per the requiremnet using Simulink.
b) To follow the MBD process: Requirement tagging and traceability, SLDD, Model Advisor, Code Geneeration.
c) To make required changes in the Configuration Parameters.
d) While choosing code generation, Storage class for Input signals: ImportedExtern; Storage class for Output signal: Export to File; Storage class for local signals: localizable; Storage class for calibration signals: Const.
e) Choose sample time as 0.01s for all signals.
Overview:
- Adaptive cruise control (ACC) is an intelligent form of cruise control that slows down and speeds up automatically to keep pace with the car in front of you.
- The driver sets the maximum speed — just as with cruise control — then a radar sensor watches for traffic ahead, locks on to the car in a lane, and instructs the car to stay 2, 3, or 4 seconds behind the person car ahead of it.
- ACC is now almost always paired with a pre-crash system that alerts you and often begins braking.
- Adaptive cruise control is also called active cruise control, autonomous cruise control, intelligent cruise control, or radar cruise control.
- This is the case because distance is measured by a small radar unit behind the front grille or under the bumper.
- Some units employ a laser, regardless of the technology, ACC works day and night, but its abilities are hampered by heavy rain, fog, or snow.
- ACC is a crucial part of the self-driving cars of the near future. On an autonomous driving car, ACC needs to track the car in front but also cars in adjacent lanes in case a lane change becomes necessary.
- 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.
Signals and 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 |
- |
- |
Main Model:

- This is the outline model of the ACC lets view inside parts of the model to understand the model.

- This is the actual model as per the requirement analysis, in this we have 3 different subsystems namely Lead_Vehicle, Drive_Vehicle and Adaptive_Cruise_Control which is the main subsystem of the model.
- Now lets deep dive into the each subsystem and built the model according the requirements mentioned.
Requirement 1: Lead_Vehicle
- Lead Vehicle is a vehicle which is driving in the road ahead of our drive vehicle. It has two input signals namely CameraInput_LeadVehicle & RadarInput_LeadVehicle.
- Ideally sensor fusion techniques will be deployed to process & analyze data from camera & radar. For complexity reasons, let’s not adapt to any such algorithms.
- Here we add both the radar & camera inputs & the corresponding output is read as Speed profile output naming as LeadVehicle_Speed
- Speed data of the lead vehicle is critical in implementing the Adaptive Cruise Control algorithm.


Requirement 2: Drive_Vehicle
- Drive Vehicle is the vehicle driven by the user, its the vehicle which has ACC algorithm in it.
- Drive Vehicle algorithm also has 2 input signals namely CameraInput_DriveVehicle, RadarInput_DriveVehicle & one signal coming as an Input to this subsystem name Acceleration_Mode making three inputs to this requirement in total.
- Sensor fusion techniques will also be deployed here, for complexity reasons we are ignoring them.
- Two output signals come from this subsystem naming DriveVehicle_Speed & LeadVehicle_Detected.
- Signal DriveVehicle_Speed is summation of three input signals CameraInput_DriveVehicle, RadarInput_DriveVehicle & Acceleration_Mode
- Signal LeadVehicle_Detected is renamed from Input Signal RadarInput_DriveVehicle by mere use of Signal Conversion block.


Requirement 3: Adapative_Cruise_Control Algorithm
- Adaptive Cruise Control feature has 3 major modes of operation: OFF Mode, STANDBY Mode & ON Mode. This particular requirement has to be implemented as state machine logic in Simulink.
- The input signals to this state machine system are Time_Gap, Set_Speed, Set_Gap, CruiseSwitch, SetSwitch.
- The output signals DriveVehicle_Speed & LeadVehicle_Detected from requirement-2 is fedback as an input signal into this state machine block.
- The output signal LeadVehicle_Speed from requirement-1 is given as an input signal to this state machine block as well.
- Output from this subsystem is a signal naming as Acceleration_Mode which governs the vehicular speed of the drive vehicle which automatically adjusts its speed & velocity to match the lead vehicle.


Requiement 3a: ACC_OFF Mode state logic
- This is the default state inside state machine logic. Output signal Acceleration_Mode is at value 0 in this state.
- This state is governed by input signal CruiseSwitch.
- If CruiseSwitch is equal to 1, state ACC STANDBY mode will get activated. If CruiseSwitch is equal to 0, state ACC OFF mode will get activated, from either ACC ON mode or ACC STANDBY mode.
Requirement 3b: ACC_STANDBY Mode state logic
- This is the second activated state inside state machine logic. Output signal Acceleration_Mode is at value 1 in this state.
- This state is governed by both input signals CruiseSwitch & SetSwitch.
- If CruiseSwitch is equal to 1, state ACC STANDBY mode will get activated. If CruiseSwitch is equal to 0, state ACC OFF mode will get activated, from either ACC ON mode or ACC STANDBY mode
- If SetSwitch is equal to 1, state ACC ON mode will get activated. If SetSwitch is equal to 0, state ACC STANDBY mode will get activated.
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:
- LeadVehicle_Detected_Follow (Default)
- LeadVehicle_Not_Detected
- LeadVehicle_Detected_Resume
- LeadVehicle_Not_Detected_Resume
- LeadVehicle_Speed_lessthan_Set_Speed
- LeadVehcile_Speed_equal_Set_Speed
Requirement 3c(i): LeadVehicle_Detected_Follow (ACC_ON MODE)
- This is the default substate inside ACC ON MODE state. Output signal Acceleration_Mode is equal to 2.
- Condition to transit from LeadVehicle_Detected_Follow to LeadVehicle_Not_Detected; Input signal condition LeadVehicle_Detected == 0.
- Condition to transit from LeadVehicle_Detected_Follow to LeadVehicle_Speed_lessthan_Set_Speed; Input Signals condition (LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed) || (Time_Gap < Set_Gap).
Requirement 3c(ii): LeadVehicle_Not_Detected (ACC_ON MODE)
- Output signal Acceleration_Mode is equal to 1.
- Condition to transit from LeadVehicle_Not_Detected to LeadVehicle_Detected_Follow; Input signals condition [(LeadVehicle_Detected==1) && (DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)]
- Condition to transit from LeadVehicle_Not_Detected to LeadVehicle_Speed_lessthan_Set_Speed; Input signals condition [(LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed) || (Time_Gap < Set_Gap)]
Requirement 3c(iii): LeadVehicle_Detected_Resume (ACC_ON MODE)
- Output signal Acceleration_Mode is equal to 3.
- Condition to transit from LeadVehicle_Detected_Resume to LeadVehicle_Detected_Follow; Input signals condition [(DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)]
- Condition to transit from LeadVehicle_Detected_Resume to LeadVehicle_Not_Detected_Resume; Input signal condition LeadVehicle_Detected==0.
- Condition to transit from LeadVehicle_Detected_Resume to LeadVehicle_Speed_equal_Set_Speed; Input Signal condition [(DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed > DriveVehicle_Speed) && (Time_Gap >= Set_Gap)]
Requirement 3c(iv): LeadVehicle_Not_Detected_Resume (ACC_ON MODE)
- Output signal Acceleration_Mode is equal to 1.
Requirement 3c(v): LeadVehicle_Speed_lessthan_Set_Speed (ACC_ON MODE)
- Output signal Acceleration_Mode is equal to 4.
- Condition to transit from LeadVehicle_Speed_lessthan_Set_Speed to LeadVehicle_Not_Detected; Input signal condition [(LeadVehicle_Detected == 0) && (DriveVehicle_Speed == Set_Speed)]
- Condition to transit from LeadVehicle_Speed_lessthan_Set_Speed to LeadVehicle_Speed_equal_Set_Speed; Input signals condition [((LeadVehicle_Speed*1.25>=DriveVehicle_Speed) && (LeadVehicle_Speed * 0.75<=DriveVehicle_Speed)) && (DriveVehicle_Speed < Set_Speed) && ((Time_Gap<=1.25*Set_Gap) && (Time_Gap >=0.75*Set_Gap))]
Requirement 3c(vi): LeadVehicle_Speed_equal_Set_Speed (ACC_ON MODE)
- Output signal Acceleration_Mode is equal to 5.
- Condition to transit from LeadVehicle_Speed_equal_Set_Speed to LeadVehicle_Not_Detected_Resume; Input signal conditions is [(LeadVehicle_Detected == 0) || (DriveVehicle_Speed <= Set_Speed)]
- Condition to transit from LeadVehicle_Speed_equal_Set_Speed to LeadVehicle_Detected_Resume; Input signal conditions [(DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed > DriveVehicle_Speed) || (Time_Gap >= Set_Gap)]
- Condition to transit from LeadVehicle_Speed_equal_Set_Speed to LeadVehicle_Speed_lessthan_Set_Speed; Input signals conditions [(LeadVehicle_Speed < Set_Speed) && (LeadVehicle_Speed < DriveVehicle_Speed) || (Time_Gap == 0.75*Set_Gap)].


- The model is completed lets create a requirement and tag the requiement as per the model and also generate a tracebility report so that in future if anyone would easily refere the model and understand it easily and can make modifications easily.
Requirement Tagging:
|
Requirement No |
Requirement tagging |
Outputs signal |
|
Reqmnt 1 |
Lead_Vehicle |
LeadVehicle_Speed |
|
Reqmnt 2 |
Drive_Vehicle |
DriveVehicle_Speed & LeadVehicle_Detected |
|
Reqmnt 3 |
Adaptive_Cruise_Control Algorithm |
Acceleration_Mode |
|
Reqmnt 3a |
ACC_OFF MODE state logic |
Acceleration_Mode = 0 |
|
Reqmnt 3b |
ACC_STANDBY MODE state logic |
Acceleration_Mode = 1 |
|
Reqmnt 3c |
ACC_ON MODE state logic |
Acceleration_Mode |
|
Reqmnt 3c(i) |
Lead_Vehicle_Detected_Follow (ACC_ON MODE) |
Acceleration_Mode = 2 |
|
Reqmnt 3c(ii) |
Lead_Vehicle_Not_Detected (ACC_ON MODE) |
Acceleration_Mode = 1 |
|
Reqmnt 3c(iii) |
Lead_Vehicle_Detected_Resume (ACC_ON MODE) |
Acceleration_Mode = 3 |
|
Reqmnt 3c(iv) |
Lead_Vehicle_Not_Detected_Resume (ACC_ON MODE) |
Acceleration_Mode = 1 |
|
Reqmnt 3c(v) |
Lead_Vehicle_Speed_lessthan_Set_Speed (ACC_ON MODE) |
Acceleration_Mode = 4 |
|
Reqmnt 3c(vi) |
Lead_Vehicle_Speed_equal_Set_Speed (ACC_ON MODE) |
Acceleration_Mode = 5 |
- All the requirements can be viewed after tagging here i have shown only few screenshots of the taggings others can be viewed in the model through reuirements viewer.
- We have also generated the report of the Traceability which i have mentioned in the google link.
SLDD:

- All the inputs, outputs, calibration parameters are saved in the SLDD when performing the Simulation the model takes the values and parameters from SLDD.
Model Update:
- The model update is done by Ctrl+D, this is done to check for any static errors. If no errors are coming the model is working correctly.
Configuration Parameter Settings:









- Various parameters have been updated as per the model, Solver to fixed step, Code generation target file to ert.tlc etc., as shown above.
Model Advisor:
- In Model Advisor we doesn't check all the parameters here we have checked only two Requirements Consisteny Checking and Modeling Standards of MAB and click on Run Selected Checks.


- In this we got 122 checks as Pass and 23 Checks as Warning. See the warnings if it is necessary then only go for the change in the warnings otherwise remain like that only.
- Click on generate report to downaload the full report for future purpose.

Code Generation:
/*
* File: Adaptive_Cruise_Control.c
*
* Code generated for Simulink model 'Adaptive_Cruise_Control'.
*
* Model version : 1.14
* Simulink Coder version : 9.3 (R2020a) 18-Nov-2019
* C/C++ source code generated on : Thu Oct 21 15:42:23 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"
/* Named constants for Chart: '<S2>/Adaptive_Cruise_Control' */
#define Ada_IN_LeadVehicle_Not_Detected ((uint8_T)3U)
#define Adaptive_Cru_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
#define Adaptive_Cruise_Cont_IN_ACC_OFF ((uint8_T)1U)
#define Adaptive_Cruise_Contr_IN_ACC_ON ((uint8_T)2U)
#define Adaptive_Cruise__IN_ACC_STANDBY ((uint8_T)3U)
#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)
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
uint8_T Acceleration_Mode; /* '<S2>/Adaptive_Cruise_Control' */
uint8_T DriveVehicle_Speed; /* '<S3>/Add' */
uint8_T LeadVehicle_Detected; /* '<S3>/Signal Conversion' */
uint8_T LeadVehicle_Speed; /* '<S4>/Add' */
/* Block states (default storage) */
DW_Adaptive_Cruise_Control_T Adaptive_Cruise_Control_DW;
/* Real-time model */
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_;
/* Forward declaration for local functions */
static void Adaptive_Cruise_Control_ACC_ON(void);
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;
}
/* Function for Chart: '<S2>/Adaptive_Cruise_Control' */
static void Adaptive_Cruise_Control_ACC_ON(void)
{
int32_T tmp;
int32_T tmp_0;
uint8_T tmp_1;
uint8_T tmp_2;
/* Inport: '<Root>/SetSwitch' incorporates:
* Inport: '<Root>/CruiseSwitch'
*/
if (!SetSwitch) {
Adaptive_Cruise_Control_DW.is_ACC_ON = Adaptive_Cru_IN_NO_ACTIVE_CHILD;
Adaptive_Cruise_Control_DW.is_c3_Adaptive_Cruise_Control =
Adaptive_Cruise__IN_ACC_STANDBY;
Acceleration_Mode = 1U;
} else if (!CruiseSwitch) {
Adaptive_Cruise_Control_DW.is_ACC_ON = Adaptive_Cru_IN_NO_ACTIVE_CHILD;
Adaptive_Cruise_Control_DW.is_c3_Adaptive_Cruise_Control =
Adaptive_Cruise_Cont_IN_ACC_OFF;
Acceleration_Mode = 0U;
} else {
switch (Adaptive_Cruise_Control_DW.is_ACC_ON) {
case IN_LeadVehicle_Detected_Follow:
switch (LeadVehicle_Detected) {
case 0:
Adaptive_Cruise_Control_DW.is_ACC_ON = Ada_IN_LeadVehicle_Not_Detected;
break;
case 1:
Adaptive_Cruise_Control_DW.is_ACC_ON = IN_LeadVehicle_Speed_lessthan_S;
break;
}
break;
case IN_LeadVehicle_Detected_Resume:
/* Inport: '<Root>/Set_Speed' incorporates:
* Inport: '<Root>/Set_Gap'
* Inport: '<Root>/Time_Gap'
*/
if ((DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >= Set_Speed) &&
(Time_Gap >= Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON = IN_LeadVehicle_Detected_Follow;
} else if (LeadVehicle_Detected == 0) {
Adaptive_Cruise_Control_DW.is_ACC_ON = IN_LeadVehicle_Not_Detected_Res;
} else {
if ((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
DriveVehicle_Speed) && (Time_Gap >= Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON = IN_LeadVehicle_Speed_equal_Set_;
}
}
break;
case Ada_IN_LeadVehicle_Not_Detected:
/* Inport: '<Root>/Set_Speed' incorporates:
* Inport: '<Root>/Set_Gap'
* Inport: '<Root>/Time_Gap'
*/
if ((LeadVehicle_Detected == 1) && (DriveVehicle_Speed == Set_Speed) &&
(LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON = IN_LeadVehicle_Detected_Follow;
} else {
if (((LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed)) ||
(Time_Gap < Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON = IN_LeadVehicle_Speed_lessthan_S;
}
}
break;
case IN_LeadVehicle_Not_Detected_Res:
break;
case IN_LeadVehicle_Speed_equal_Set_:
/* Inport: '<Root>/Set_Speed' incorporates:
* Inport: '<Root>/Set_Gap'
* Inport: '<Root>/Time_Gap'
*/
if ((LeadVehicle_Detected == 0) || (DriveVehicle_Speed <= Set_Speed)) {
Adaptive_Cruise_Control_DW.is_ACC_ON = IN_LeadVehicle_Not_Detected_Res;
} else if (((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
DriveVehicle_Speed)) || (Time_Gap >= Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON = IN_LeadVehicle_Detected_Resume;
} 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 = IN_LeadVehicle_Speed_lessthan_S;
}
}
break;
default:
/* Inport: '<Root>/Set_Speed' */
/* case IN_LeadVehicle_Speed_lessthan_Set_Speed: */
if ((LeadVehicle_Detected == 0) && (DriveVehicle_Speed == Set_Speed)) {
Adaptive_Cruise_Control_DW.is_ACC_ON = Ada_IN_LeadVehicle_Not_Detected;
} else {
tmp = (int32_T)rt_roundd_snf((real_T)LeadVehicle_Speed * 1.25);
/* Inport: '<Root>/Set_Gap' */
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;
}
/* Inport: '<Root>/Time_Gap' incorporates:
* Inport: '<Root>/Set_Gap'
*/
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 = IN_LeadVehicle_Speed_equal_Set_;
}
}
break;
}
}
/* End of Inport: '<Root>/SetSwitch' */
}
/* Model step function */
void Adaptive_Cruise_Control_step(void)
{
/* Sum: '<S4>/Add' incorporates:
* Inport: '<Root>/CameraInput_LeadVehicle'
* Inport: '<Root>/RadarInput_LeadVehicle'
*/
LeadVehicle_Speed = (uint8_T)((uint32_T)CameraInput_LeadVehicle +
RadarInput_LeadVehicle);
/* Sum: '<S3>/Add' incorporates:
* Inport: '<Root>/CameraInput_DriveVehicle'
* Inport: '<Root>/RadarInput_DriveVehicle'
* UnitDelay: '<S1>/Unit Delay'
*/
DriveVehicle_Speed = (uint8_T)((uint32_T)(uint8_T)((uint32_T)
CameraInput_DriveVehicle + Adaptive_Cruise_Control_DW.UnitDelay_DSTATE) +
RadarInput_DriveVehicle);
/* SignalConversion: '<S3>/Signal Conversion' incorporates:
* Inport: '<Root>/RadarInput_DriveVehicle'
*/
LeadVehicle_Detected = RadarInput_DriveVehicle;
/* Chart: '<S2>/Adaptive_Cruise_Control' incorporates:
* Inport: '<Root>/CruiseSwitch'
* Inport: '<Root>/SetSwitch'
*/
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_Cont_IN_ACC_OFF;
Acceleration_Mode = 0U;
} else {
switch (Adaptive_Cruise_Control_DW.is_c3_Adaptive_Cruise_Control) {
case Adaptive_Cruise_Cont_IN_ACC_OFF:
Acceleration_Mode = 0U;
if (CruiseSwitch) {
Adaptive_Cruise_Control_DW.is_c3_Adaptive_Cruise_Control =
Adaptive_Cruise__IN_ACC_STANDBY;
Acceleration_Mode = 1U;
}
break;
case Adaptive_Cruise_Contr_IN_ACC_ON:
Adaptive_Cruise_Control_ACC_ON();
break;
default:
/* case IN_ACC_STANDBY: */
Acceleration_Mode = 1U;
if (!CruiseSwitch) {
Adaptive_Cruise_Control_DW.is_c3_Adaptive_Cruise_Control =
Adaptive_Cruise_Cont_IN_ACC_OFF;
Acceleration_Mode = 0U;
} else {
if (SetSwitch) {
Adaptive_Cruise_Control_DW.is_c3_Adaptive_Cruise_Control =
Adaptive_Cruise_Contr_IN_ACC_ON;
Adaptive_Cruise_Control_DW.is_ACC_ON = IN_LeadVehicle_Detected_Follow;
}
}
break;
}
}
/* End of Chart: '<S2>/Adaptive_Cruise_Control' */
/* Update for UnitDelay: '<S1>/Unit Delay' */
Adaptive_Cruise_Control_DW.UnitDelay_DSTATE = Acceleration_Mode;
}
/* 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]
*/
Conclusion: Hence created a model for the Adaptive Cruise Control for the given requiremnets by following the MAB standards and also create a SLDD file for inputs and output defining, changed the configuration parameters as per the requirement, Model Advisor checks are done and also the Code generation for the created model is performed.
GoogleLink: https://drive.google.com/drive/folders/1pZaVipfXyiDvfGWpVRg4ZqUUpCPklE03?usp=sharing