Challenge

Project 2 Adaptive Cruise Control

                                                                                 EV-BATCH 17

Objective of Main Project:

  1.  To Developing Adaptive Cruise Control feature as per the Requirement Document using MATLAB Simulink.
  2.  To 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.

Main Project – Adaptive Cruise Control (ACC)

Adaptive cruise control (ACC) is an active safety system that automatically controls the acceleration and braking of a vehicle. It is activated through a button on the steering wheel and cancelled by driver’s braking and/or another button.

       

How adaptive cruise control works

By monitoring other vehicles and objects on the road, adaptive cruise control enables a safe and comfortable driving experience. It does so by helping the driver keep a steady vehicle speed at a given moment. The driver can set their preference regarding certain factors, such as the distance to the car in front, driving mode – for example, economical, sporty or comfortable – and others. Together with information about speed limits, road curvature, accidents data and more, these choices influence the automatically selected speed.

What is the difference between normal cruise control and adaptive cruise control?

The origins of normal cruise control go back to 1948, when Ralph Teetor invented the speedostat. Having greatly improved since, its focus on throttle control is still central to automation today. One example is automatically pressing the acceleration pedal, which enables drivers to take their foot off the pedal for a few moments when they are on a motorway with low traffic.

In the late 1990s, several carmakers started introducing a new generation of cruise control: adaptive cruise control. This technology relies on front radar to address the biggest limitation traditional cruise control had: the ability to correctly appreciate the speed of the vehicle in front.

This improvement significantly expanded the continuous operation time of the cruise control function, as automation allowed to control both the acceleration and braking of a vehicle. This allowed the driver to travel for longer distances with their feet off the pedal, even in moderate traffic situations on the motorway. Of course, the need for them to pay attention to the road ahead remained, as cars in front could still brake or suddenly cut in.

As drivers are getting more and more comfortable with using ACC while driving, the expectation for an even longer duration of continuous operation time for the system is rising. In turn, this puts pressure for it to be further improved. As new enhancements are made, the market is shifting to a new standard in ACC, called intelligent cruise control.

What use cases are supported by modern adaptive cruise control?

The latest intelligent cruise control systems aim to tackle the entire journey, offloading the driver’s tasks whenever possible. Here are some of the most interesting use cases:

Stop & Go cruise control

This is where Stop & Go cruise control can play a role. Operating similarly to adaptive cruise control on motorways, the difference is in slow-moving traffic, when it automatically stops or starts vehicle movement under driver supervision. The car will brake and accelerate on its own, while maintaining a safe distance from the vehicle in front.

Speed limit-aware cruise control

one of the situations requiring ACC adjustment by the driver is when passing a speed limit sign. However, intelligent cruise control can automatically adjust the set speed to the newly detected speed limit, thanks to input from the traffic sign recognition system. This is done by fusing camera observation and map data to provide reliable speed restriction information

Eco cruise control for fuel and EV capacity savings

When in eco mode, cruise control adjusts the set speed so that the minimum amount of energy – whether electricity or fuel – is consumed during the journey. In a situation where a vehicle would go uphill, the system could drop the speed of the vehicle with 15-20%, in appreciation of the expected downhill speed gain shortly after.

Cruise control in curves

Especially on country roads and junctions, but also on motorways, the driver usually needs to correct the speed set by adaptive cruise control when facing bends and turns.

Using curvature data from the ADAS Map, intelligent cruise control can eliminate human intervention by calculating the safe and comfortable speed for a given road segment. It does so by also considering specific vehicle dynamics.

Turn-by-turn cruise control

One of the most recent advancements in intelligent cruise control technology is the capability to automate acceleration and braking at highway exits, entrances, junctions and roundabouts. Even when a driver corrects the vehicle speed by braking, as soon as the pedal is released, the system resumes its activity and sets the speed according to the upcoming road feature it detects.

Map data is critical to this operation, as the system relies on insights based on traffic signs – stop, yield, traffic lights – and curvature at junction information.

Predictive adaptive cruise control to anticipate road hazards ahead

When there is a road accident, a broken vehicle on the road or severe weather conditions such as icy roads, special caution when driving is required. Intelligent cruise control systems rely on the vehicle’s connectivity to obtain early warnings and adjust speed accordingly. The result is a safer and more comfortable journey for the driver and passengers.

 Parking speed control

The first and the last stage of a car journey with adaptive cruise control is always the same: controlling the speed when maneuvering in a parking or a driveway. To assist the driver in such a scenario, it is imperative to use additional sensing and very low speed.

Currently, many ACC systems under development target not only self-parking, but also maneuvering through large parking lots.

 Dynamic priority cruise control: an emerging technology

The next step for modern adaptive cruise control systems is the ability to perceive and automatically handle changing traffic lights and other vehicles at junctions. Intelligent driving strategies that support this use case include priority negotiation and sensing a rapidly changing situation with high confidence. Of course, the driver can still observe the vehicle’s choices and intervene at any given moment.


Future of adaptive cruise control

The benefits of adaptive cruise control make it a worthwhile technology to continue investing in. It provides longitudinal control of a vehicle, such as acceleration and braking. Increasingly, it can be combined with steering assist technology like lane centering for automated lane changes. The longitudinal and lateral control systems working together leads to autonomous driving, the next mobility revolution, which is expected to evolve rapidly over the next decade.

TomTom creates technologies for a moving world that supports all levels of autonomous driving. To learn more about how the ADAS Map is already powering automated vehicles on the road today, download the product sheet.

  • 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

-

-

 

  1.  To Follow all the MBD related processes: Requirement Tagging & Traceability, SLDD creation, Configuration Parameter changes, Model Advisor check & Code Generation.

General step :

1.  open the matlab window check the current folder conatin the Modelbase_major project folder and open that folder.

2. Then check  correct folder path or not and then open the simulink model file and simulink script file also.

3.Then Goto the model settings then went to solver then chanage the parameters of solver selection type and solver to fixed varible and Discrete solver and then change the Fixed step size to 0.01 click ok. Its shown in below figure.

In modelling settings inside tab select the code generation option and in system target file  browse the  file in embedded coder form i.e(ert.tlc) file as shown below.

  1. In Configuration Parameters: enable “Support Floating Numbers” under Code Generation settings.

after selection the code generation and select the code generation parameter select the interface and in that  select the floating points at shared code placement. 

  • After setting the solver configuration block and create the sldd file by selcting modeling tab and in that window we have to select the link to data dictionary block as shown below.

then create the sldd file as modelbase_majorproect.sldd and with the desired path for particular folder.

After that open the simulink model page and in that goto modelling window and in that select model explorer window enter the  signals and data type , dimensions, complexitiy min and max , storage class values as shown below and save the design data sheet 

 After creating the SLDD file again open the modelling in that open  model explorer window and check the SLDD file is in the extrenal data. 

 To Developing Adaptive Cruise Control feature as per the Requirement Document using MATLAB Simulink.

Simulation model for the Adaptive Cruise Contorl method and along with the  subsystem with their requirements are shown below.

Simulation Model:

    

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.

Sub system of Lead_Vehicle model in its input 1 camerainput_LeadVehicle & input  2 Radarinput_LeadVehicle given to the addition block and the output of the addition block is LeadVehicle _speed as shown below.

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.

in the Drive_Vechile sub system   oneof the input is camerainput_drive Vehicle and second Acceleration_mode and Radarinput_DriveVehcle and which are connected to the add block and output of add block is Drive_Vehicle Speed and radarinput_ DriveVehicle is connected to solver connector and which give the input as same output and then connected the output to ACC_ logic to input as shown below.

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

After ACC_Algoritm model we have to creat the the flow chart sheet in that select the all the chart blocks and write the  condition for each signal and its create the input and output sequence as per the input data as shown below.

after given the input and outport in the chart sampler and the out of flow chart appear as shown below.

Add the coditions to the each block requrirements as per the question.

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<="" em="">

  after assign the command for each block and flow chart as shown below.

After creat the adaptive cruise control model save the model and goto main simulink page in that select model expoler block inthat we have to select the  model advisor tool and in that we have to select the model task. 

in that we have to select the modeling standards of MAB test has been done. 

in this test we are correct and testing model is design as per MAB standards.

after run test we have to keep failed as a 0 and warnings is alos keep  to be less than 10 as possible to check clear the wornings.

then after run the model and check its once and generated the repot in html. file and which is saved in currect path in correct folder and save the file.   

generated report is as shown below.

5. Use Embedded Coder to generate the code.

Open the main model and in that select the App block and in that select Embeded Code opition and in that C Code select build option and after build the code as shown below.  

Generate code:

 
/*
 
 
* Academic License - for use in teaching, academic research, and meeting
 
 
* course requirements at degree granting institutions only. Not for
 
 
* government, commercial, or other organizational use.
 
 
*
 
 
* File: mbdmajor_project.c
 
 
*
 
 
* Code generated for Simulink model 'mbdmajor_project'.
 
 
*
 
 
* Model version : 1.11
 
 
* Simulink Coder version : 9.7 (R2022a) 13-Nov-2021
 
 
* C/C++ source code generated on : Tue Jun 28 13:12:55 2022
 
 
*
 
 
* Target selection: ert.tlc
 
 
* Embedded hardware selection: Intel->x86-64 (Windows64)
 
 
* Code generation objectives: Unspecified
 
 
* Validation result: Not run
 
 
*/
 
 
 
 
 
#include "mbdmajor_project.h"
 
 
#include "rtwtypes.h"
 
 
#include "mbdmajor_project_private.h"
 
 
 
 
 
/* Named constants for Chart: '/ACC_Logic' */
 
 
#define IN_LeadVehicle_Detected_Follow ((uint8_T)1U)
 
 
#define IN_LeadVehicle_Detected_Resume ((uint8_T)2U)
 
 
#define IN_LeadVehicle_Not_Detected_res ((uint8_T)4U)
 
 
#define IN_LeadVehicle_Speed_equal_set_ ((uint8_T)5U)
 
 
#define IN_LeadVehicle_Speed_lessthan_S ((uint8_T)6U)
 
 
#define mbd_IN_LeadVehicle_Not_Detected ((uint8_T)3U)
 
 
#define mbdmajor_pr_IN_ACC_STANDBY_MODE ((uint8_T)3U)
 
 
#define mbdmajor_pro_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
 
 
#define mbdmajor_projec_IN_ACC_OFF_MODE ((uint8_T)1U)
 
 
#define mbdmajor_project_IN_ACC_ON_MODE ((uint8_T)2U)
 
 
 
 
 
/* Exported data definition */
 
 
 
 
 
/* Definition for custom storage class: ExportToFile */
 
 
real_T Acceleration_Mode; /* '/Unit_Delay' */
 
 
real_T DriveVehicle_Speed; /* '/Add' */
 
 
uint8_T LeadVehicle_Speed; /* '/Add' */
 
 
 
 
 
/* Block states (default storage) */
 
 
DW_mbdmajor_project_T mbdmajor_project_DW;
 
 
 
 
 
/* External outputs (root outports fed by signals with default storage) */
 
 
ExtY_mbdmajor_project_T mbdmajor_project_Y;
 
 
 
 
 
/* Real-time model */
 
 
static RT_MODEL_mbdmajor_project_T mbdmajor_project_M_;
 
 
RT_MODEL_mbdmajor_project_T *const mbdmajor_project_M = &mbdmajor_project_M_;
 
 
 
 
 
/* Model step function */
 
 
void mbdmajor_project_step(void)
 
 
{
 
 
/* Sum: '/Add' incorporates:
 
 
* Inport: '/CameraInput_LeadVehicle'
 
 
* Inport: '/RadarInput_LeadVehicle'
 
 
*/
 
 
LeadVehicle_Speed = (uint8_T)(CameraInput_LeadVehicle + RadarInput_LeadVehicle);
 
 
 
 
 
/* UnitDelay: '/Unit_Delay' */
 
 
Acceleration_Mode = mbdmajor_project_Y.Acceleration_Mode_f;
 
 
 
 
 
/* Sum: '/Add' incorporates:
 
 
* Inport: '/CameraInput_DriveVehicle'
 
 
* Inport: '/RadarInput_DriveVehicle'
 
 
*/
 
 
DriveVehicle_Speed = ((real_T)CameraInput_DriveVehicle + Acceleration_Mode) +
 
 
(real_T)RadarInput_DriveVehicle;
 
 
 
 
 
/* Chart: '/ACC_Logic' incorporates:
 
 
* Inport: '/CruiseSwitch'
 
 
* Inport: '/RadarInput_DriveVehicle'
 
 
* Inport: '/SetSwitch'
 
 
* Inport: '/Set_Gap'
 
 
* Inport: '/Set_Speed'
 
 
* Inport: '/Time_Gap'
 
 
* UnitDelay: '/Unit_Delay'
 
 
*/
 
 
if (mbdmajor_project_DW.is_active_c3_mbdmajor_project == 0U) {
 
 
mbdmajor_project_DW.is_active_c3_mbdmajor_project = 1U;
 
 
mbdmajor_project_DW.is_c3_mbdmajor_project = mbdmajor_projec_IN_ACC_OFF_MODE;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 0.0;
 
 
} else {
 
 
switch (mbdmajor_project_DW.is_c3_mbdmajor_project) {
 
 
case mbdmajor_projec_IN_ACC_OFF_MODE:
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 0.0;
 
 
if (CruiseSwitch) {
 
 
mbdmajor_project_DW.is_c3_mbdmajor_project =
 
 
mbdmajor_pr_IN_ACC_STANDBY_MODE;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 1.0;
 
 
}
 
 
break;
 
 
 
 
 
case mbdmajor_project_IN_ACC_ON_MODE:
 
 
if (!CruiseSwitch) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = mbdmajor_pro_IN_NO_ACTIVE_CHILD;
 
 
mbdmajor_project_DW.is_c3_mbdmajor_project =
 
 
mbdmajor_projec_IN_ACC_OFF_MODE;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 0.0;
 
 
} else if (!SetSwitch) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = mbdmajor_pro_IN_NO_ACTIVE_CHILD;
 
 
mbdmajor_project_DW.is_c3_mbdmajor_project =
 
 
mbdmajor_pr_IN_ACC_STANDBY_MODE;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 1.0;
 
 
} else {
 
 
switch (mbdmajor_project_DW.is_ACC_ON_MODE) {
 
 
case IN_LeadVehicle_Detected_Follow:
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 2.0;
 
 
if (RadarInput_DriveVehicle == 0) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = mbd_IN_LeadVehicle_Not_Detected;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 1.0;
 
 
} else if (((RadarInput_DriveVehicle == 1) && (LeadVehicle_Speed <
 
 
Set_Speed)) || (Time_Gap < Set_Gap)) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_lessthan_S;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 4.0;
 
 
}
 
 
break;
 
 
 
 
 
case IN_LeadVehicle_Detected_Resume:
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 3.0;
 
 
if ((RadarInput_DriveVehicle == Set_Speed) && (LeadVehicle_Speed >=
 
 
Set_Speed) && (Time_Gap >= Set_Gap)) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_Follow;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 2.0;
 
 
} else if (RadarInput_DriveVehicle == 0) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = IN_LeadVehicle_Not_Detected_res;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 1.0;
 
 
} else if ((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
 
 
DriveVehicle_Speed) && (Time_Gap >= Set_Gap)) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_equal_set_;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 5.0;
 
 
}
 
 
break;
 
 
 
 
 
case mbd_IN_LeadVehicle_Not_Detected:
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 1.0;
 
 
if ((RadarInput_DriveVehicle == 1) && (DriveVehicle_Speed == Set_Speed)
 
 
&& (LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_Follow;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 2.0;
 
 
} else if (((RadarInput_DriveVehicle == 1) && (LeadVehicle_Speed <
 
 
Set_Speed)) || (Time_Gap < Set_Gap)) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_lessthan_S;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 4.0;
 
 
}
 
 
break;
 
 
 
 
 
case IN_LeadVehicle_Not_Detected_res:
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 1.0;
 
 
break;
 
 
 
 
 
case IN_LeadVehicle_Speed_equal_set_:
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 5.0;
 
 
if (((LeadVehicle_Speed < Set_Speed) && (LeadVehicle_Speed <
 
 
DriveVehicle_Speed)) || (0.75 * (real_T)Set_Gap == Time_Gap)) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_lessthan_S;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 4.0;
 
 
} else if (((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
 
 
DriveVehicle_Speed)) || (Time_Gap >= Set_Gap)) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_Resume;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 3.0;
 
 
} else if ((RadarInput_DriveVehicle == 0) || (DriveVehicle_Speed <=
 
 
Set_Speed)) {
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = IN_LeadVehicle_Not_Detected_res;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 1.0;
 
 
}
 
 
break;
 
 
 
 
 
default:
 
 
/* case IN_LeadVehicle_Speed_lessthan_Set_Speed: */
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 4.0;
 
 
if ((RadarInput_DriveVehicle == 0) && (DriveVehicle_Speed == Set_Speed))
 
 
{
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = mbd_IN_LeadVehicle_Not_Detected;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 1.0;
 
 
} else if (((real_T)LeadVehicle_Speed * 1.25 >= DriveVehicle_Speed) &&
 
 
((real_T)LeadVehicle_Speed * 0.75 <= DriveVehicle_Speed) &&
 
 
(DriveVehicle_Speed < Set_Speed) && ((Time_Gap <= 1.25 *
 
 
(real_T)Set_Gap) && (Time_Gap >= 0.75 * (real_T)Set_Gap)))
 
 
{
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_equal_set_;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 5.0;
 
 
}
 
 
break;
 
 
}
 
 
}
 
 
break;
 
 
 
 
 
default:
 
 
/* case IN_ACC_STANDBY_MODE: */
 
 
if (!CruiseSwitch) {
 
 
mbdmajor_project_DW.is_c3_mbdmajor_project =
 
 
mbdmajor_projec_IN_ACC_OFF_MODE;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 0.0;
 
 
} else {
 
 
mbdmajor_project_DW.is_c3_mbdmajor_project =
 
 
mbdmajor_project_IN_ACC_ON_MODE;
 
 
mbdmajor_project_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_Follow;
 
 
mbdmajor_project_Y.Acceleration_Mode_f = 2.0;
 
 
}
 
 
break;
 
 
}
 
 
}
 
 
 
 
 
/* End of Chart: '/ACC_Logic' */
 
 
}
 
 
 
 
 
/* Model initialize function */
 
 
void mbdmajor_project_initialize(void)
 
 
{
 
 
/* (no initialization code required) */
 
 
}
 
 
 
 
 
/* Model terminate function */
 
 
void mbdmajor_project_terminate(void)
 
 
{
 
 
/* (no terminate code required) */
 
 
}
 
 
 
 
 
/*
 
 
* File trailer for generated code.
 
 
*
 
 
* [EOF]
 
 
*/

6.In Configuration Parameters: enable “Support Floating Numbers” under Code Generation settings.

after selection the code generation and select the code generation parameter select the interface and in that  select the floating points at shared code placement. 

 

conclusion:

  • we are Developing Adaptive Cruise Control feature as per the Requirement Document using MATLAB Simulink.
  •  To Follow all the MBD related processes: Requirement Tagging & Traceability, SLDD creation, Configuration Parameter changes, Model Advisor check & Code Generation has been done .
  • In Configuration Parameters: enable “Support Floating Numbers” under Code Generation settings and set all requiremnts..
  •  By Using  Embedded Coder to generated the code also .
  • In  code generation choosing the  Storage class for Input signals as : ImportedExtern; Storage class for Output signal as: Export to File; Storage class for local signals as: localizable; Storage class for calibration signals as: Const.
  • Choose sample time for all signals as 0.01s.

results for the ACC control model are attached with necessary documents and reports and files are attached below.

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.

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.