Challenge

Project 2 Adaptive Cruise Control

Main Project – Adaptive Cruise Control (ACC)

Aim:

To Create a Simulink Data Dictionary ,develop an algorithm for Adaptive Cruise Control and generate a C code for it using Simulink.

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

Adaptive Cruise Control:

Adaptive Cruise Control (ACC) is an automotive feature that allows a vehicle's cruise control system to adapt the vehicle's speed to the traffic environment. A radar system attached to the front of the vehicle is used to detect whether slower moving vehicles are in the ACC vehicle's path. If a slower moving vehicle is detected, the ACC system will slow the vehicle down and control the clearance, or time gap, between the ACC vehicle and the forward vehicle. If the system detects that the forward vehicle is no longer in the ACC vehicle's path, the ACC system will accelerate the vehicle back to its set cruise control speed. This operation allows the ACC vehicle to autonomously slow down and speed up with traffic without intervention from the driver. The method by which the ACC vehicle's speed is controlled is via engine throttle control and limited brake operation.

General Overview:

Adaptive Cruise Control Feature for passenger cars allows the host vehicle to adapt to the speed in line with the flow of traffic. Driving in heavy traffic or keeping a safe distance to the preceding vehicle calls for a high level of concentration. The Adaptive Cruise Control feature can reduce the stress on the driver by automatically controlling the vehicle speed & maintaining a predefined minimum distance to the preceding vehicle. As a consequence, the driver enjoys more comfort & can concentrate on the road little better.

A radar sensor is usually at the core of the Adaptive Cruise Control. Installed at the front of the vehicle, the system permanently monitors the road ahead. As long as the road ahead is clear, cruise control feature maintains the speed set by the driver. If the system spots a slower vehicle within its detection range, it gently reduces speed by releasing the accelerator or actively engaging the brake control system. If the vehicle ahead speeds up or changes lanes, the cruise control automatically accelerates to the driver’s desired speed.

Standard Adaptive Cruise Control can be activated from speeds of around 30 km/h (20 mph) upwards and supports the driver, primarily on cross-country journeys or on freeways. The cruise control stop & go variant is also active at speeds below 30 km/h (20 mph). It can maintain the set distance to the preceding vehicle even at very low speeds and can decelerate to a complete standstill. When the vehicle remains stopped longer, the driver needs only to reactivate the system, for example by briefly stepping on the gas pedal to return to cruise control mode. In this way, cruise control stop & go supports the driver even in heavy traffic and traffic jams.

Since Adaptive Cruise Control is a comfort and convenience system, brake interventions and vehicle acceleration only take place within defined limits. Even with Adaptive Cruise Control switched on, it remains the driver’s responsibility to monitor the speed and distance from the vehicle in front.

  • Types of Adaptive Cruise control:

Radar-Based Systems:

According to eInfoChips, radar-based systems work by placing radar-based sensors on or around plastic fascias to detect your vehicle's surroundings. Each radar sensor works together to create a comprehensive picture of the vehicle's proximity to other cars or potentially hazardous objects. This type of sensor can look different depending on the design and model of the car.

Laser-Based Systems:

As mentioned by Electronic Design, this type of ACC system operates out of a large black box typically placed in the grille of your vehicle. It uses laser technology to detect the proximity of objects to your car. It does not operate well during rainstorms and other weather conditions.

Binocular Computer Vision Systems:

According to ExtremeTech, this is a relatively new ACC system put into use in 2013. It uses small cameras that are placed on the back of a vehicle's rearview mirror to detect front-facing objects.

Assisting Systems:

Assisting systems are radar-based add-ons that customers can buy together. These pre-crash systems can offer lane control, brake assistance, cruise control, proximity alerts to objects like corners, and steering power.

Multi-Sensor Systems:

According to Fierce Electronics, adaptive cruise control systems sometimes integrate more than one type of sensor to aid in a vehicle's operation. Multi-sensor systems incorporate several different sensor types to provide a driver with advanced information. These sensors might include GPS data equipment or cameras to gather information about a vehicle's geographic environment and proximity to other cars.

Predictive Systems:

As mentioned by Autoblog, prediction systems are a type of ACC that uses sensory data to predict the actions of neighboring vehicles. This means that your car might slow down to brace for another vehicle suddenly switching lanes and, in doing so, promotes passenger safety.

Adaptive cruise control is evolving each year. Car companies are continuously making adjustments to this technology and, in doing so, creating more common and affordable options that can be purchased with a new car or added to older car models, making driving safer for everyday people.

Adavantages and Limits:

  • Advantages of Adaptive Cruise Control:
  • Some key advantages of adaptive cruise control mentioned by MyCarDoesWhat.org include an increase in road safety, as cars with this technology will keep the adequate spacing between them and other vehicles. These space-mindful features will also help prevent accidents that result from an obstructed view or close following distance. Similarly, ACC will help maximize traffic flow because of its spatial awareness. As a driver, you don't have to worry about your speed, and instead, you can focus on what is going on around you.
  • Limitation of Adaptive Cruise Control:
  • Although there are many advantages to adaptive cruise control, there are still limitations to consider. One of the main faults in this system is the fact that it is not entirely autonomous. The driver of the vehicle still needs to practice safe driving habits that will work in tandem with this technology to produce the best results. Similarly, adverse weather conditions like snow, rain, or fog might confuse the system's sensors, as well as environmental factors such as driving through tunnels.

Adaptive Cruise Control:

Subsystem:

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.

Chart:

ACC OFF MODE AND STAND BY STATE LOGIC:

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

Requirement 3c (i) – LeadVehicle_Detected_Follow (ACC ON MODE):

  • This is the default sub state inside ACC ON MODE state. Output signal Acceleration_Mode is equal to 2.
  • Condition to transit from LeadVehicle_Detected_Follow to LeadVehicle_Not_Detected; Input signal condition LeadVehicle_Detected == 0.
  • Condition to transit from LeadVehicle_Detected_Follow to LeadVehicle_Speed_lessthan_Set_Speed; Input Signals condition (LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed) || (Time_Gap < Set_Gap).

Requirement 3c (ii) – LeadVehicle_Not_Detected (ACC ON MODE):

  • Output signal Acceleration_Mode is equal to 1.
  • Condition to transit from LeadVehicle_Not_Detected to LeadVehicle_Detected_Follow; Input signals condition [(LeadVehicle_Detected==1) && (DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)]
  • Condition to transit from LeadVehicle_Not_Detected to LeadVehicle_Speed_lessthan_Set_Speed; Input signals condition [(LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed) || (Time_Gap < Set_Gap)]

Requirement 3c (iii) – LeadVehicle_Detected_Resume (ACC ON MODE):

  • Output signal Acceleration_Mode is equal to 3.
  • Condition to transit from LeadVehicle_Detected_Resume to LeadVehicle_Detected_Follow; Input signals condition [(DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)]
  • Condition to transit from LeadVehicle_Detected_Resume to LeadVehicle_Not_Detected_Resume; Input signal condition LeadVehicle_Detected==0.
  • Condition to transit from LeadVehicle_Detected_Resume to LeadVehicle_Speed_equal_Set_Speed; Input Signal condition [(DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed > DriveVehicle_Speed) && (Time_Gap >= Set_Gap)]

Requirement 3c (iv) - LeadVehicle_Not_Detected_Resume (ACC ON MODE):

  • Output signal Acceleration_Mode is equal to 1.

Requirement 3c (v) - LeadVehicle_Speed_lessthan_Set_Speed (ACC ON MODE):

  • Output signal Acceleration_Mode is equal to 4.
  • Condition to transit from LeadVehicle_Speed_lessthan_Set_Speed to LeadVehicle_Not_Detected; Input signal condition [(LeadVehicle_Detected == 0) && (DriveVehicle_Speed == Set_Speed)]
  • Condition to transit from LeadVehicle_Speed_lessthan_Set_Speed to LeadVehicle_Speed_equal_Set_Speed; Input signals condition [((LeadVehicle_Speed*1.25>=DriveVehicle_Speed) && (LeadVehicle_Speed * 0.75<=DriveVehicle_Speed)) && (DriveVehicle_Speed < Set_Speed) && ((Time_Gap<=1.25*Set_Gap) && (Time_Gap >=0.75*Set_Gap))]

Requirement 3c (vi) - LeadVehicle_Speed_equal_Set_Speed (ACC ON MODE):

  • Output signal Acceleration_Mode is equal to 5.
  • Condition to transit from LeadVehicle_Speed_equal_Set_Speed to LeadVehicle_Not_Detected_Resume; Input signal conditions is [(LeadVehicle_Detected == 0) || (DriveVehicle_Speed <= Set_Speed)]
  • Condition to transit from LeadVehicle_Speed_equal_Set_Speed to LeadVehicle_Detected_Resume; Input signal conditions [(DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed > DriveVehicle_Speed) || (Time_Gap >= Set_Gap)]
  • Condition to transit from LeadVehicle_Speed_equal_Set_Speed to LeadVehicle_Speed_lessthan_Set_Speed; Input signals conditions [(LeadVehicle_Speed<set_speed) &&="" (leadvehicle_speed<drivevehicle_speed)="" ||="" (time_gap="=0.75*Set_Gap)]</em"></set_speed)>

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

-

-

SLDD File:

Requirements in excel

Code Generation:

File: ADAS_ACC_PROJECT.c

1 /*
2 * File: ADAS_ACC_PROJECT.c
3 *
4 * Code generated for Simulink model 'ADAS_ACC_PROJECT'.
5 *
6 * Model version : 1.8
7 * Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
8 * C/C++ source code generated on : Tue Jan 18 18:59:50 2022
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives: Unspecified
13 * Validation result: Not run
14 */
15
16 #include "ADAS_ACC_PROJECT.h"
17 #include "ADAS_ACC_PROJECT_private.h"
18
19 /* Named constants for Chart: '/Chart' */
20 #define ADAS_ACC_PROJECT_IN_ACC_ON_MODE ((uint8_T)2U)
21 #define ADAS_ACC_PROJEC_IN_ACC_OFF_MODE ((uint8_T)1U)
22 #define ADAS_ACC_PRO_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
23 #define ADAS_ACC_PR_IN_ACC_STANDBY_MODE ((uint8_T)3U)
24 #define ADAS__IN_LeadVehicle_Not_Resume ((uint8_T)4U)
25 #define ADA_IN_LeadVehicle_Not_Detected ((uint8_T)2U)
26 #define IN_LeadVehicle_Detected_Follow ((uint8_T)1U)
27 #define IN_LeadVehicle_Not_Detected_Res ((uint8_T)3U)
28 #define IN_LeadVehicle_Speed_equal_Set_ ((uint8_T)5U)
29 #define IN_LeadVehicle_Speed_lessthan_S ((uint8_T)6U)
30
31 /* Exported data definition */
32
33 /* Definition for custom storage class: ExportToFile */
34 uint8_T Acceleration_Mode; /* '/Unit Delay' */
35
36 /* Block states (default storage) */
37 DW_ADAS_ACC_PROJECT_T ADAS_ACC_PROJECT_DW;
38
39 /* External outputs (root outports fed by signals with default storage) */
40 ExtY_ADAS_ACC_PROJECT_T ADAS_ACC_PROJECT_Y;
41
42 /* Real-time model */
43 static RT_MODEL_ADAS_ACC_PROJECT_T ADAS_ACC_PROJECT_M_;
44 RT_MODEL_ADAS_ACC_PROJECT_T *const ADAS_ACC_PROJECT_M = &ADAS_ACC_PROJECT_M_;
45 real_T rt_roundd_snf(real_T u)
46 {
47 real_T y;
48 if (fabs(u) < 4.503599627370496E+15) {
49 if (u >= 0.5) {
50 y = floor(u + 0.5);
51 } else if (u > -0.5) {
52 y = u * 0.0;
53 } else {
54 y = ceil(u - 0.5);
55 }
56 } else {
57 y = u;
58 }
59
60 return y;
61 }
62
63 /* Model step function */
64 void ADAS_ACC_PROJECT_step(void)
65 {
66 /* local block i/o variables */
67 uint8_T LeadVehicle_Speed;
68 uint8_T DriveVehicle_Speed;
69 uint8_T LeadVehicle_Detected;
70 int32_T tmp;
71 int32_T tmp_0;
72 uint8_T tmp_1;
73 uint8_T tmp_2;
74
75 /* Outputs for Atomic SubSystem: '/Adaptive_Cruise_Control' */
76 /* Sum: '/Add' incorporates:
77 * Inport: '/CameraInput_LeadVehicle'
78 * Inport: '/RadarInput_LeadVehicle'
79 */
80 LeadVehicle_Speed = (uint8_T)((uint32_T)CameraInput_LeadVehicle +
81 RadarInput_LeadVehicle);
82
83 /* UnitDelay: '/Unit Delay' */
84 Acceleration_Mode = ADAS_ACC_PROJECT_Y.Acceleration_Mode_g;
85
86 /* Sum: '/Add' incorporates:
87 * Inport: '/CameraInput_DriveVehicle'
88 * Inport: '/RadarInput_DriveVehicle'
89 */
90 DriveVehicle_Speed = (uint8_T)((uint32_T)(uint8_T)((uint32_T)
91 CameraInput_DriveVehicle + Acceleration_Mode) + RadarInput_DriveVehicle);
92
93 /* SignalConversion: '/Signal Conversion' incorporates:
94 * Inport: '/RadarInput_DriveVehicle'
95 */
96 LeadVehicle_Detected = RadarInput_DriveVehicle;
97
98 /* Chart: '/Chart' incorporates:
99 * Inport: '/CruiseSwitch'
100 * Inport: '/SetSwitch'
101 * Inport: '/Set_Gap'
102 * Inport: '/Set_Speed'
103 * Inport: '/Time_Gap'
104 * UnitDelay: '/Unit Delay'
105 */
106 if (ADAS_ACC_PROJECT_DW.is_active_c3_ADAS_ACC_PROJECT == 0U) {
107 ADAS_ACC_PROJECT_DW.is_active_c3_ADAS_ACC_PROJECT = 1U;
108 ADAS_ACC_PROJECT_DW.is_c3_ADAS_ACC_PROJECT = ADAS_ACC_PROJEC_IN_ACC_OFF_MODE;
109 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 0U;
110 } else {
111 switch (ADAS_ACC_PROJECT_DW.is_c3_ADAS_ACC_PROJECT) {
112 case ADAS_ACC_PROJEC_IN_ACC_OFF_MODE:
113 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 0U;
114 if (CruiseSwitch) {
115 ADAS_ACC_PROJECT_DW.is_c3_ADAS_ACC_PROJECT =
116 ADAS_ACC_PR_IN_ACC_STANDBY_MODE;
117 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 1U;
118 }
119 break;
120
121 case ADAS_ACC_PROJECT_IN_ACC_ON_MODE:
122 if (!CruiseSwitch) {
123 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = ADAS_ACC_PRO_IN_NO_ACTIVE_CHILD;
124 ADAS_ACC_PROJECT_DW.is_c3_ADAS_ACC_PROJECT =
125 ADAS_ACC_PROJEC_IN_ACC_OFF_MODE;
126 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 0U;
127 } else if (!SetSwitch) {
128 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = ADAS_ACC_PRO_IN_NO_ACTIVE_CHILD;
129 ADAS_ACC_PROJECT_DW.is_c3_ADAS_ACC_PROJECT =
130 ADAS_ACC_PR_IN_ACC_STANDBY_MODE;
131 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 1U;
132 } else {
133 switch (ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE) {
134 case IN_LeadVehicle_Detected_Follow:
135 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 2U;
136 if (LeadVehicle_Detected == 0) {
137 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = ADA_IN_LeadVehicle_Not_Detected;
138 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 2U;
139 } else if (((LeadVehicle_Detected == 1) && (LeadVehicle_Speed <
140 Set_Speed)) || (Time_Gap < Set_Gap)) {
141 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_lessthan_S;
142 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 4U;
143 }
144 break;
145
146 case ADA_IN_LeadVehicle_Not_Detected:
147 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 2U;
148 if ((LeadVehicle_Detected == 1) && (DriveVehicle_Speed == Set_Speed) &&
149 (LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)) {
150 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_Follow;
151 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 2U;
152 } else if (((LeadVehicle_Detected == 1) && (LeadVehicle_Speed <
153 Set_Speed)) || (Time_Gap < Set_Gap)) {
154 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_lessthan_S;
155 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 4U;
156 }
157 break;
158
159 case IN_LeadVehicle_Not_Detected_Res:
160 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 1U;
161 break;
162
163 case ADAS__IN_LeadVehicle_Not_Resume:
164 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 3U;
165 if ((DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >=
166 Set_Speed) && (Time_Gap >= Set_Gap)) {
167 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_Follow;
168 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 2U;
169 } else if (LeadVehicle_Detected == 0) {
170 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = IN_LeadVehicle_Not_Detected_Res;
171 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 1U;
172 } else if ((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
173 DriveVehicle_Speed) && (Time_Gap >= Set_Gap)) {
174 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_equal_Set_;
175 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 5U;
176 }
177 break;
178
179 case IN_LeadVehicle_Speed_equal_Set_:
180 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 5U;
181 if ((LeadVehicle_Detected == 0) || (DriveVehicle_Speed <= Set_Speed))
182 {
183 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = IN_LeadVehicle_Not_Detected_Res;
184 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 1U;
185 } else if (((LeadVehicle_Speed < Set_Speed) && (LeadVehicle_Speed <
186 DriveVehicle_Speed)) || ((int32_T)rt_roundd_snf(0.75 *
187 (real_T)Set_Gap) == Time_Gap)) {
188 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_lessthan_S;
189 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 4U;
190 } else if (((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
191 DriveVehicle_Speed)) || (Time_Gap >= Set_Gap)) {
192 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = ADAS__IN_LeadVehicle_Not_Resume;
193 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 3U;
194 }
195 break;
196
197 default:
198 /* case IN_LeadVehicle_Speed_lessthan_Set_Speed: */
199 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 4U;
200 tmp = (int32_T)rt_roundd_snf((real_T)LeadVehicle_Speed * 1.25);
201 tmp_0 = (int32_T)rt_roundd_snf(1.25 * (real_T)Set_Gap);
202 if (tmp < 256) {
203 tmp_1 = (uint8_T)tmp;
204 } else {
205 tmp_1 = MAX_uint8_T;
206 }
207
208 if (tmp_0 < 256) {
209 tmp_2 = (uint8_T)tmp_0;
210 } else {
211 tmp_2 = MAX_uint8_T;
212 }
213
214 if ((tmp_1 >= DriveVehicle_Speed) && ((int32_T)rt_roundd_snf((real_T)
215 LeadVehicle_Speed * 0.75) <= DriveVehicle_Speed) &&
216 (DriveVehicle_Speed < Set_Speed) && (Time_Gap <= tmp_2) &&
217 (Time_Gap >= (int32_T)rt_roundd_snf(0.75 * (real_T)Set_Gap))) {
218 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = IN_LeadVehicle_Speed_equal_Set_;
219 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 5U;
220 } else if ((LeadVehicle_Detected == 1) && (DriveVehicle_Speed ==
221 Set_Speed)) {
222 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = ADA_IN_LeadVehicle_Not_Detected;
223 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 2U;
224 }
225 break;
226 }
227 }
228 break;
229
230 default:
231 /* case IN_ACC_STANDBY_MODE: */
232 if (CruiseSwitch) {
233 ADAS_ACC_PROJECT_DW.is_c3_ADAS_ACC_PROJECT =
234 ADAS_ACC_PROJECT_IN_ACC_ON_MODE;
235 ADAS_ACC_PROJECT_DW.is_ACC_ON_MODE = IN_LeadVehicle_Detected_Follow;
236 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 2U;
237 } else {
238 ADAS_ACC_PROJECT_DW.is_c3_ADAS_ACC_PROJECT =
239 ADAS_ACC_PROJEC_IN_ACC_OFF_MODE;
240 ADAS_ACC_PROJECT_Y.Acceleration_Mode_g = 0U;
241 }
242 break;
243 }
244 }
245
246 /* End of Chart: '/Chart' */
247 /* End of Outputs for SubSystem: '/Adaptive_Cruise_Control' */
248 }
249
250 /* Model initialize function */
251 void ADAS_ACC_PROJECT_initialize(void)
252 {
253 /* (no initialization code required) */
254 }
255
256 /* Model terminate function */
257 void ADAS_ACC_PROJECT_terminate(void)
258 {
259 /* (no terminate code required) */
260 }
261
262 /*
263 * File trailer for generated code.
264 *
265 * [EOF]
266 */
267

Steps Followed for code generation:

  1. Right_click on the subsystem
  2. Select block parameters
  3. Then checkmark on the treat as atomic size
  4. Then go to the model explorer settings
  5. Configure the solver to fixed and the change code generation to ert.tlc
  6. Then go to the app embedded coder
  7. Then in the build option select generation code

Model Advisor:

Conclusion

Thus a Simulink Data Dictionary file has been created, an algorithm for Adaptive Cruise Control has been made ,and the C code for the model has been generated using Simulink Satisfactorily.

REFERENCES:


1. https://www.slideshare.net/naveenkumar1128/adaptive-cruise-control-automobile-black-box-team-code-chef-pes-university-78222426


2. Gennaro Nicola Bifulco et al. (2011), Development and testing of fully Adaptive Cruise Control system


3.https://www.researchgate.net/figure/The-control-architecture-of-the-ACC-system-ACC-adaptive-cruise-control_fig1_327584473.


4. Giulio Francesco Bianchi Piccinini et al. (2014), Driver's behavioral adaptation to Adaptive Cruise Control (ACC): The case of speed
and time headway


5. https://www.ijser.org/researchpaper/Adaptive-Cruise-Control-Towards-a-Safer-Driving-Experience.pdf


6. Paul John King et al. (2000), Adaptive cruise control system


7. Sankar V.: Review on adaptive cruise control in automobiles. International Journal of Mechanical and Robotics Research, vol. 3, no. 2,
pp. 405-409, 2014


8. www.howstuffworks.com


9. Advanced High Speed Black Box Based Vehicle Crash Investigation System :A. Abarnaa, Subramaniam Harish, S. Sreejith (2019

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.