Challenge

Project 2 Adaptive Cruise Control

Objective of Main Project:

  1. Developing Adaptive Cruise Control feature as per the Requirement Document using MATLAB Simulink.
  2. Follow all the MBD related processes: Requirement Tagging & Traceability, SLDD creation, Configuration Parameter changes, Model Advisor check & Code Generation.
  3. In Configuration Parameters: enable “Support Floating Numbers” under Code Generation settings.
  4. Use Embedded Coder to generate the code.
  5. 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.
  6. 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.
Adaptive Cruise Control Algorithm:
Creat Input & output so put values in Symbols Pane. Given names store in this symbols
Join the all input & output values to ACC subsystem.
Requirement Tagging & Traceability:
Save a given data requirment in Word document. select Lead vehicle,Drive vehicle and ACC subsystem right click>>Requirement>>Link to selection Word.
before we select that requirememnt document .
Right click >>Block Parameters (Subsystem)>> click Treat as Atomic Unit >> apply and ok
Code Generation:
click App>> Embeddedd Coder >>Build then creating Code generated
/*
 * 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 check:
Click Model Advisor block >>System selector >> click ok
we want only Modeling Standards for MAB so select that only then Run Selecetd Checks>> clear errors
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 names

Check the model file name to ensure that the name complies with the recommended guidelines.

Passed
All files have correct names.


Check folder names

Check the folder name to ensure that the name complies with the recommended guidelines.

Passed
All folders have correct names.


Check length of model file name

Check length of model file name

Passed
Model name is valid.


Check length of folder name at every level of model path

The model file name is: Adaptive_Cruise_Control



Passed
Folder names are valid.


1.2 Content 15 0 1 0

Check subsystem names

Identify subsystem names with incorrect characters.

Passed
All the subsystem names use correct characters.


Check character usage in block names

Identify block names with incorrect characters.

Passed
All the block names use correct characters.


Check length of subsystem names

Check length of subsystem names

Passed
All subsystem names are valid.


Check length of block names

Check length of block names

Passed
All block names are valid.


Check length of Inport and Outport names

Check length of Inport and Outport names

Passed
All Inport and Outport names are valid.


Check character usage in signal names and bus names

Identify signal and bus names with invalid characters.

Passed
No invalid characters are used in signal and bus names.


Check character usage in parameter names

Identify parameter names with invalid characters.

Passed
No invalid characters are used in parameter names.


Check length of signal and bus names

Check length of signal and bus names

Passed
All signal and bus names are valid.


Check length of parameter names

Check length of parameter names

Passed
All parameter names are valid.


Check character usage in Stateflow data names

Identify Stateflow data names with invalid characters.

Passed
No invalid characters are used in Stateflow data names.


Check length of Stateflow data name

Check if the length of Stateflow data names are within limit.

Passed
All Stateflow data names are valid.


Check duplication of Simulink Data names

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

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

Checks 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


Check usage of restricted variable names

Checks whether variable names used in MATLAB Function blocks are reserved for C/C++/MATLAB keywords

Passed
No variable names conflict with reserved keywords



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 mode

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

Identify 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


Check model diagnostic parameters

Identify diagnostic parameters that are set to none.

Passed
All of the diagnostic parameters are set to error or warning.



2.2 Diagram Appearance 14 0 3 0

Check for Simulink diagrams using nonstandard display attributes

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

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

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

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

Identify blocks that use and fail to display nondefault values.

Passed
Model displays all block parameter values that are not default values.


Check Model Description

Identify layers in the model having inconsistent description format.

Warning
Following layers do not have model descriptions:

Recommended Action
Consider adding model description for all the layers.

Check if blocks are shaded in the model

Check if blocks are shaded in the model

Passed
Blocks in the model are not shaded.


Check for unconnected signal lines and blocks

Identify unconnected signal lines, subsystems and basic blocks.

Passed
All signal lines and blocks in the model are connected.


Check signal line connections

Check signal intersections

Warning
The following signals intersect with other signals in the diagram:

Recommended Action
Reposition the above listed signals to avoid intersections.

Check signal flow in model

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

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

Identify connections between structural subsystems.

Passed
All connections to structural subsystems adhere to the guideline.


Check for consistency in model element names

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

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

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


Check for avoiding algebraic loops between subsystems

jc_0653: Delay block layout in feedback loops

Identify delay blocks usage in feedback loops.

Passed
No delay blocks in feedback loops violate the guidelines for avoiding algebraic loops between subsystems.


Check for prohibited sink blocks

Identify sink blocks that must be removed prior to code generation.

Passed
There are no prohibited blocks in the subsystem.



2.3 Signal 1 0 5 0

Check usage of vector and bus signals

Identify mixed usages of vector and bus signals.

Passed
No mixing of vector and bus signals found in the system.


Check definition of signal labels

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

∧ Less
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:

∧ Less
Recommended Action
Add a new or propagated label to the signal line.

Check Signal name propagation

Check Signal name propagation for subsystems

Warning
The following subsystems do not display propagated signals but have signal names:

Recommended Action
Remove labels and enable signal propagation by selecting 'Show propagated signal' parameter for signals.

Check position of signal labels

Check location of signal labels

Warning
The following signals do not have labels located at the origin of the signal line:

Recommended Action
Consider placing the labels at the origin of the signal line.

Check signal line labels

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

∧ Less
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:

∧ Less
Recommended Action
Add a new or propagated label to the signal line.

Check for propagated signal labels

Identify propagated labels on signal lines.

Warning
The following signal labels are not propagated. Propagate signals coming from Subsystem blocks.

Recommended Action
Add labels to the output signals.


2.4 Block Consistency 5 0 1 0

Check Indexing Mode

Check for Zero-Based Indexing Mode.

Warning
The following blocks or charts have One-Based Indexing mode:

Recommended Action
Consider remodeling by using Zero-Based Indexing.

Check block orientation

Identify blocks which are rotated or reversed.

Passed
No blocks found with rotated or reversed orientation


Check if tunable block parameters are defined as named constants

Check if tunable block parameters are defined as named constants

Passed
All tunable block parameters are defined as named constants


Check for sample time setting

Check if sample time property of a block is set to -1 (inherited).

Passed
All permitted blocks have sample time set to -1 (inherited).


Check usage of fixed-point data type with non-zero bias

jc_0643: Fixed-point setting

Identify blocks with a fixed-point data type whose bias is not zero.

Passed
No blocks found with the Data Type Assistant mode set to "Fixed point" and a bias value other than zero


Check type setting by data objects

jc_0644: Type setting

Identify blocks that violate signal data type setting if signal objects are used.

Passed
No blocks found that violate signal data type setting if signal objects are used.



2.5 Conditional Subsystem relations 5 0 0 0

Check position of conditional blocks and iterator blocks

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

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

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


Check logical expressions in If blocks

Checks If blocks for complex usage of primary expressions within a logical expression

Passed
Logical expressions inside If blocks are simple


Check default/else case in Switch Case blocks and If blocks

Check if default/else case in Switch Case blocks and If blocks are set to 'on'

Passed
Conditional Control blocks are valid.



2.6 Operation Blocks 15 0 0 0

Check fundamental logical and numerical operations

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

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

Operator order for Product blocks.

Passed
All Product blocks have valid operator order.


Check signs of input signals in product blocks

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

Identify order of parentheses in Fcn block expressions.

Passed
All Fcn blocks use parentheses to mark operator precedence.


Check icon shape of Logical Operator blocks

Icon shape of Logical Operator blocks.

Passed
All Logical Operator blocks have consistent icon shape.


Check usage of Relational Operator blocks

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

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

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

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

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

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

jc_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


Check output data type of operation blocks

jc_0651: Implementing a type conversion

Identify operation blocks that specify output data type.

Passed
No operation blocks found that explicitly specify output data type.


Check for division by zero in Simulink

Identify division operations in Simulink resulting in divide-by-zero error.

Passed
No division operations found resulting in divide-by-zero error.



2.7 Other blocks 9 0 1 0

Check position of Inport and Outport blocks

Check positions of Inport blocks

Warning
The following Inport blocks are not placed to the extreme left side of the diagram:

Recommended Action
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 blocks

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

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

Identify the usage of Data Store Memory blocks.

Passed
Usage of Data Store Memory blocks is correct.


Check usage of Switch blocks

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

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

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

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


Check use of default variants

na_0036: Default variant

Identify variant subsystems that do not use default variants.

Passed
All variant subsystems in the model use default variants


Check use of single variable variant conditionals

Identify variant subsystems which use multi-variable compound conditions.

Passed
No variant subsystems with multiple variable compound conditions found



3 Stateflow 45 0 7 0


3.1 Block/Data/Events 7 0 0 0

Check for Strong Data Typing with Simulink I/O

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

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

Identify usage of first index of Stateflow data.

Passed
All Stateflow data first index values are uniform.


Check scope of data in parallel states

jc_0722: Local data definition in parallel states
The scope of local variables should be restricted to one parallel state unless it is being used by other parallel states.

Passed
No Stateflow States were found.


Check definition of Stateflow events

Stateflow events should be defined at the smallest possible scope of usage.

Passed
All Stateflow events are defined at their smallest scope.



3.2 Diagram 12 0 2 0

Check for unconnected objects in Stateflow Charts

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

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

Substates of parallel states should not be parallel states.

Passed
All Stateflow Charts pass the check.


Check Stateflow transition appearance

Identify Stateflow transitions visually overlapping other Stateflow objects.

Passed
No transition violates the guidelines for Stateflow transition appearance.


Check default transition placement in Stateflow charts

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

Recommended Action
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 states

Identify transitions ending on external child states.

Passed
No direct transitions found from external state to child state.


Check for unexpected backtracking in state transitions

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

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

Identify Stateflow states using multiple internal transitions.

Passed
No Stateflow states found with multiple internal transitions


Check prohibited combination of state action and flow chart

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

Check for transition orientation in flow charts

Warning
The following transitions with condition expressions are not drawn horizontally:

Recommended Action
Draw transition condition expressions horizontally.

Check usage of unconditional transitions in flow charts

Identify unconditional transitions in flow charts.

Passed
All unconditional transitions adhere to the guideline.


Check terminal junctions in Stateflow

Identify usage of terminal junctions in flow charts.

Passed
Multiple terminal junctions were not found.


Check usage of Stateflow comments

Identify comments that are nested or contain newline(s) in the middle in Stateflow for action language 'C'.

Passed
No comments found that are either nested or contain newline(s) in the middle.



3.3 Condition Transition/Action 14 0 3 0

Check Stateflow chart action language

Identify if the action language of Stateflow charts is set to 'C'

Warning
The following Stateflow Charts do not have action language set to 'C':

Recommended Action
Consider setting Stateflow Chart action language to 'C'.

Check usage of numeric literals in Stateflow

Check 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
∧ Less


Recommended Action
Consider remodeling to use named parameters and constants instead of numeric literals.

Check for pointers in Stateflow charts

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

Identify undirected event broadcasts in Stateflow.

Passed
No instances of undirected event broadcast were found.


Check order of state action types

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

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

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

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

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

Identify usage of transition actions in Stateflow.

Passed
No Stateflow charts have transition actions.


Check for MATLAB expressions in Stateflow blocks

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

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

Identify the usage of operators in Stateflow.

Passed
No Stateflow blocks found with incorrect operator usage.


Check prohibited comparison operation of logical type signals

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

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

Operations 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]
∧ Less


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.

Check usage of graphical functions in Stateflow

Check for calls between graphical functions.

Passed
No calls between graphical functions were found.



3.4 Label Description 8 0 2 0

Check uniqueness of Stateflow State and Data names

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

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

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

Check indentation of code in Stateflow states

Identify non-uniform indentation in Stateflow blocks.

Passed
All Stateflow blocks have uniform indentation.


Check for usage of text inside states

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

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

∧ Less
Recommended Action
Consider placing the label string near the point of origin of the transition.

Check position of comments in transition labels

Identify comments in transition labels that are not positioned uniformly.

Passed
Comments in transition labels are positioned uniformly.


Check usage of parentheses in Stateflow transitions

jc_0752: Condition action in transition label

Start new line before and after parentheses for condition actions in Stateflow transitions.

Passed
No Stateflow Transitions found that violate the requirement for new line for condition actions.


Check for comments in unconditional transitions

Identify comments in unconditional transitions without action statements.

Passed
All unconditional transitions without action statements have comments.



3.5 Miscellaneous 4 0 0 0

Check return value assignments in Stateflow graphical functions

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

jc_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 usage of Simulink functions in Stateflow

Usage of Simulink Functions in Stateflow.

Passed
All Simulink Functions in Stateflow are defined according to the guideline.


Check use of Simulink in Stateflow charts

na_0039: Limitation on Simulink functions in Chart blocks

Check use of Stateflow charts nested inside Simulink functions used in Stateflow.

Passed
No Stateflow charts found nested inside Simulink functions used in Stateflow.



4 MATLAB 9 0 0 0


4.1 Data and Operations 3 0 0 0

Check MATLAB code for global variables

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


Check usage of enumerated values

Identify enumeration classes used in the model with no default value specification.

Passed
No enumeration classes found without default value specifications.


Check input and output settings of MATLAB Functions

Identify MATLAB Functions that have inputs, outputs, or parameters with inherited complexity, data type, or size properties.

Passed
No MATLAB Functions found in the model or subsystem.



4.2 Usage 6 0 0 0

Check lines of code in MATLAB Functions

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

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

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

Checks whether character vectors are being used inside MATLAB Function blocks

Passed
No character vectors found in MATLAB Function block


Check usage of recommended patterns for Switch/Case statements

Checks whether non-constant variables are used in Switch/Case arguments.

Passed
Non-constant variables are not used as Switch/Case arguments


Check for use of C-style comment symbols

Identify usage of C-style comments in CGT Files and MPT Objects.

Passed
C-style comments are not used in CGT Files and MPT Objects.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.