Adaptive Cruise Control - ACC
AIM:
- Developing Adaptive Cruise Control feature as per the Requirement Document using MATLAB Simulink
- Follow all the MBD related processes: Requirement Tagging & Traceability, SLDD creation, Configuration Parameter changes, Model Advisor check & Code Generation
- In Configuration Parameters: enable "Support Floating Numbers" under Code Generation settings
- Use Embedded Coder to generate the code
- If 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
- Choose sample time for all signals as 0.01s
OBJECTIVES:
Requirement 1– Lead Vehicle:
- Lead Vehicle is a vehicle which is driving in the road ahead of our drive vehicle. Two input signals (Signal Name: 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.
- We can simply add both the radar & camera inputs & the corresponding output is read as Speed profile output (Signal Name: 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 & this is the vehicle which has ACC algorithm in it.
- Like the Lead Vehicle, Drive Vehicle algorithm also has 2 input signals (Signal Name: CameraInput_DriveVehicle, RadarInput_DriveVehicle) & one signal coming as an Input to this subsystem (Signal Name: Acceleration_Mode) – three inputs into this requirement in total.
- Like the above requirement, sensor fusion techniques will also be deployed here, for complexity reasons we are ignoring them.
- Two output signals come from this subsystem (Signal Name: DriveVehicle_Speed & LeadVehicle_Detected).
- Signal DriveVehicle_Speed is summation of three input signals mentioned above & LeadVehicle_Detected is renamed from Input Signal RadarInput_DriveVehicle by mere use of Signal Conversion block.
Requirement 3 – Adaptive 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 (Signal Name: Time_Gap, Set_Speed, Set_Gap, CruiseSwitch, SetSwitch).
- Also, the output signals (Signal Name: DriveVehicle_Speed & LeadVehicle_Detected) from requirement-2 is fed back as an input signal into this state machine block.
- Additionally, output signal (Signal Name: 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 (Signal Name: Acceleration_Mode) which governs the vehicular speed of the drive vehicle which automatically adjusts its speed & velocity to match the lead vehicle.
Requirement 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
- LeadVehicle_Speed_equal_Set_Speed
Requirement 3c (i) – LeadVehicle_Detected_Follow (ACC ON MODE):
- This is the default sub state 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)]
DEVELOPING ADAPTIVE CRUISE CONTROL FEATURE AS PER THE REQUIREMENT DOCUMENT USING MATLAB SIMULINK

A general overview of the vehicle cruise control is,
- 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
Following were the procedure to create a 'Adaptive Cruise Control (ACC)' test environment,
STEP 1 - Open Modelling >>> Model settings. In configuration parameters choose 'Solver' and select solver selection as Fixed-step type, solver as discrete (no continuous states) and in solver details of sample time as be 0.01s

STEP 2 - Choose code generation, In system target file browse "ert.tlc Embedded Coder" and click OK. This makes to adapt all the configuration parameters as per the testing environment

STEP 3 - Now select Modelling tab >>> Link to Data Dictionary. In that pop-up window, Under the 'external data' tab, click New option to create the new data dictionary, name it and click OK

STEP 4 - Open Modelling >>> Model Explorer, choose created the 'VCC_DD' (.sldd) file as below. And click the marked two simulink parameter and signal options to add the inputs to the data dictionary file. Then make a right click on the created file and select save changes

STEP 5 - Now we have to create the subsystem of 'Adaptiveve_Cruise_Control_ACC' with nine inputs and one output. Inside of this subsystem block we going to construct the given three requirements

STEP 6 - Inside the main subsystem, create 2 subsystems and 1 stateflow chart, then name it as 'Lead_Vehicle', 'Drive_Vehicle' and 'Adaptive_Cruise_Control_Algorithm'
Lead Vehicle:
- First connect the two inputs of 'CameraInput_LeadVehicle' and 'RadarInput_LeadVehicle' with the add block for the sum process
- Then get an output of the speed of lead vehicle and connect with the out port as shown below

Drive Vehicle:
- Connect the two inputs of 'CameraInput_DriveVehicle' and 'RadarInput_DriveVehicle' with the add block for the sum process
- Connect the output of 1st add block and 'Acceleration_Mode' with the another add block for the final sum process
- Then get an two outputs were one is speed of drive vehicle which is connect with the out port
- Another one is from the input signal of 'RadarInput_DriveVehicle' by the signal conversion block as shown below

Adaptive Cruise Control Algorithm:
- As per the given requirements, the ACC algorithm were works by three operational modes which are OFF Mode, STANDBY Mode & ON Mode
- This particular requirement has to be implemented as state machine logic with the given condition in simulink
- Simple understanding about this was when a cruise turn ON the ACC, whatever the speed of driving vehicle will be get reduced and maintain it's speed level as per the lead vehicle where going in front of the user vehicle
- By the speed of lead vehicle, the user vehicle wil change it's acceleration mode with the help of the given inputs (time gap, set gap, set speed, lead vehicle detection)

STEP 7 - Now open Modelling >>> Symbol Pane. This is used to add or remove and order the inputs and outputs as per the port numbers were shown below

STEP 8 - Follow the following points:
From the main subsystem of ACC,
- Connect the two inputs of 'CameraInput_LeadVehicle' and 'RadarInput_LeadVehicle' signal to the 'Lead_Vehicle' subsystem
- Connect the two inputs of 'CameraInput_DriveVehicle' and 'RadarInput_DriveVehicle' signal to the 'Drive_Vehicle' subsystem
- Connect the five inputs of 'Set_Gap','Time_Gap','Set_Speed','CruiseSwitch', and 'SetSwitch' to the 'Adaptive_Cruise_Control_Algorithm' stateflow chart
- Connect the 'LeadVehicle_Speed' local signal of Lead_Vehicle's output with the 'Adaptive_Cruise_Control_Algorithm' as inputs
- Connect the 'DriveVehicle_Speed' and 'LeadVehicle_Detected' local signals of Drive_Vehicle's outputs with the 'Adaptive_Cruise_Control_Algorithm' as inputs
- Connect the output of ACC ('Acceleration_Mode') with the unit delay block(for sample and hold with one sample period delay) and pass to the Drive_Vehicle subsystem's existing input and make a 'Acceleration_Mode' signal as final output

STEP 9 - Now Tagging. Tag the required documents of 'Lead_Vehicle', 'Drive_Vehicle' and 'Adaptive_Cruise_Control_Algorithm' to their corresponding subsystems were shown below
- Create the word document with the given information
- Select the appropriate word (Requirement 1– Lead Vehicle) from the created document

- After the linking process, we can cross check as it linked properly or not. So again right click on the subsystem and select Requirements >>> 1. "Requirement 1– Lead Vehicle"

- Now you can see the targeted word from the document as below

- Just follow the same steps to tag the description for the following subsystem and stateflow chart from the word document
1. 'Requirement 2 – Drive Vehicle' subsystem:

2. 'Requirement 3 – Adaptive_Cruise_Control_Algorithm' stateflow chart:

STEP 10 - Resolve & Propagate. For resolve(requires that the resolved signal have the same name as the subsystem output or local data). For Propagate (to track a signal label through one block or many blocks)
Follow these steps for resolve:
- Right-click the signal line connected to the subsystem that you want to resolve and select properties from the context menu
- In the signal properties dialog box, enter a name for the signal that corresponds to the signal object
- Enable the signal name must resolve to Simulink signal object check box. Click apply and OK

Follow these steps for propagate:
- Right-click the signal for which you want to display a propagated signal label and select properties
- In the signal properties dialog box, enable propagated signals check box. Click apply and OK

- Following will shows how the model will looks like after the signals resolve and propagate were done,
Adaptive Cruise Control ACC Subsystem:

Inside the Main subsystem:

Lead Vehicle Subsystem:

Drive Vehicle Subsystem:

STEP 11 - Now have to change the main subsystem's parameter, so right click on the created subsystem and select 'block parameters (subsystem)'

STEP 12 - In this block parameters, enable the 'Treat as atomic unit', this causes simulink to treat the subsystem as a unit when determining block execution order. When it comes time to execute the subsystem, simulink executes all blocks within the subsystem before executing any other block at the same level as the subsystem block
For information,
- If this option is not selected, simulink treats all blocks in the subsystem as being at the same level in the model hierarchy as the subsystem when determining block execution order
- This can cause execution of blocks within the subsystem to be interleaved with execution of blocks outside the subsystem

STEP 13 - Code Generation. Open the APPS tab and choose the 'Embedded Coder' option to go for the code generation as shown below

STEP 14 - By choosing the 'Embedded Coder', the 'C code' tab will appears. In that tab, check once the 'code for' section for ensuring we're doing the codes for right subsystem and choose the 'Build' option to generate the codes. By this process, after the few moments the "C code" will be generated as shown below

STEP 15 - After the code generation, the 'main_project_VCC_ert_rtw' folder will auto generated. This folder holds the supporting files of Vehicle Direction Determination Subsystem' like codes (.c), MAT (.mat), header (.h) files, etc.,

- Following will shows the codes were hold by the C source file of 'main_project_VCC.c',
/*
* File: main_project_VCC.c
*
* Code generated for Simulink model 'main_project_VCC'.
*
* Model version : 1.30
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Sat May 28 15:29:58 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "main_project_VCC.h"
#include "main_project_VCC_private.h"
/* Named constants for Chart: '<S1>/Adaptive_Cruise_Control_Algorithm' */
#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 mai_IN_LeadVehicle_Not_Detected ((uint8_T)3U)
#define main_projec_IN_ACC_STANDBY_MODE ((uint8_T)3U)
#define main_project_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
#define main_project_VCC_IN_ACC_ON_MODE ((uint8_T)2U)
#define main_project_VC_IN_ACC_OFF_MODE ((uint8_T)1U)
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
uint8_T Acceleration_Mode; /* '<S1>/Unit Delay' */
uint8_T DriveVehicle_Speed; /* '<S3>/Add1' */
uint8_T LeadVehicle_Detected; /* '<S3>/Signal Conversion' */
uint8_T LeadVehicle_Speed; /* '<S4>/Add' */
/* Block states (default storage) */
DW_main_project_VCC_T main_project_VCC_DW;
/* External outputs (root outports fed by signals with default storage) */
ExtY_main_project_VCC_T main_project_VCC_Y;
/* Real-time model */
static RT_MODEL_main_project_VCC_T main_project_VCC_M_;
RT_MODEL_main_project_VCC_T *const main_project_VCC_M = &main_project_VCC_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 main_project_VCC_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_ACC' */
/* Sum: '<S4>/Add' incorporates:
* Inport: '<Root>/CameraInput_LeadVehicle'
* Inport: '<Root>/RadarInput_LeadVehicle'
*/
LeadVehicle_Speed = (uint8_T)((uint32_T)CameraInput_LeadVehicle +
RadarInput_LeadVehicle);
/* UnitDelay: '<S1>/Unit Delay' */
Acceleration_Mode = main_project_VCC_Y.Acceleration_Mode_j;
/* Sum: '<S3>/Add1' incorporates:
* Inport: '<Root>/CameraInput_DriveVehicle'
* Inport: '<Root>/RadarInput_DriveVehicle'
* Sum: '<S3>/Add'
*/
DriveVehicle_Speed = (uint8_T)((uint32_T)(uint8_T)((uint32_T)
CameraInput_DriveVehicle + RadarInput_DriveVehicle) + Acceleration_Mode);
/* SignalConversion: '<S3>/Signal Conversion' incorporates:
* Inport: '<Root>/RadarInput_DriveVehicle'
*/
LeadVehicle_Detected = RadarInput_DriveVehicle;
/* Chart: '<S1>/Adaptive_Cruise_Control_Algorithm' incorporates:
* Inport: '<Root>/CruiseSwitch'
* Inport: '<Root>/SetSwitch'
* Inport: '<Root>/Set_Gap'
* Inport: '<Root>/Set_Speed'
* Inport: '<Root>/Time_Gap'
* UnitDelay: '<S1>/Unit Delay'
*/
if (main_project_VCC_DW.is_active_c3_main_project_VCC == 0U) {
main_project_VCC_DW.is_active_c3_main_project_VCC = 1U;
main_project_VCC_DW.is_c3_main_project_VCC = main_project_VC_IN_ACC_OFF_MODE;
main_project_VCC_Y.Acceleration_Mode_j = 0U;
} else {
switch (main_project_VCC_DW.is_c3_main_project_VCC) {
case main_project_VC_IN_ACC_OFF_MODE:
main_project_VCC_Y.Acceleration_Mode_j = 0U;
if (CruiseSwitch) {
main_project_VCC_DW.is_c3_main_project_VCC =
main_projec_IN_ACC_STANDBY_MODE;
main_project_VCC_Y.Acceleration_Mode_j = 1U;
}
break;
case main_project_VCC_IN_ACC_ON_MODE:
if (!SetSwitch) {
main_project_VCC_DW.is_ACC_ON_MODE = main_project_IN_NO_ACTIVE_CHILD;
main_project_VCC_DW.is_c3_main_project_VCC =
main_projec_IN_ACC_STANDBY_MODE;
main_project_VCC_Y.Acceleration_Mode_j = 1U;
} else if (!CruiseSwitch) {
main_project_VCC_DW.is_ACC_ON_MODE = main_project_IN_NO_ACTIVE_CHILD;
main_project_VCC_DW.is_c3_main_project_VCC =
main_project_VC_IN_ACC_OFF_MODE;
main_project_VCC_Y.Acceleration_Mode_j = 0U;
} else {
switch (main_project_VCC_DW.is_ACC_ON_MODE) {
case IN_LeadVehicle_Detected_Follow:
main_project_VCC_Y.Acceleration_Mode_j = 2U;
if (((LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed)) ||
(Time_Gap < Set_Gap)) {
main_project_VCC_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_lessthan_S;
main_project_VCC_Y.Acceleration_Mode_j = 4U;
} else if (LeadVehicle_Detected == 0) {
main_project_VCC_DW.is_ACC_ON_MODE = mai_IN_LeadVehicle_Not_Detected;
main_project_VCC_Y.Acceleration_Mode_j = 1U;
}
break;
case IN_LeadVehicle_Detected_Resume:
main_project_VCC_Y.Acceleration_Mode_j = 3U;
if ((DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >=
Set_Speed) && (Time_Gap >= Set_Gap)) {
main_project_VCC_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_Follow;
main_project_VCC_Y.Acceleration_Mode_j = 2U;
} else if (LeadVehicle_Detected == 0) {
main_project_VCC_DW.is_ACC_ON_MODE = IN_LeadVehicle_Not_Detected_Res;
main_project_VCC_Y.Acceleration_Mode_j = 1U;
} else if ((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
DriveVehicle_Speed) && (Time_Gap >= Set_Gap)) {
main_project_VCC_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_equal_Set_;
main_project_VCC_Y.Acceleration_Mode_j = 5U;
}
break;
case mai_IN_LeadVehicle_Not_Detected:
main_project_VCC_Y.Acceleration_Mode_j = 1U;
if ((LeadVehicle_Detected == 1) && (DriveVehicle_Speed == Set_Speed) &&
(LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)) {
main_project_VCC_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_Follow;
main_project_VCC_Y.Acceleration_Mode_j = 2U;
} else if (((LeadVehicle_Detected == 1) && (LeadVehicle_Speed <
Set_Speed)) || (Time_Gap < Set_Gap)) {
main_project_VCC_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_lessthan_S;
main_project_VCC_Y.Acceleration_Mode_j = 4U;
}
break;
case IN_LeadVehicle_Not_Detected_Res:
main_project_VCC_Y.Acceleration_Mode_j = 1U;
break;
case IN_LeadVehicle_Speed_equal_Set_:
main_project_VCC_Y.Acceleration_Mode_j = 5U;
if (((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
DriveVehicle_Speed)) || (Time_Gap >= Set_Gap)) {
main_project_VCC_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_Resume;
main_project_VCC_Y.Acceleration_Mode_j = 3U;
} else if ((LeadVehicle_Detected == 0) || (DriveVehicle_Speed <=
Set_Speed)) {
main_project_VCC_DW.is_ACC_ON_MODE = IN_LeadVehicle_Not_Detected_Res;
main_project_VCC_Y.Acceleration_Mode_j = 1U;
} else if (((LeadVehicle_Speed < Set_Speed) && (LeadVehicle_Speed <
DriveVehicle_Speed)) || ((int32_T)rt_roundd_snf(0.75 *
(real_T)Set_Gap) == Time_Gap)) {
main_project_VCC_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_lessthan_S;
main_project_VCC_Y.Acceleration_Mode_j = 4U;
}
break;
default:
/* case IN_LeadVehicle_Speed_lessthan_Set_Speed: */
main_project_VCC_Y.Acceleration_Mode_j = 4U;
if ((LeadVehicle_Detected == 0) && (DriveVehicle_Speed == Set_Speed))
{
main_project_VCC_DW.is_ACC_ON_MODE = mai_IN_LeadVehicle_Not_Detected;
main_project_VCC_Y.Acceleration_Mode_j = 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))) {
main_project_VCC_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_equal_Set_;
main_project_VCC_Y.Acceleration_Mode_j = 5U;
}
}
break;
}
}
break;
default:
/* case IN_ACC_STANDBY_MODE: */
main_project_VCC_Y.Acceleration_Mode_j = 1U;
if (!CruiseSwitch) {
main_project_VCC_DW.is_c3_main_project_VCC =
main_project_VC_IN_ACC_OFF_MODE;
main_project_VCC_Y.Acceleration_Mode_j = 0U;
} else if (SetSwitch) {
main_project_VCC_DW.is_c3_main_project_VCC =
main_project_VCC_IN_ACC_ON_MODE;
main_project_VCC_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_Follow;
main_project_VCC_Y.Acceleration_Mode_j = 2U;
}
break;
}
}
/* End of Chart: '<S1>/Adaptive_Cruise_Control_Algorithm' */
/* End of Outputs for SubSystem: '<Root>/Adaptive_Cruise_Control_ACC' */
}
/* Model initialize function */
void main_project_VCC_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void main_project_VCC_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
STEP 16 - Model Advisor. Now open the Modelling >>> Model Advisor for MBD compliant changes. In that pop-up window, choose the system have to check and click OK


STEP 17 - Under the 'By Task' option, check 'Modeling Standards for MAB' and click the 'Run Selected Checks' option to starts the complaints checking

STEP 18 - After the check done, the report summary will shows the no.of pass, fail, warning as below,

- Finally generate the report by selecting the 'Generate Report' option and click OK. The report file will saves in the related folder as in HTML format
