All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
P r o j e c t : 2 A d a p t i v e C r u i s e C o n t r o l [ ACC ] ◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉- General Overview: Adaptive Cruise Control Feature for passenger cars allows the host vehicle…
Jayant chikankar
updated on 01 Jul 2022
P r o j e c t : 2
A d a p t i v e C r u i s e C o n t r o l [ ACC ]
◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-◎-◉-
General Overview:
Aim : To develope a Adaptive Cruise Control feature as per the Requirement Document using MATLAB Simulink .
Objective of Main Project:
Instructions :
1 . 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.
2 . Choose sample time for all signals as 0.01s
SLDD CREATION :
The SLDD data files are related to the MATLAB/Simulink. Mathworks Simulink is a multidomain simulation and Model- Based Design for dynamic systems. The SLDD file stores some kind of data used by MATLAB. The following procedure shows how to create and add data to the SLDD file.
After clicking on the Link to Data Dictionary, the following popup window will appears which ask us about data dictionary. If already created and to open SLDD, click on browse option and then select the respective file then click on ok. Here we are creating the new SLDD file so, Click on New and then save with a name. After saving the new SLDD file, uncheck the enable model access to base workspace because as it is new file there is no data to add workspace. If it is already created one then we can click on enable model access to base workspace.
After saving the file the above popup window will closes.
• To open the SLDD file go to the Modeling section and then select Model explorer. Which is showing in the following figure.
If we see at the top left side of the window, there are few option like file, edit, view, tools, add and help. If we click on add button it will show some options as shown in the following figure.
From the options we can select our variable according to its nature.
• If it is a signal then will select simulink signal if it is constant will select simulink parameter like this.
Now enter all signals and parameters according to the given signals and calibration data. To avoid the errors just copy paste the given signal/calibration name.
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 |
- |
- |
After designing the SLDD file, right click on the SLDD form here it is saved as Adaptive_Cruise_Control.sldd . Right click on it and save changes.
• After saving the data we can close the model explorer window and we can start modelling.
Simulink Model Of ACC :
The modeling can be done according to the given requirements. So as we have three given requirements, we are taking a main subsystem first and naming it as Adaptive_Cruise_Control.
Added a subsystem to the empty simulink model. And named it as Adaptive_Cruise_Control.
• Taking its inports and outports according to the given data.
After making a subsystem, double click on it to model the given requirements. The following figure shows the three subsystems under the Adaptive_Cruise_Control subsystem.
These three subsystems are named as Lead_Vehicle, Drive_Vehicle and Algorithum.
The inports and outports are considered according to the given data.
• Now will see how these subsystems are modeled.
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.
The signal names and calibration values are copy pasted to avoide the errors. Because we have taken exact values in SLDD form so to match them again i have did the same. All the ports and blocks are named according to the requirement. To add the given inputs we have taken an Add block.
The following figure shows the model under requirement subsystem.
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)]<="" em=""></set_speed)>
The overall state diagram with their transitions and conditions as per the given requirements is shown in the following figure.
RESOLVING & PROPAGATING:
By resolving and propagating the signals we can migrate design attributes from existing simulink signal objects into the model by using block parameters and signal properties here in the model explorer we have designed then attributes in SLDD form. To force signal resolution for a signal in a MATLAB Function block, follow these steps:
• In the Simulink model, right-click the signal line connected to the respective input or output that you want to resolve and select Properties from the context menu.
• In the Signal Properties dialog, enter a name for the signal that corresponds to the signal object.
The following figure shows the process of signal Resolving. As said right click on signal go to properties then the following procedure should follow. Give exact same as the input or output we have used and click on resolve to simulink object. Then a symbol with name shows at the signal line.
After clicking on the properties a window will appears as follows, where you have to give name and tick the resolving option .
• Repeat the same procedure to al the signals which are to be resolved.
To propagate the signal, right click on it then select properties. And tick the option show propagated signals. Which is shown in the following figure.
or
Double click on signal and type '«»' then click on enter button in the keyboard. Then it will appears as shown below.
Once the signal is resolved then no need to resolve again and again just propagate the signal from its originating place. After making all siganls resolved and propagated the Adaptive_Cruise _Control subsystem is shown as below.
• The two inputs are resolved at input side. The output will be resolved at its intial condition then it will propagate till final output.
The three subsystems are shown below after resolving and propagation of signals.
• As the inputs are already resolved they are propagated to the subsystems. As outputs are resolved inside subsystem they are propagated to outside of subsystems.
The simulink model under the Lead_Vehicle subsystem after resolving and propagating the signals. As it is the origin place for the output here the output is resolved and the inputs are propagated from outside of the subsystem as shown in the following figure.
The simulink model under the Cruise _Vehicle subsystem after resolving and propagating the signals. As it is the origin place for the output here the output is resolved and the inputs are propagated from outside of the subsystem as shown in the followig figure.
The simulink model under the ACC _Algorithum subsystem after propagating the signals. All the inputs are propagated from outside of the subsystem as shown in the following figure.
TAGGING:
To perform Tagging first we have to create a word file with all details regarding about the model we are creating. Not only a word file we can also take excel sheet or MATLAB file etc, here we are taking word file. Tagging enables us to view the procedure which is used to build the model or to know more details about the designed model. To tag this given requirement blocks the following procedure has been followed.
In the above figure it show the selection of word, now to tag this to the subsystem:
Now will be able to see the tagging. Repeat same procedure like right click on subsystem go to requirements and from the options, the top 1. represents the word which is tagged to the subsystem.
• To know about the subsytem building or any other details which are written in the word file, click on that Ist option it will take you to the word file requirement section.
SOLVER SETTINGS:
Solver settings are important to simulate the model. To open the solver setings, go to the Modeling section which is at the top of simulink window. And select the Model settings under the modeling section. Which is shown in the following figure.
After clicking on model settings the following window will appears. The window presents the configuration of the parameters in our simulink mode.
• In the configuration window, click on solver to model the solver parameters.
• Now change the type to Fixed-step, Solver to discrete (no continuous states) and take sample time as 0.01sec.
Then click Ok.
This settings are shown in the following figure.
In the same configuration window there another settings to model, which is Code generation. Click on code generation, Choose the system targer file as ert.lc (Embedded coder) by clicking on the browse option.
• Then click on Ok and close the window.
As per the objective of our model, we have to enable "Support Floating Numbers" under Code Generation settings. Which is shown in the following figure.
MAB GUIDEINES:
The MAB (MathWorks Advisory Board) Guidelines are a set of modeling guidelines developed by an independent industry working group for the usage of MATLAB, Simulink, Stateflow and Embedded Coder. The guidelines are the culmination of years of engineering expertise and best practices for developing, maintaining and documenting control algorithm models used in the development of production software.
• To perform the MAB guidelines test on our simulink model, go to modeling section and select Model Advisor which is at the top left corner of the window.
• You can use the Model Advisor to verify compliance of your model with the MathWorks Advisory Board (MAB) quidelines.
By clicking on the Model Advisor, a window will ask us to confirmation if we click on Ok then it will opens a window which is shown in the following figure.
In the Model advisor there are number of guidelines, among them will select only Modeling Standards fro MAB.
• If we expand the section will be able to see which are tested under the MAB guidelins. If we again expand there will be many sub sections in each section.
After selecting MAB guidelines, click on Run Selected checks.
• Then it asks again for confirmation, click on continue. Then the testing will begins. It takes time to perform the guidelines test.
After clicking Generate report in the above window, a popup window will appears as shown in the following figure.
• It shows the directory, at where the report is going to save. It will save in the same folder of our simulink model.
• Give a name to the report.
Then click on OK.
After clicking on Ok. It will save in the folder and opens as shown in the followig diagram.
• The report shows all the checks performed under MAB guidelines.
C CODING:
Now we are converting all our model in terms of C Code. To create C code of our simulink model, follow the procedure as explained below.
• Go to the Apps section which is at top of the window.
• Under Apps section, click on Embedder coder which is shown in the following figure.
After clicking on EMbedded codel option, other window will creates as C CODE, which is shown in the following figure.
• Go to the C Code section, and click on Build option to build the code.
After clicking on Build it will generate the C Code of our simulink as shown inn the following figure.
• The C code shows all the data of our simulink model. The C code file is also saved in the same folder of our simulink model.
Generated code :
/*
* File: accproject_by_jatin.c
*
* Code generated for Simulink model 'accproject_by_jatin'.
*
* Model version : 1.26
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Tue May 17 22:29:56 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "accproject_by_jatin.h"
#include "accproject_by_jatin_private.h"
/* Named constants for Chart: '/ACCLogicChart' */
#define IN_LeadVehicle_Detected_Resume ((uint8_T)1U)
#define IN_LeadVehicle_Detected_follow ((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 acc_IN_LeadVehicle_Not_Detected ((uint8_T)3U)
#define accproject__IN_ACC_STANDBY_MODE ((uint8_T)3U)
#define accproject_b_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
#define accproject_by_j_IN_ACC_OFF_MODE ((uint8_T)1U)
#define accproject_by_ja_IN_ACC_ON_MODE ((uint8_T)2U)
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
uint8_T Acceleration_Mode; /* '/Unit Delay' */
uint8_T DriveVehicle_Speed; /* '/Add' */
uint8_T LeadVehicle_Detected; /* '/SignalConversion' */
uint8_T LeadVehicle_Speed; /* '/Add' */
/* Block states (default storage) */
DW_accproject_by_jatin_T accproject_by_jatin_DW;
/* External outputs (root outports fed by signals with default storage) */
ExtY_accproject_by_jatin_T accproject_by_jatin_Y;
/* Real-time model */
static RT_MODEL_accproject_by_jatin_T accproject_by_jatin_M_;
RT_MODEL_accproject_by_jatin_T *const accproject_by_jatin_M =
&accproject_by_jatin_M_;
real_T rt_roundd(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 = 0.0;
} else {
y = ceil(u - 0.5);
}
} else {
y = u;
}
return y;
}
/* Model step function */
void accproject_by_jatin_step(void)
{
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 = accproject_by_jatin_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 + Acceleration_Mode) + RadarInput_DriveVehicle);
/* SignalConversion: '/SignalConversion' incorporates:
* Inport: '/RadarInput_DriveVehicle'
*/
LeadVehicle_Detected = RadarInput_DriveVehicle;
/* Chart: '/ACCLogicChart' incorporates:
* Inport: '/CruiseSwitch'
* Inport: '/SetSwitch'
* Inport: '/Set_Gap'
* Inport: '/Set_Speed'
* Inport: '/Time_Gap'
* UnitDelay: '/Unit Delay'
*/
if (accproject_by_jatin_DW.is_active_c3_accproject_by_jati == 0U) {
accproject_by_jatin_DW.is_active_c3_accproject_by_jati = 1U;
accproject_by_jatin_DW.is_c3_accproject_by_jatin =
accproject_by_j_IN_ACC_OFF_MODE;
accproject_by_jatin_Y.Acceleration_Mode_h = 0U;
} else {
switch (accproject_by_jatin_DW.is_c3_accproject_by_jatin) {
case accproject_by_j_IN_ACC_OFF_MODE:
accproject_by_jatin_Y.Acceleration_Mode_h = 0U;
if (CruiseSwitch) {
accproject_by_jatin_DW.is_c3_accproject_by_jatin =
accproject__IN_ACC_STANDBY_MODE;
accproject_by_jatin_Y.Acceleration_Mode_h = 1U;
}
break;
case accproject_by_ja_IN_ACC_ON_MODE:
if (!CruiseSwitch) {
accproject_by_jatin_DW.is_ACC_ON_MODE = accproject_b_IN_NO_ACTIVE_CHILD;
accproject_by_jatin_DW.is_c3_accproject_by_jatin =
accproject_by_j_IN_ACC_OFF_MODE;
accproject_by_jatin_Y.Acceleration_Mode_h = 0U;
} else if (!SetSwitch) {
accproject_by_jatin_DW.is_ACC_ON_MODE = accproject_b_IN_NO_ACTIVE_CHILD;
accproject_by_jatin_DW.is_c3_accproject_by_jatin =
accproject__IN_ACC_STANDBY_MODE;
accproject_by_jatin_Y.Acceleration_Mode_h = 1U;
} else {
switch (accproject_by_jatin_DW.is_ACC_ON_MODE) {
case IN_LeadVehicle_Detected_Resume:
if (LeadVehicle_Detected == 0) {
accproject_by_jatin_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Not_Detected_Res;
accproject_by_jatin_Y.Acceleration_Mode_h = 1U;
} else if ((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
DriveVehicle_Speed) && (Time_Gap >= Set_Gap)) {
accproject_by_jatin_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_equal_Set_;
accproject_by_jatin_Y.Acceleration_Mode_h = 5U;
} else {
accproject_by_jatin_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_follow;
accproject_by_jatin_Y.Acceleration_Mode_h = 2U;
}
break;
case IN_LeadVehicle_Detected_follow:
accproject_by_jatin_Y.Acceleration_Mode_h = 2U;
if (LeadVehicle_Detected == 0) {
accproject_by_jatin_DW.is_ACC_ON_MODE =
acc_IN_LeadVehicle_Not_Detected;
accproject_by_jatin_Y.Acceleration_Mode_h = 1U;
} else if (((LeadVehicle_Detected == 1) && (LeadVehicle_Speed <
Set_Speed)) || (Time_Gap < Set_Gap)) {
accproject_by_jatin_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
accproject_by_jatin_Y.Acceleration_Mode_h = 4U;
}
break;
case acc_IN_LeadVehicle_Not_Detected:
accproject_by_jatin_Y.Acceleration_Mode_h = 1U;
if ((LeadVehicle_Detected == 1) && (DriveVehicle_Speed == Set_Speed) &&
(LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)) {
accproject_by_jatin_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_follow;
accproject_by_jatin_Y.Acceleration_Mode_h = 2U;
} else if (((LeadVehicle_Detected == 1) && (LeadVehicle_Speed <
Set_Speed)) || (Time_Gap < Set_Gap)) {
accproject_by_jatin_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
accproject_by_jatin_Y.Acceleration_Mode_h = 4U;
}
break;
case IN_LeadVehicle_Not_Detected_Res:
accproject_by_jatin_Y.Acceleration_Mode_h = 1U;
break;
case IN_LeadVehicle_Speed_equal_Set_:
accproject_by_jatin_Y.Acceleration_Mode_h = 5U;
if (((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
DriveVehicle_Speed)) || (Time_Gap >= Set_Gap)) {
accproject_by_jatin_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_Resume;
accproject_by_jatin_Y.Acceleration_Mode_h = 3U;
} else if (((LeadVehicle_Speed < Set_Speed) && (LeadVehicle_Speed <
DriveVehicle_Speed)) || ((int32_T)rt_roundd(0.75 *
(real_T)Set_Gap) == Time_Gap)) {
accproject_by_jatin_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
accproject_by_jatin_Y.Acceleration_Mode_h = 4U;
} else if ((LeadVehicle_Detected == 0) || (DriveVehicle_Speed <=
Set_Speed)) {
accproject_by_jatin_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Not_Detected_Res;
accproject_by_jatin_Y.Acceleration_Mode_h = 1U;
}
break;
default:
/* case IN_LeadVehicle_Speed_lessthan_Set_Speed: */
accproject_by_jatin_Y.Acceleration_Mode_h = 4U;
if ((LeadVehicle_Detected == 0) && (DriveVehicle_Speed == Set_Speed))
{
accproject_by_jatin_DW.is_ACC_ON_MODE =
acc_IN_LeadVehicle_Not_Detected;
accproject_by_jatin_Y.Acceleration_Mode_h = 1U;
} else {
tmp = (int32_T)rt_roundd((real_T)LeadVehicle_Speed * 1.25);
tmp_0 = (int32_T)rt_roundd(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((real_T)
LeadVehicle_Speed * 0.75) <= DriveVehicle_Speed) &&
(DriveVehicle_Speed < Set_Speed) && (Time_Gap <= tmp_2) &&
(Time_Gap >= (int32_T)rt_roundd(0.75 * (real_T)Set_Gap))) {
accproject_by_jatin_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_equal_Set_;
accproject_by_jatin_Y.Acceleration_Mode_h = 5U;
}
}
break;
}
}
break;
default:
/* case IN_ACC_STANDBY_MODE: */
accproject_by_jatin_Y.Acceleration_Mode_h = 1U;
if (SetSwitch) {
accproject_by_jatin_DW.is_c3_accproject_by_jatin =
accproject_by_ja_IN_ACC_ON_MODE;
accproject_by_jatin_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_follow;
accproject_by_jatin_Y.Acceleration_Mode_h = 2U;
} else if (!CruiseSwitch) {
accproject_by_jatin_DW.is_c3_accproject_by_jatin =
accproject_by_j_IN_ACC_OFF_MODE;
accproject_by_jatin_Y.Acceleration_Mode_h = 0U;
}
break;
}
}
/* End of Chart: '/ACCLogicChart' */
}
/* Model initialize function */
void accproject_by_jatin_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void accproject_by_jatin_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
The C Code will be saved in the same folder of our simulink model.
Results:
After implementing the ACC model run the simulation. If the model is running successfully without any errors then the Adaptive Cruise Control is works as per the requirement.
• The model is running successfully without any error.
CONCLUSION:
The Adaptive Cruise Control is modeled as per the given requirements, all the signals and calibrated values are defined in the Simulink Data Dictionary (SLDD). All input and output signals are resolved and propagated. The respective subsystems are Tagged according to their requirement. Model Advisory check is done with MAB guidelines and there is 0 fail conditions. Since there are no errors in Model Advisory report C Code has been generated by using Embedded coder.
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 - Development of TFT Cluster Speedometer Software Component
Q.Develop the Simulink model based on the given requirements and also create SLDD file and link the same to the model. Perform the complete V and V workflow for the obtained model Development of TFT Cluster Speedometer Software Component Cluster Instrument receives the signals from other ECU via CAN bus interface.…
03 Dec 2022 08:49 AM IST
Project 1 - Wiper control system and Vehicle speed calculation for ABS using Wheel Speed sensor
Wiper control system Develop Simulink/state flow model for wiper control system based on the given conditions. Description of Challenge: If the density of the rain is low, then wiper rotates with low speed & the output signal should be 100rpm If the density of the rain is medium, then wiper rotates with medium speed…
03 Dec 2022 08:38 AM IST
Week-11 Challenge: Braking
Aim #1 : For a defined driving cycle, calculate the energy required for braking. Theory : For a defined driving cycle, calculate the energy required for braking. At first, the drive cycle is determined in a Table and a plot is made. Using the plot, the values from the braking regions of the vehicle are…
10 Sep 2022 05:24 PM IST
Week-7 Challenge: DC Motor Control
Aim : 1. A. Explain a MATLAB demo model named ‘Speed control of a DC motor using BJT H-bridge’. Comment on the armature current shoot-up from the scope results. Refer to the help section of ‘The Four-Quadrant Chopper DC Drive (DC7) block’. Compare it with the H-bridge model. BAsic discussion…
06 Sep 2022 08:53 AM IST
Related Courses
127 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.