Project 2 Adaptive Cruise Control
Objective of Main Project:
- 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
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)]
Configuration Parameter changes:
Set a give data in Configuration Parameters. Change the valuse Solver selection type>> fixed step and solver data change auto to discrete. Solver details sample time 0.01s given data.

Set Code generation block>> Target Selection block >> set system file taget change to ert.tlc Embedded Coder browse the file and click apply and oK.


SLDD creation:
click modeling>>Link to data dictionary creat model Properties block Adaptive_Cruise_Control.sldd creat new file >> click apply and ok.
Model explor>> Adaptive_Cruise_Control.sldd>>design data . Store a given datas and save it datas.


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 |
- |
- |


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


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.















/*
* File: Adaptive_Cruise_Control.c
*
* Code generated for Simulink model 'Adaptive_Cruise_Control'.
*
* Model version : 1.20
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Sun Oct 9 14:36:09 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Adaptive_Cruise_Control.h"
#include "Adaptive_Cruise_Control_private.h"
/* Named constants for Chart: '<S1>/Chart' */
#define Ada_IN_LeadVehicle_Not_Detected ((uint8_T)3U)
#define Adaptive_Cr_IN_ACC_STANDBY_MODE ((uint8_T)3U)
#define Adaptive_Cru_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
#define Adaptive_Cruise_IN_ACC_OFF_MODE ((uint8_T)1U)
#define Adaptive_Cruise__IN_ACC_ON_MODE ((uint8_T)2U)
#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)
/* Block states (default storage) */
DW_Adaptive_Cruise_Control_T Adaptive_Cruise_Control_DW;
/* External inputs (root inport signals with default storage) */
ExtU_Adaptive_Cruise_Control_T Adaptive_Cruise_Control_U;
/* External outputs (root outports fed by signals with default storage) */
ExtY_Adaptive_Cruise_Control_T Adaptive_Cruise_Control_Y;
/* Real-time model */
static RT_MODEL_Adaptive_Cruise_Cont_T Adaptive_Cruise_Control_M_;
RT_MODEL_Adaptive_Cruise_Cont_T *const Adaptive_Cruise_Control_M =
&Adaptive_Cruise_Control_M_;
/* Model step function */
void Adaptive_Cruise_Control_step(void)
{
real_T rtb_Add1;
real_T rtb_Add_l;
/* Outputs for Atomic SubSystem: '<Root>/Adaptive Cruise Control' */
/* Sum: '<S3>/Add1' incorporates:
* Inport: '<Root>/CameraInput_DriveVehicle'
* Inport: '<Root>/RadarInput_DriveVehicle'
* Sum: '<S3>/Add'
* UnitDelay: '<S1>/Unit Delay'
*/
rtb_Add1 = (Adaptive_Cruise_Control_U.CameraInput_DriveVehicle +
Adaptive_Cruise_Control_U.RadarInput_DriveVehicle) +
Adaptive_Cruise_Control_Y.Acceleratio_Mode;
/* Outputs for Atomic SubSystem: '<S1>/Lead Vehicle' */
/* Sum: '<S4>/Add' incorporates:
* Inport: '<Root>/ RadarInput_LeadVehicle'
* Inport: '<Root>/CameraInput_LeadVehicle '
*/
rtb_Add_l = Adaptive_Cruise_Control_U.CameraInput_LeadVehicle +
Adaptive_Cruise_Control_U.RadarInput_LeadVehicle;
/* End of Outputs for SubSystem: '<S1>/Lead Vehicle' */
/* Chart: '<S1>/Chart' incorporates:
* Inport: '<Root>/CruiseSwitch'
* Inport: '<Root>/RadarInput_DriveVehicle'
* Inport: '<Root>/SetSwitch'
* Inport: '<Root>/Set_Gap'
* Inport: '<Root>/Set_Speed'
* Inport: '<Root>/Time_Gap'
* UnitDelay: '<S1>/Unit Delay'
*/
if (Adaptive_Cruise_Control_DW.is_active_c1_Adaptive_Cruise_Co == 0U) {
Adaptive_Cruise_Control_DW.is_active_c1_Adaptive_Cruise_Co = 1U;
Adaptive_Cruise_Control_DW.is_c1_Adaptive_Cruise_Control =
Adaptive_Cruise_IN_ACC_OFF_MODE;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 0.0;
} else {
switch (Adaptive_Cruise_Control_DW.is_c1_Adaptive_Cruise_Control) {
case Adaptive_Cruise_IN_ACC_OFF_MODE:
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 0.0;
if (Adaptive_Cruise_Control_U.CruiseSwitch == 1.0) {
Adaptive_Cruise_Control_DW.is_c1_Adaptive_Cruise_Control =
Adaptive_Cr_IN_ACC_STANDBY_MODE;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 1.0;
}
break;
case Adaptive_Cruise__IN_ACC_ON_MODE:
if (Adaptive_Cruise_Control_U.SetSwitch == 0.0) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
Adaptive_Cru_IN_NO_ACTIVE_CHILD;
Adaptive_Cruise_Control_DW.is_c1_Adaptive_Cruise_Control =
Adaptive_Cr_IN_ACC_STANDBY_MODE;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 1.0;
} else {
switch (Adaptive_Cruise_Control_DW.is_ACC_ON_MODE) {
case IN_LeadVehicle_Detected_Follow:
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 2.0;
if (rtb_Add1 == 0.0) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
Ada_IN_LeadVehicle_Not_Detected;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 1.0;
} else if (((rtb_Add1 == 1.0) && (rtb_Add_l <
Adaptive_Cruise_Control_U.Set_Speed)) ||
(Adaptive_Cruise_Control_U.Time_Gap <
Adaptive_Cruise_Control_U.Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 4.0;
}
break;
case IN_LeadVehicle_Detected_Resume:
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 3.0;
if ((Adaptive_Cruise_Control_U.RadarInput_DriveVehicle ==
Adaptive_Cruise_Control_U.Set_Speed) && (rtb_Add_l >=
Adaptive_Cruise_Control_U.Set_Speed) &&
(Adaptive_Cruise_Control_U.Time_Gap >=
Adaptive_Cruise_Control_U.Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_Follow;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 2.0;
} else if (rtb_Add1 == 0.0) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Not_Detected_Res;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 1.0;
} else if ((Adaptive_Cruise_Control_U.RadarInput_DriveVehicle <
Adaptive_Cruise_Control_U.Set_Speed) && (rtb_Add_l >
Adaptive_Cruise_Control_U.RadarInput_DriveVehicle) &&
(Adaptive_Cruise_Control_U.Time_Gap >=
Adaptive_Cruise_Control_U.Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_equal_Set_;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 5.0;
}
break;
case Ada_IN_LeadVehicle_Not_Detected:
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 1.0;
if ((rtb_Add1 == 1.0) &&
(Adaptive_Cruise_Control_U.RadarInput_DriveVehicle ==
Adaptive_Cruise_Control_U.Set_Speed) && (rtb_Add_l >=
Adaptive_Cruise_Control_U.Set_Speed) &&
(Adaptive_Cruise_Control_U.Time_Gap >=
Adaptive_Cruise_Control_U.Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_Follow;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 2.0;
} else if (((rtb_Add1 == 1.0) && (rtb_Add_l <
Adaptive_Cruise_Control_U.Set_Speed)) ||
(Adaptive_Cruise_Control_U.Time_Gap <
Adaptive_Cruise_Control_U.Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 4.0;
}
break;
case IN_LeadVehicle_Not_Detected_Res:
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 1.0;
break;
case IN_LeadVehicle_Speed_equal_Set_:
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 5.0;
if ((rtb_Add1 == 0.0) ||
(Adaptive_Cruise_Control_U.RadarInput_DriveVehicle <=
Adaptive_Cruise_Control_U.Set_Speed)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_Resume;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 3.0;
} else if (((Adaptive_Cruise_Control_U.RadarInput_DriveVehicle <
Adaptive_Cruise_Control_U.Set_Speed) && (rtb_Add_l >
Adaptive_Cruise_Control_U.RadarInput_DriveVehicle)) ||
(Adaptive_Cruise_Control_U.Time_Gap >=
Adaptive_Cruise_Control_U.Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Not_Detected_Res;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 1.0;
} else if (((rtb_Add_l < Adaptive_Cruise_Control_U.Set_Speed) &&
(rtb_Add_l <
Adaptive_Cruise_Control_U.RadarInput_DriveVehicle)) ||
(0.75 * Adaptive_Cruise_Control_U.Set_Gap ==
Adaptive_Cruise_Control_U.Time_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_lessthan_S;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 4.0;
}
break;
default:
/* case IN_LeadVehicle_Speed_lessthan_Set_Speed: */
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 4.0;
if ((rtb_Add1 == 0.0) &&
(Adaptive_Cruise_Control_U.RadarInput_DriveVehicle ==
Adaptive_Cruise_Control_U.Set_Speed)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
Ada_IN_LeadVehicle_Not_Detected;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 1.0;
} else if ((rtb_Add_l * 1.25 >=
Adaptive_Cruise_Control_U.RadarInput_DriveVehicle) &&
(rtb_Add_l * 0.75 <=
Adaptive_Cruise_Control_U.RadarInput_DriveVehicle) &&
(Adaptive_Cruise_Control_U.RadarInput_DriveVehicle <
Adaptive_Cruise_Control_U.Set_Speed) &&
(Adaptive_Cruise_Control_U.Time_Gap <= 1.25 *
Adaptive_Cruise_Control_U.Set_Gap) &&
(Adaptive_Cruise_Control_U.Time_Gap >= 0.75 *
Adaptive_Cruise_Control_U.Set_Gap)) {
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Speed_equal_Set_;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 5.0;
}
break;
}
}
break;
default:
/* case IN_ACC_STANDBY_MODE: */
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 1.0;
if (Adaptive_Cruise_Control_U.CruiseSwitch == 0.0) {
Adaptive_Cruise_Control_DW.is_c1_Adaptive_Cruise_Control =
Adaptive_Cruise_IN_ACC_OFF_MODE;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 0.0;
} else if (Adaptive_Cruise_Control_U.SetSwitch == 1.0) {
Adaptive_Cruise_Control_DW.is_c1_Adaptive_Cruise_Control =
Adaptive_Cruise__IN_ACC_ON_MODE;
Adaptive_Cruise_Control_DW.is_ACC_ON_MODE =
IN_LeadVehicle_Detected_Follow;
Adaptive_Cruise_Control_Y.Acceleratio_Mode = 2.0;
}
break;
}
}
/* End of Chart: '<S1>/Chart' */
/* 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]
*/







| Model Advisor Report - Adaptive_Cruise_Control.slx | |
| Simulink version: 10.3 | Model version: 1.38 |
| System: Adaptive_Cruise_Control | Current run: 09-Oct-2022 17:52:56 |
| Treat as Referenced Model: off | |
Run Summary
| Pass | Fail | Warning | Not Run | Total |
|---|---|---|---|---|
126 |
0 |
18 |
0 |
144 |
Modeling Standards for MAB
1 Naming Conventions
19
0
1
0
1.1 General
4
0
0
0
Check file namesCheck the model file name to ensure that the name complies with the recommended guidelines.
Passed
All files have correct names.
Check folder namesCheck the folder name to ensure that the name complies with the recommended guidelines.
Passed
All folders have correct names.
1.2 Content
15
0
1
0
Check subsystem namesIdentify subsystem names with incorrect characters.
Passed
All the subsystem names use correct characters.
Check port block namesCharacters allowed for port block names
Warning
The following port blocks have invalid names:
- Adaptive_Cruise_Control/CameraInput_LeadVehicle
- Adaptive_Cruise_Control/ RadarInput_LeadVehicle
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/CameraInput_LeadVehicle
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/ RadarInput_LeadVehicle
- ..../Adaptive_Cruise_Control/Drive_Vehicle/ Acceleration_Mode
- ..../Adaptive_Cruise_Control/Drive_Vehicle/DriveVehicle_Speed
Consider having only alphanumeric characters and underscores in port block name.
Check character usage in block namesIdentify block names with incorrect characters.
Passed
All the block names use correct characters.
Check length of Inport and Outport namesCheck length of Inport and Outport names
Passed
All Inport and Outport names are valid.
Check character usage in signal names and bus namesIdentify signal and bus names with invalid characters.
Passed
No invalid characters are used in signal and bus names.
Check character usage in parameter namesIdentify parameter names with invalid characters.
Passed
No invalid characters are used in parameter names.
Check length of signal and bus namesCheck length of signal and bus names
Passed
All signal and bus names are valid.
Check character usage in Stateflow data namesIdentify Stateflow data names with invalid characters.
Passed
No invalid characters are used in Stateflow data names.
Check length of Stateflow data nameCheck if the length of Stateflow data names are within limit.
Passed
All Stateflow data names are valid.
Check duplication of Simulink Data namesSimulink Data names should be unique across base workspace, model workspace and data dictionary.
Passed
All Simulink Data names are unique.
Check unused data in Simulink ModelIdentify unused data in model workspace and data dictionary.
Passed
No unused data found in model workspace and/or data dictionary.
Check for unused data in Stateflow ChartsChecks if the model parameter 'Unused data, events, messages and functions' is not set to 'none'.
Passed
All constraints on model configuration parameters have been met.
| Status | Parameter | Current Value | Recommended Values |
|---|---|---|---|
| Pass | Unused data, events, messages and functions (SFUnusedDataAndEventsDiag) | warning | error, warning |
2 Simulink
53
0
10
0
2.1 Configuration Parameters
4
0
0
0
Check Implement logic signals as Boolean data (vs. double)Identify whether Implement logic signals as Boolean data (vs. double) is selected.
Passed
Implement logic signals as Boolean data (vs. double) is selected.
Check Signed Integer Division Rounding modejc_0642: Integer rounding mode setting
Identifies blocks with block parameter 'Integer Rounding Mode' set to 'Simplest' when the configuration parameter 'Signed integer division rounds to' is set to 'Undefined'.
Passed
Configuration parameter 'Signed integer division rounds to' is not set to 'Undefined'.
Check diagnostic settings for incorrect calculation resultsIdentify data validity diagnostic settings which detect incorrect calculation results.
Passed
All constraints on model configuration parameters have been met.
| Status | Parameter | Current Value | Recommended Values |
|---|---|---|---|
| Pass | Division by singular matrix (CheckMatrixSingularityMsg) | error | error |
| Pass | Inf or NaN block output (SignalInfNanChecking) | error | error |
| Pass | Wrap on overflow (IntegerOverflowMsg) | error | error |
| Pass | Saturate on overflow (IntegerSaturationMsg) | error | error |
2.2 Diagram Appearance
14
0
3
0
Check for Simulink diagrams using nonstandard display attributesIdentify nonstandard display attributes in Simulink diagrams.
_________________________________________________________________________________________
Check format settings
Identify incorrect model-level format options.
Passed
The format options are correct.
_________________________________________________________________________________________
Check block colors
Identify blocks using nonstandard colors.
Passed
All blocks use standard colors.
_________________________________________________________________________________________
Check canvas colors
Identify canvases that are not white.
Passed
All diagrams use a white canvas.
_________________________________________________________________________________________
Check diagram zoom
Identify diagrams that do not have zoom factor set to 100 %.
Note: Zoom factors can differ for each instance of a model diagram opened in Simulink Editor
Passed
All canvases have a zoom factor of 100 percent.
Check Model font settingsIdentify blocks and charts with different font settings from input parameters.
Passed
Font settings of the blocks and charts and input parameters are same.
Check whether block names appear below blocksIdentify blocks where the name is not displayed below the block.
Passed
All blocks have names displayed below the block.
Check the display attributes of block namesIdentify whether to display block names.
Check for blocks with hidden names and obvious function
Identify block names that are displayed but can be hidden due to obvious behavior.
Passed
All blocks with obvious behavior have hidden names.
Check for non-descriptive displayed block names
Identify block names that are displayed but should be hidden due to a lack of a descriptive name.
Passed
All displayed names provide descriptive information.
Check for missing block names
Identify block names that are hidden but should be displayed to show a descriptive name.
Passed
All displayed names provide descriptive information.
Check for nondefault block attributesIdentify blocks that use and fail to display nondefault values.
Passed
Model displays all block parameter values that are not default values.
Check Model DescriptionIdentify layers in the model having inconsistent description format.
Warning
Following layers do not have model descriptions:
- Adaptive_Cruise_Control
- Adaptive_Cruise_Control/Adaptive_Cruise_Control
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Lead_Vehicle
Consider adding model description for all the layers.
Check if blocks are shaded in the modelCheck if blocks are shaded in the model
Passed
Blocks in the model are not shaded.
Check for unconnected signal lines and blocksIdentify unconnected signal lines, subsystems and basic blocks.
Passed
All signal lines and blocks in the model are connected.
Check signal line connectionsCheck signal intersections
Warning
The following signals intersect with other signals in the diagram:
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/DriveVehicle_Speed
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/LeadVehicle_Speed
Reposition the above listed signals to avoid intersections.
Check signal flow in modelIdentify subsystems which do not have a signal flow from left to right.
Passed
No subsystems found with inappropriate signal flow.
Check usage of tunable parameters in blocksIdentify tunable parameters used to specify expressions, data type conversions, or indexing operations.
Passed
Tunable parameters are not used in the model.
Check connections between structural subsystemsIdentify connections between structural subsystems.
Passed
All connections to structural subsystems adhere to the guideline.
Check for consistency in model element namesCheck if model elements connected to a signal are following consistent naming
Warning
The following model elements are not consistent with the connected signal name:
| Block Path | Expression |
|---|---|
| ..../Drive_Vehicle/LeadVehicle_Detected | Naming mismatch with signal name "DriveVehicle_Speed" |
| ..../Drive_Vehicle/DriveVehicle_Speed | Naming mismatch with signal name "LeadVehicle_Detected" |
| ..../Adaptive_Cruise_Control/Acceleratio_Mode | Naming mismatch with signal name "Acceleration_Mode" |
| Adaptive_Cruise_Control/Acceleratio_Mode | Naming mismatch with signal name "Acceleration_Mode" |
| ..../ RadarInput_LeadVehicle | Naming mismatch with signal name "RadarInput_LeadVehicle" |
| ..../ RadarInput_LeadVehicle | Naming mismatch with signal name "RadarInput_LeadVehicle" |
| ..../CameraInput_LeadVehicle | Naming mismatch with signal name "CameraInput_LeadVehicle" |
| ..../CameraInput_LeadVehicle | Naming mismatch with signal name "CameraInput_LeadVehicle" |
Recommended Action
Consider renaming the deviating model elements to match the signal name or to be consistent with Inport/Outport blocks.
Check trigger signal namesIdentify trigger blocks where the origin of the trigger signal and the destination have dissimilar names.
Passed
No violation of the guideline for use of trigger signal names.
Check for mixing basic blocks and subsystemsIdentify levels in the model that include basic blocks and subsystems. Each level of a model must be designed with blocks of the same level (for example, only subsystems or only basic blocks).
Passed
The model does not mix basic blocks and subsystems at the same level.
2.3 Signal
1
0
5
0
Check usage of vector and bus signalsIdentify mixed usages of vector and bus signals.
Passed
No mixing of vector and bus signals found in the system.
Check definition of signal labelsIdentify blocks that require labeled signals. A subset of source and destination blocks require labeled signals.
Check source block labels
Warning
The following signals have no label:
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/CameraInput_LeadVehicle /
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/ RadarInput_LeadVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/CameraInput_DriveVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/RadarInput_DriveVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Time_Gap/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Set_Speed/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Set_Gap/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/CruiseSwitch/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/SetSwitch/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/CameraInput_DriveVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/RadarInput_DriveVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/ Acceleration_Mode/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Lead_Vehicle/CameraInput_LeadVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Lead_Vehicle/RadarInput_LeadVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
Recommended Action
Add a new or propagated label to the signal line.
_________________________________________________________________________________________
Identify blocks that require labeled signals. A subset of source and destination blocks require labeled signals.
Check destination block labels
Warning
The following signals have no label:
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/LeadVehicle_Detected/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/DriveVehicle_Speed /
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Lead_Vehicle/LeadVehicle_Speed/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Acceleratio_Mode/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Lead_Vehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Lead_Vehicle/
Recommended Action
Add a new or propagated label to the signal line.
Check Signal name propagationCheck Signal name propagation for subsystems
Warning
The following subsystems do not display propagated signals but have signal names:
- Adaptive_Cruise_Control/Acceleration_Mode
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/DriveVehicle_Speed
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/LeadVehicle_Detected
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/LeadVehicle_Speed
Remove labels and enable signal propagation by selecting 'Show propagated signal' parameter for signals.
Check position of signal labelsCheck location of signal labels
Warning
The following signals do not have labels located at the origin of the signal line:
Consider placing the labels at the origin of the signal line.
Check signal line labelsIdentify blocks that require labeled signals. A subset of source and destination blocks require labeled signals.
Check source block labels
Warning
The following signals have no label:
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/CameraInput_LeadVehicle /
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/ RadarInput_LeadVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/CameraInput_DriveVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/RadarInput_DriveVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Time_Gap/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Set_Speed/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Set_Gap/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/CruiseSwitch/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/SetSwitch/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/CameraInput_DriveVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/RadarInput_DriveVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/ Acceleration_Mode/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Lead_Vehicle/CameraInput_LeadVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Lead_Vehicle/RadarInput_LeadVehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
Recommended Action
Add a new or propagated label to the signal line.
_________________________________________________________________________________________
Identify blocks that require labeled signals. A subset of source and destination blocks require labeled signals.
Check destination block labels
Warning
The following signals have no label:
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/LeadVehicle_Detected/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/DriveVehicle_Speed /
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Lead_Vehicle/LeadVehicle_Speed/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Acceleratio_Mode/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Drive_Vehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Lead_Vehicle/
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Lead_Vehicle/
Recommended Action
Add a new or propagated label to the signal line.
Check for propagated signal labelsIdentify propagated labels on signal lines.
Warning
The following signal labels are not propagated. Propagate signals coming from Subsystem blocks.
- Adaptive_Cruise_Control/Acceleration_Mode
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/DriveVehicle_Speed
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/LeadVehicle_Detected
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/LeadVehicle_Speed
Add labels to the output signals.
2.4 Block Consistency
5
0
1
0
Check Indexing ModeCheck for Zero-Based Indexing Mode.
Warning
The following blocks or charts have One-Based Indexing mode:
Consider remodeling by using Zero-Based Indexing.
Check block orientationIdentify blocks which are rotated or reversed.
Passed
No blocks found with rotated or reversed orientation
Check if tunable block parameters are defined as named constantsCheck if tunable block parameters are defined as named constants
Passed
All tunable block parameters are defined as named constants
Check for sample time settingCheck if sample time property of a block is set to -1 (inherited).
Passed
All permitted blocks have sample time set to -1 (inherited).
2.5 Conditional Subsystem relations
5
0
0
0
Check position of conditional blocks and iterator blocksIdentify conditional and iterative blocks that are positioned inconsistently in the model.
Passed
The conditional and iterative blocks are correctly placed in the model.
Check undefined initial output for conditional subsystemsIdentify undefined initial output for Outports/Merge blocks in conditional subsystems
Passed
The initial output setting for all Conditional Subsystems are valid.
Check usage of Merge blockjc_0659: Usage restrictions of signal lines input to Merge blocks
There must not be any block between a Conditional Subsystem block and a Merge block.
Passed
No Merge block found.
2.6 Operation Blocks
15
0
0
0
Check fundamental logical and numerical operationsIdentify the usage of logical and numerical operations.
Passed
No numerical operation blocks found with boolean inputs.
No logical operation blocks found with non-boolean inputs.
Check usage of Sum blocksIdentify Sum block usage that can affect readability.
Passed
No violations of the guideline found with the usage of the Sum block.
Check operator order of Product blocksOperator order for Product blocks.
Passed
All Product blocks have valid operator order.
Check signs of input signals in product blocksjc_0611: Input sign for multiplication and division blocks
Identify blocks that perform division whose inputs have different sign bit.
Passed
No product block with division of different sign bits found.
Check for parentheses in Fcn block expressionsIdentify order of parentheses in Fcn block expressions.
Passed
All Fcn blocks use parentheses to mark operator precedence.
Check icon shape of Logical Operator blocksIcon shape of Logical Operator blocks.
Passed
All Logical Operator blocks have consistent icon shape.
Check usage of Relational Operator blocksIdentify Relational Operator blocks that connect to constants with the first (upper) input value.
Passed
This model does not contain Relational Operator blocks.
Check comparison of floating point types in Simulinkjc_0800: Comparing floating-point types in Simulink
Equivalence comparison should not be used for floating point numbers.
Passed
No Equivalence comparison done on floating point numbers.
Check usage of Lookup TablesCheck usage of recommended settings for Lookup Table blocks to prevent unexpected results.
Passed
All Lookup Table blocks have recommended settings.
Check usage of Memory and Unit Delay blocksIdentify Memory blocks not using a continuous sample time
Passed
No Memory blocks found with inappropriate sample time
_________________________________________________________________________________________
Identify Unit Delay blocks with non-discrete sample time
Passed
No Unit Delay blocks found with non-discrete sample time
Check for cascaded Unit Delay blocksIdentify cascaded and tapped pattern of Unit Delay blocks.
Passed
No cascaded Unit Delay blocks found that can be changed to Tapped Delay/Delay block.
Check usage of Discrete-Time Integrator blockCheck usage of recommended settings for Discrete-Time Integrator blocks to prevent unexpected results.
Passed
All Discrete-Time Integrator blocks have recommended settings.
Check usage of the Saturation blocksjc_0628: Usage of Saturation blocks
Identify the Saturation and Saturation Dynamic blocks that perform type casting.
Passed
No Saturation and/or Saturation Dynamic blocks perform type casting
2.7 Other blocks
9
0
1
0
Check position of Inport and Outport blocksCheck positions of Inport blocks
Warning
The following Inport blocks are not placed to the extreme left side of the diagram:
- Adaptive_Cruise_Control/CameraInput_LeadVehicle
- Adaptive_Cruise_Control/ RadarInput_LeadVehicle
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/CameraInput_LeadVehicle
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/ RadarInput_LeadVehicle
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/CruiseSwitch
Move the Inport blocks identified to the left of all other blocks in the diagram.
It is acceptable to move the Inport block to the right only to prevent signal crossings.
Check display for port blocksIdentify Inport and Outport blocks that do not specify Port number for the Icon display block parameter.
Passed
All port blocks display the port number.
Check scope of From and Goto blocksIdentify incorrect scoping of From and Goto blocks. For signal flows, From and Goto blocks must use local scope. Control flow can use global scope.
Passed
All From and Goto blocks are used correctly.
Check for usage of Data Store Memory blocksIdentify the usage of Data Store Memory blocks.
Passed
Usage of Data Store Memory blocks is correct.
Check usage of Switch blocksIdentify Switch blocks that do not use Boolean inputs for the switch condition (input 2), and do not use u2 ~= 0 for the Criteria for passing first input block parameter.
_________________________________________________________________________________________
Check Switch block parameters
Identify Switch blocks with the parameter Criteria for passing first input not set to u2 ~= 0.
Passed
The block parameter Criteria for passing first input is correctly configured.
_________________________________________________________________________________________
Check for Boolean switch condition
Identify blocks that do not use Boolean signal switch conditions (input 2).
Passed
The switch condition is a Boolean signal.
Check input and output datatype for Switch blocksIdentify Switch blocks with mismatched input and output data types.
Passed
No Switch blocks found with mismatched input and output data types
Check settings for data ports in Multiport Switch blocksIdentify Multiport Switch blocks that violate data port settings.
Passed
No Multiport Switch blocks found with inappropriate data port settings.
Check for missing ports in Variant SubsystemsCheck for number of inputs/outputs to a Variant Subsystem.
Passed
No Variant Subsystems found having different number of inputs/outputs in the Variant Subsystem choices.
3 Stateflow
45
0
7
0
3.1 Block/Data/Events
7
0
0
0
Check for Strong Data Typing with Simulink I/OCheck whether labeled input and output signals are strongly typed.
Passed
No Stateflow charts have Use Strong Data Typing with Simulink I/O cleared.
Check for names of Stateflow ports and associated signals
Identify mismatches between names of Stateflow ports and the associated signals.
Passed
There are no name mismatches between Stateflow ports and the associated signals.
Check execution timing for default transition path'Execute (enter) Chart At Initialization' should be set to OFF.
Passed
All Stateflow Charts pass the check.
Check definition of Stateflow dataIdentify the Scope value set on Stateflow data defined at machine level.
Passed
All Stateflow data at machine level has been defined as per guideline.
Check usable number for first indexIdentify usage of first index of Stateflow data.
Passed
All Stateflow data first index values are uniform.
3.2 Diagram
12
0
2
0
Check for unconnected objects in Stateflow ChartsIdentify dangling transitions and unconnected Stateflow States and Junctions in Stateflow Charts.
Passed
No unconnected transitions, states or junctions found in Stateflow Charts.
Check for exclusive states in state machinesIdentify states which are the only sub-state within a state with OR(exclusive) type decomposition.
Passed
All states with OR(exclusive) type decomposition have more than one sub-state.
Check usage of parallel statesSubstates of parallel states should not be parallel states.
Passed
All Stateflow Charts pass the check.
Check Stateflow transition appearanceIdentify Stateflow transitions visually overlapping other Stateflow objects.
Passed
No transition violates the guidelines for Stateflow transition appearance.
Check default transition placement in Stateflow chartsjc_0531: Default transition
Identify all groupings of states that do not have a default transition or do not have the default state as the top-most state.
Warning
The following destination states or junctions of default transitions are not on the top:
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/ACC_OFF_MODE
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/LeadVehicle_Detected_Follow
The transition destination state or transition destination junction for the default transition must be positioned in the far upper left within the same level.
Check usage of transitions to external statesIdentify transitions ending on external child states.
Passed
No direct transitions found from external state to child state.
Check for unexpected backtracking in state transitionsIdentify configuration parameter settings which identify unexpected backtracking in state transitions.
Passed
All constraints on model configuration parameters have been met.
| Status | Parameter | Current Value | Recommended Values |
|---|---|---|---|
| Pass | Unexpected backtracking (SFUnexpectedBacktrackingDiag) | error | error |
Check usage of internal transitionInternal transition lines should start from the left edge of the state.
Passed
No Stateflow transitions found that violate the guidelines for starting point of internal transition in Stateflow.
Check usage of internal transitions in Stateflow statesIdentify Stateflow states using multiple internal transitions.
Passed
No Stateflow states found with multiple internal transitions
Check prohibited combination of state action and flow chartState actions and flow charts should not be combined in states.
Passed
No Stateflow states were found that combine state action and flow chart.
Check transitions in Stateflow flow chartsCheck for transition orientation in flow charts
Warning
The following transitions with condition expressions are not drawn horizontally:
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/transition(#169)
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/transition(#170)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#149)
Draw transition condition expressions horizontally.
Check usage of unconditional transitions in flow chartsIdentify unconditional transitions in flow charts.
Passed
All unconditional transitions adhere to the guideline.
3.3 Condition Transition/Action
14
0
3
0
Check Stateflow chart action languageIdentify if the action language of Stateflow charts is set to 'C'
Warning
The following Stateflow Charts do not have action language set to 'C':
Consider setting Stateflow Chart action language to 'C'.
Check usage of numeric literals in StateflowCheck for numeric literals in Stateflow
Warning
The following expressions contain numeric literals:
| Block Path | Expression |
|---|---|
| ..../Chart/ACC_STANDBY_MODE | Acceleration_Mode=1; |
| ..../ACC_ON_MODE/LeadVehicle_Detected_Follow | Acceleration_Mode=2; |
| ..../ACC_ON_MODE/LeadVehicle_Not_Detected | Acceleration_Mode=1; |
| ..../ACC_ON_MODE/LeadVehicle_Detected_Resume | Acceleration_Mode=3; |
| ..../LeadVehicle_Not_Detected_Resume | Acceleration_Mode=1; |
| ..../LeadVehicle_Speed_lessthan_Set_Speed | Acceleration_Mode=4; |
| ..../LeadVehicle_Speed_equal_Set_Speed | Acceleration_Mode=5; |
| ..../Chart/ACC_ON_MODE/transition(#146) | LeadVehicle_Detected == 0 |
| ..../Chart/ACC_ON_MODE/transition(#147) | (LeadVehicle_Detected==1) && (DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap) |
| ..../Chart/ACC_ON_MODE/transition(#148) | (LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed) || (Time_Gap < Set_Gap) |
| ..../Chart/ACC_ON_MODE/transition(#149) | LeadVehicle_Detected==0 |
| ..../Chart/ACC_ON_MODE/transition(#151) | (LeadVehicle_Detected == 0) || (DriveVehicle_Speed <= Set_Speed) |
| ..../Chart/ACC_ON_MODE/transition(#152) | (LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed) || (Time_Gap < Set_Gap) |
| ..../Chart/ACC_ON_MODE/transition(#153) | (LeadVehicle_Detected == 0) && (DriveVehicle_Speed == Set_Speed) |
| ..../Chart/ACC_ON_MODE/transition(#154) | (LeadVehicle_Speed<set_speed) &&="" (leadvehicle_speed<drivevehicle_speed)="" ||="" (time_gap="=" 0.75*set_gap)="" <="" td=""></set_speed)> |
| ..../Chart/ACC_ON_MODE/transition(#155) | ((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)) |
| ..../Chart/transition(#167) | CruiseSwitch==1 |
| ..../Chart/transition(#168) | CruiseSwitch==0 |
| ..../Chart/transition(#169) | SetSwitch==0 |
| ..../Chart/transition(#170) | SetSwitch==1 |
Recommended Action
Consider remodeling to use named parameters and constants instead of numeric literals.
Check for pointers in Stateflow chartsIdentify pointer operations on custom code variables.
Note: This check applies only to Stateflow charts that use C as the action language.
Passed
No pointer operations were found.
Check usage of events in Stateflow chartsIdentify undirected event broadcasts in Stateflow.
Passed
No instances of undirected event broadcast were found.
Check order of state action typesIdentify out of order state action types in Stateflow states.
Passed
No Stateflow states found with out of order state action types
Check repetition of Action typesjc_0734: Number of state action types
Identifies repeated action types in a Stateflow State.
Passed
All Stateflow States pass the check.
Check if state action type 'exit' is used in the modelCheck if state action type 'exit' is used in the model.
Passed
State action type 'exit' is not used in the model.
Check updates to variables used in state transition conditionsjc_0741: Timing to update data used in state chart transition conditions
Variables used in state transition conditions must not perform an update by "during" state action type.
Passed
No Stateflow states found that violate the guidelines for updating the variables used in state transition conditions.
Check usage of transition conditions in Stateflow transitionsIdentify unconditional Stateflow transitions with higher priority than conditional transitions.
Passed
No unconditional Stateflow transitions found with higher priority than conditional transitions
Check condition actions and transition actions in StateflowIdentify usage of transition actions in Stateflow.
Passed
No Stateflow charts have transition actions.
Check for MATLAB expressions in Stateflow blocksIdentify MATLAB expressions that are not suitable for code generation in Stateflow blocks.
Passed
No Stateflow objects found using MATLAB expressions unsuitable for code generation.
Check usage of floating-point expressions in Stateflow chartsIdentify equality or inequality operations (==,~=,!=) in expressions involving floating-point variables or constants.
Passed
No equality or inequality to operations in expressions where at least one side of the expression is a floating-point variable or constant were found.
Check Stateflow operatorsIdentify the usage of operators in Stateflow.
Passed
No Stateflow blocks found with incorrect operator usage.
Check prohibited comparison operation of logical type signalsIdentify boolean variables in Stateflow charts using comparison operations.
Passed
No boolean variables use comparison operations of logical type in the model.
Check usage of unary minus operations in Stateflow chartsIdentify unary minus operations applied to unsigned integers in Stateflow objects.
Passed
No unary minus operations applied to unsigned integers in Stateflow objects were found.
Check for implicit type casting in StateflowOperations performed between variables must be of the same data type.
Warning
The following operations and/or function calls have data type mismatch:
| Block Path | Expression |
|---|---|
| ..../Chart/ACC_OFF_MODE | ACC_OFF_MODE<br > en: Acceleration_Mode=0;</br > |
| ..../Chart/ACC_STANDBY_MODE | ACC_STANDBY_MODE<br > en: Acceleration_Mode=1;</br > |
| ..../ACC_ON_MODE/LeadVehicle_Detected_Follow | LeadVehicle_Detected_Follow<br > en: Acceleration_Mode=</br >2; |
| ..../ACC_ON_MODE/LeadVehicle_Not_Detected | LeadVehicle_Not_Detected<br > en: Acceleration_Mode=</br >1; |
| ..../ACC_ON_MODE/LeadVehicle_Detected_Resume | LeadVehicle_Detected_Resume<br > en: Acceleration_Mode=</br >3; |
| ..../LeadVehicle_Not_Detected_Resume | LeadVehicle_Not_Detected_Resume<br > en: Acceleration_Mode=</br >1; |
| ..../LeadVehicle_Speed_lessthan_Set_Speed | LeadVehicle_Speed_lessthan_Set_Speed<br > en: Acceleration_Mode=</br >4; |
| ..../LeadVehicle_Speed_equal_Set_Speed | LeadVehicle_Speed_equal_Set_Speed<br > en: Acceleration_Mode=</br >5; |
| ..../Chart/ACC_ON_MODE/transition(#146) | [LeadVehicle_Detected == 0] |
| ..../Chart/ACC_ON_MODE/transition(#147) | [(LeadVehicle_Detected==1) && (DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)] |
| ..../Chart/ACC_ON_MODE/transition(#148) | [(LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed) || (Time_Gap < Set_Gap)] |
| ..../Chart/ACC_ON_MODE/transition(#149) | [LeadVehicle_Detected==0] |
| ..../Chart/ACC_ON_MODE/transition(#151) | [(LeadVehicle_Detected == 0) || (DriveVehicle_Speed <= Set_Speed)] |
| ..../Chart/ACC_ON_MODE/transition(#152) | [(LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed) || (Time_Gap < Set_Gap)] |
| ..../Chart/ACC_ON_MODE/transition(#153) | [(LeadVehicle_Detected == 0) && (DriveVehicle_Speed == Set_Speed)] |
| ..../Chart/ACC_ON_MODE/transition(#154) | [(LeadVehicle_Speed<set_speed) && (leadvehicle_speed<drivevehicle_speed) || (time_gap == 0.75*Set_Gap)]</set_speed) && (leadvehicle_speed<drivevehicle_speed) || (time_gap |
| ..../Chart/ACC_ON_MODE/transition(#155) | [((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))] |
| ..../Chart/transition(#167) | [CruiseSwitch==1] |
| ..../Chart/transition(#168) | [CruiseSwitch==0] |
| ..../Chart/transition(#169) | [SetSwitch==0] |
| ..../Chart/transition(#170) | [SetSwitch==1] |
Recommended Action
All operations (substitution, comparison, arithmetic, etc.) must be made only between variables of the same data type. Actual arguments and formal arguments in function calls must be of the same data type. If data types are different, the variables need to be explicitly type cast to matching data types.
3.4 Label Description
8
0
2
0
Check uniqueness of Stateflow State and Data namesjc_0732: Distinction between state names, data names, and event names
Identify Stateflow State and Stateflow Data that have identical names in a given chart.
Passed
All Stateflow charts pass the check.
Check uniqueness of State namesjc_0730: Unique state name in Stateflow blocks
Identifies identical State names within a Stateflow Chart.
Passed
All Stateflow charts pass the check.
Check usage of State namesjc_0731: State name format
Identify state names with '/' at its end.
Passed
All State names pass the check.
Check entry formatting in State blocks in Stateflow chartsCheck entry formatting in State blocks in Stateflow charts
Warning
The following entries use incorrect formatting:
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/ACC_OFF_MODE
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/LeadVehicle_Not_Detected_Resume
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/ACC_STANDBY_MODE
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/LeadVehicle_Not_Detected
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/LeadVehicle_Detected_Resume
- ..../Chart/ACC_ON_MODE/LeadVehicle_Speed_lessthan_Set_Speed
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/LeadVehicle_Detected_Follow
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/LeadVehicle_Speed_equal_Set_Speed
Ensure that the entries (en:, du:, ex:) and all statements begin on a new line.
Check indentation of code in Stateflow statesIdentify non-uniform indentation in Stateflow blocks.
Passed
All Stateflow blocks have uniform indentation.
Check for usage of text inside statesIdentify Stateflow states with text exceeding the boundary of the state.
Passed
No Stateflow states found with text exceeding the boundary of the state.
Check position of label string in Stateflow transitionTransition labels should be placed near the point of origin of the transition
Warning
The following transitions do not have label string placed near the origin of the transition:
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#144)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#146)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#147)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#148)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#149)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#150)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#151)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#152)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#153)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#154)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#155)
- ..../Adaptive_Cruise_Control/Chart/ACC_ON_MODE/transition(#156)
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/transition(#167)
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/transition(#168)
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/transition(#169)
- Adaptive_Cruise_Control/Adaptive_Cruise_Control/Chart/transition(#170)
Recommended Action
Consider placing the label string near the point of origin of the transition.
Check position of comments in transition labelsIdentify comments in transition labels that are not positioned uniformly.
Passed
Comments in transition labels are positioned uniformly.
3.5 Miscellaneous
4
0
0
0
Check return value assignments in Stateflow graphical functionsIdentify graphical functions with multiple assignments of return values in Stateflow charts.
Passed
No multiple assignments of return values were found.
Check uniqueness of Stateflow State and Data namesjc_0732: Distinction between state names, data names, and event names
Identify Stateflow State and Stateflow Data that have identical names in a given chart.
Passed
All Stateflow charts pass the check.
4 MATLAB
9
0
0
0
4.1 Data and Operations
3
0
0
0
Check MATLAB code for global variablesCheck for global variables in MATLAB code
_________________________________________________________________________________________
Check for global variables in MATLAB code used in MATLAB Function blocks
Passed
No MATLAB Function blocks found
_________________________________________________________________________________________
Check for global variables in MATLAB functions defined in Stateflow charts
Passed
No MATLAB functions defined in Stateflow charts found
_________________________________________________________________________________________
Check for global variables in called MATLAB functions
Passed
No external MATLAB functions found
_________________________________________________________________________________________
4.2 Usage
6
0
0
0
Check lines of code in MATLAB FunctionsIdentify MATLAB Functions with high number of effective lines of code.
Passed
No MATLAB Function found with high number of effective lines of code.
Check the number of function calls in MATLAB Function blocksChecks whether number of function calls in MATLAB Function blocks is less than 3.
Passed
Number of function calls in MATLAB Function blocks is less than 3.
Check nested conditions in MATLAB FunctionsIdentify nested if/else and case statements in MATLAB Functions.
Passed
No MATLAB Function found with deeply nested if/else and case statements.
Check usage of character vector inside MATLAB Function blockChecks whether character vectors are being used inside MATLAB Function blocks
Passed
No character vectors found in MATLAB Function block