Challenge

Project 2 Adaptive Cruise Control

Adaptive Cruise Control- Model Based Development

Adaptive cruise control:-

Adaptive cruise control (ACC) is a system designed to help vehicles maintain a safe following distance and stay within the speed limit. This system adjusts a car's speed automatically so drivers don't have to.

ACC functions by sensory technology installed within vehicles such as cameras, lasers, and radar equipment, which creates an idea of how close one car is to another, or other objects on the roadway. For this reason, ACC is the basis for future car intelligence.

These sensory technologies allow the car to detect and warn the driver about potential forward collisions. When this happens, red lights begin to flash, and the phrase 'brake now!' appears on the dashboard to help the driver slow down. There might also be an audible warning.

Overview of the project:-

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.

Aim for the 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

Project Description:-

Provided Requirements:-

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

All these requirements were encoded with the state flow and it will appear as follows:-

FINAL SIMULINK MODEL:-

SUBSYSTEM:-

ADAPTIVE CRUISE CONTROL ALGORITHM:-

STATE FLOW LOGIC:-

And hence, the simulink model is created for all the given requirements and the model is sucessfully updated by giving ctrl+D command.

Requirement Tagging:-

Now the next process is to tag all the requirements to the respective model and that can be achieved by Right click ---> Requirements ---> Link selection to word and hence the respective requirements were tagged to the corresponding subsystems or blocks.

Creating SLDD:-

Then, the Data dictionary has been created for all of the signals and parameters by Modelling ---> Link to Data Dictionary. And there all the details like Data type, Dimensions, Min and Max values and the sample time are updated accoringly.

SLDD FOR THE SUBSYSTEM:-

Model Advisory Report:-

The next step is to generate the Model advisory report. Before generating it, some of the configration settings were done on the Model settings tool. And specifically in our project Configuration Parameters: enable “Support Floating Numbers” has been asked and along with different model settings, this is also done.

Now to generate the model advisor report choose, Apps ---> Model advisor is chosen.

Then the Model advisor diaglog box will appear and then choose the entire model name for model check.

And then in the dialog box select the tasks which you want to go for the check. In this project, I have chosen only MAAB guidelines for the advisory check. But depending upon our project we can go for our required checks and after selecting the guideline click on ' Run the selected checks '. And hence the checks will be done and our results will be displayed as follows:-

After the process, 'Generate Report' command is given to generate the advisory report as follows:-

Note:- The model advisory report is attached with the answer box

CODE GENERATION:-

The final step of the project is to develop the C- code.This is done by giving the command, Apps ---> Embbedded coder ---> Build ---> Generate code and build model. And hence the C code is generated and stored for the model sucessfully.

C- Code:-

File: project2_final.c

1	/*
2	 * File: project2_final.c
3	 *
4	 * Code generated for Simulink model 'project2_final'.
5	 *
6	 * Model version                  : 1.13
7	 * Simulink Coder version         : 9.2 (R2019b) 18-Jul-2019
8	 * C/C++ source code generated on : Tue Oct 11 14:17:34 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 "project2_final.h"
17	#include "project2_final_private.h"
18	
19	/* Named constants for Chart: '/AdaptiveCruiseControlAlgorithm' */
20	#define IN_LeadVehicle_Detected_Follow ((uint8_T)1U)
21	#define IN_LeadVehicle_Detected_Resume ((uint8_T)2U)
22	#define IN_LeadVehicle_Not_Detected_Res ((uint8_T)4U)
23	#define IN_LeadVehicle_Speed_equal_Set_ ((uint8_T)5U)
24	#define IN_LeadVehicle_Speed_lessthan_S ((uint8_T)6U)
25	#define pro_IN_LeadVehicle_Not_Detected ((uint8_T)3U)
26	#define project2_fin_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
27	#define project2_final_IN_OFF_Mode     ((uint8_T)1U)
28	#define project2_final_IN_ON_Mode      ((uint8_T)2U)
29	#define project2_final_IN_STANDBY_Mode ((uint8_T)3U)
30	
31	/* Exported data definition */
32	
33	/* Definition for custom storage class: ExportToFile */
34	uint8_T Acceleration_Mode;           /* '/AdaptiveCruiseControlAlgorithm' */
35	
36	/* Definition for custom storage class: Localizable */
37	static uint8_T DriveVehicle_Speed;     /* '/Add' */
38	static uint8_T LeadVehicle_Detected;   /* '/Signal Conversion' */
39	static uint8_T LeadVehicle_Speed;      /* '/Add' */
40	
41	/* Block states (default storage) */
42	DW_project2_final_T project2_final_DW;
43	
44	/* Real-time model */
45	RT_MODEL_project2_final_T project2_final_M_;
46	RT_MODEL_project2_final_T *const project2_final_M = &project2_final_M_;
47	
48	/* Forward declaration for local functions */
49	static void project2_final_ON_Mode(void);
50	real_T rt_roundd_snf(real_T u)
51	{
52	  real_T y;
53	  if (fabs(u) < 4.503599627370496E+15) {
54	    if (u >= 0.5) {
55	      y = floor(u + 0.5);
56	    } else if (u > -0.5) {
57	      y = u * 0.0;
58	    } else {
59	      y = ceil(u - 0.5);
60	    }
61	  } else {
62	    y = u;
63	  }
64	
65	  return y;
66	}
67	
68	/* Function for Chart: '/AdaptiveCruiseControlAlgorithm' */
69	static void project2_final_ON_Mode(void)
70	{
71	  int32_T tmp;
72	  int32_T tmp_0;
73	  uint8_T tmp_1;
74	  uint8_T tmp_2;
75	  boolean_T guard1 = false;
76	
77	  /* Inport: '/CruiseSwitch' incorporates:
78	   *  Inport: '/SetSwitch'
79	   */
80	  if (!CruiseSwitch) {
81	    project2_final_DW.is_ON_Mode = project2_fin_IN_NO_ACTIVE_CHILD;
82	    project2_final_DW.is_c3_project2_final = project2_final_IN_OFF_Mode;
83	    Acceleration_Mode = 0U;
84	  } else if (!SetSwitch) {
85	    project2_final_DW.is_ON_Mode = project2_fin_IN_NO_ACTIVE_CHILD;
86	    project2_final_DW.is_c3_project2_final = project2_final_IN_STANDBY_Mode;
87	    Acceleration_Mode = 1U;
88	  } else {
89	    guard1 = false;
90	    switch (project2_final_DW.is_ON_Mode) {
91	     case IN_LeadVehicle_Detected_Follow:
92	      Acceleration_Mode = 2U;
93	      if (LeadVehicle_Detected == 0) {
94	        project2_final_DW.is_ON_Mode = pro_IN_LeadVehicle_Not_Detected;
95	        Acceleration_Mode = 1U;
96	      }
97	      break;
98	
99	     case IN_LeadVehicle_Detected_Resume:
100	      Acceleration_Mode = 3U;
101	
102	      /* Inport: '/Set_Speed' incorporates:
103	       *  Inport: '/Set_Gap'
104	       *  Inport: '/Time_Gap'
105	       */
106	      if ((DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >= Set_Speed) &&
107	          (Time_Gap >= Set_Gap)) {
108	        project2_final_DW.is_ON_Mode = IN_LeadVehicle_Detected_Follow;
109	        Acceleration_Mode = 2U;
110	      } else if (LeadVehicle_Detected == 0) {
111	        project2_final_DW.is_ON_Mode = IN_LeadVehicle_Not_Detected_Res;
112	        Acceleration_Mode = 1U;
113	      } else {
114	        if ((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
115	             DriveVehicle_Speed) && (Time_Gap >= Set_Gap)) {
116	          project2_final_DW.is_ON_Mode = IN_LeadVehicle_Speed_equal_Set_;
117	          Acceleration_Mode = 5U;
118	        }
119	      }
120	      break;
121	
122	     case pro_IN_LeadVehicle_Not_Detected:
123	      Acceleration_Mode = 1U;
124	      if (((LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed)) ||
125	          (Time_Gap < Set_Gap)) {
126	        guard1 = true;
127	      } else if ((LeadVehicle_Detected == 1) && (DriveVehicle_Speed == Set_Speed)
128	                 && (LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)) {
129	        project2_final_DW.is_ON_Mode = IN_LeadVehicle_Detected_Follow;
130	        Acceleration_Mode = 2U;
131	      } else {
132	        if (((LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed)) ||
133	            (Time_Gap < Set_Gap)) {
134	          guard1 = true;
135	        }
136	      }
137	      break;
138	
139	     case IN_LeadVehicle_Not_Detected_Res:
140	      Acceleration_Mode = 1U;
141	      break;
142	
143	     case IN_LeadVehicle_Speed_equal_Set_:
144	      Acceleration_Mode = 5U;
145	
146	      /* Inport: '/Set_Speed' incorporates:
147	       *  Inport: '/Set_Gap'
148	       *  Inport: '/Time_Gap'
149	       */
150	      if ((LeadVehicle_Detected == 0) || (DriveVehicle_Speed <= Set_Speed)) {
151	        project2_final_DW.is_ON_Mode = IN_LeadVehicle_Not_Detected_Res;
152	        Acceleration_Mode = 1U;
153	      } else if (((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >
154	                   DriveVehicle_Speed)) || (Time_Gap >= Set_Gap)) {
155	        project2_final_DW.is_ON_Mode = IN_LeadVehicle_Detected_Resume;
156	        Acceleration_Mode = 3U;
157	      } else {
158	        if (((LeadVehicle_Speed < Set_Speed) && (LeadVehicle_Speed <
159	              DriveVehicle_Speed)) || ((int32_T)rt_roundd_snf(0.75 * (real_T)
160	              Set_Gap) == Time_Gap)) {
161	          project2_final_DW.is_ON_Mode = IN_LeadVehicle_Speed_lessthan_S;
162	          Acceleration_Mode = 4U;
163	        }
164	      }
165	      break;
166	
167	     default:
168	      /* case IN_LeadVehicle_Speed_lessthan_Set_Speed: */
169	      Acceleration_Mode = 4U;
170	
171	      /* Inport: '/Set_Speed' */
172	      if ((LeadVehicle_Detected == 0) && (DriveVehicle_Speed == Set_Speed)) {
173	        project2_final_DW.is_ON_Mode = pro_IN_LeadVehicle_Not_Detected;
174	        Acceleration_Mode = 1U;
175	      } else {
176	        tmp = (int32_T)rt_roundd_snf((real_T)LeadVehicle_Speed * 1.25);
177	
178	        /* Inport: '/Set_Gap' */
179	        tmp_0 = (int32_T)rt_roundd_snf(1.25 * (real_T)Set_Gap);
180	        if (tmp < 256) {
181	          tmp_1 = (uint8_T)tmp;
182	        } else {
183	          tmp_1 = MAX_uint8_T;
184	        }
185	
186	        if (tmp_0 < 256) {
187	          tmp_2 = (uint8_T)tmp_0;
188	        } else {
189	          tmp_2 = MAX_uint8_T;
190	        }
191	
192	        /* Inport: '/Time_Gap' incorporates:
193	         *  Inport: '/Set_Gap'
194	         */
195	        if ((tmp_1 >= DriveVehicle_Speed) && ((int32_T)rt_roundd_snf((real_T)
196	              LeadVehicle_Speed * 0.75) <= DriveVehicle_Speed) &&
197	            (DriveVehicle_Speed < Set_Speed) && (Time_Gap <= tmp_2) && (Time_Gap
198	             >= (int32_T)rt_roundd_snf(0.75 * (real_T)Set_Gap))) {
199	          project2_final_DW.is_ON_Mode = IN_LeadVehicle_Speed_equal_Set_;
200	          Acceleration_Mode = 5U;
201	        }
202	      }
203	      break;
204	    }
205	
206	    if (guard1) {
207	      project2_final_DW.is_ON_Mode = IN_LeadVehicle_Speed_lessthan_S;
208	      Acceleration_Mode = 4U;
209	    }
210	  }
211	
212	  /* End of Inport: '/CruiseSwitch' */
213	}
214	
215	/* Model step function */
216	void project2_final_step(void)
217	{
218	  /* Sum: '/Add' incorporates:
219	   *  Inport: '/CameraInput_LeadVehicle '
220	   *  Inport: '/RadarInput_LeadVehicle'
221	   */
222	  LeadVehicle_Speed = (uint8_T)((uint32_T)CameraInput_LeadVehicle +
223	    RadarInput_LeadVehicle);
224	
225	  /* Sum: '/Add' incorporates:
226	   *  Inport: '/CameraInput_DriveVehicle'
227	   *  Inport: '/RadarInput_DriveVehicle'
228	   *  UnitDelay: '/Unit Delay'
229	   */
230	  DriveVehicle_Speed = (uint8_T)((uint32_T)(uint8_T)((uint32_T)
231	    CameraInput_DriveVehicle + project2_final_DW.UnitDelay_DSTATE) +
232	    RadarInput_DriveVehicle);
233	
234	  /* SignalConversion: '/Signal Conversion' incorporates:
235	   *  Inport: '/RadarInput_DriveVehicle'
236	   */
237	  LeadVehicle_Detected = RadarInput_DriveVehicle;
238	
239	  /* Chart: '/AdaptiveCruiseControlAlgorithm' incorporates:
240	   *  Inport: '/CruiseSwitch'
241	   *  Inport: '/SetSwitch'
242	   */
243	  if (project2_final_DW.is_active_c3_project2_final == 0U) {
244	    project2_final_DW.is_active_c3_project2_final = 1U;
245	    project2_final_DW.is_c3_project2_final = project2_final_IN_OFF_Mode;
246	    Acceleration_Mode = 0U;
247	  } else {
248	    switch (project2_final_DW.is_c3_project2_final) {
249	     case project2_final_IN_OFF_Mode:
250	      Acceleration_Mode = 0U;
251	      if (CruiseSwitch) {
252	        project2_final_DW.is_c3_project2_final = project2_final_IN_STANDBY_Mode;
253	        Acceleration_Mode = 1U;
254	      }
255	      break;
256	
257	     case project2_final_IN_ON_Mode:
258	      project2_final_ON_Mode();
259	      break;
260	
261	     default:
262	      /* case IN_STANDBY_Mode: */
263	      Acceleration_Mode = 1U;
264	      if (!CruiseSwitch) {
265	        project2_final_DW.is_c3_project2_final = project2_final_IN_OFF_Mode;
266	        Acceleration_Mode = 0U;
267	      } else {
268	        if (SetSwitch) {
269	          project2_final_DW.is_c3_project2_final = project2_final_IN_ON_Mode;
270	          project2_final_DW.is_ON_Mode = IN_LeadVehicle_Detected_Follow;
271	          Acceleration_Mode = 2U;
272	        }
273	      }
274	      break;
275	    }
276	  }
277	
278	  /* End of Chart: '/AdaptiveCruiseControlAlgorithm' */
279	
280	  /* Update for UnitDelay: '/Unit Delay' */
281	  project2_final_DW.UnitDelay_DSTATE = Acceleration_Mode;
282	}
283	
284	/* Model initialize function */
285	void project2_final_initialize(void)
286	{
287	  /* (no initialization code required) */
288	}
289	
290	/* Model terminate function */
291	void project2_final_terminate(void)
292	{
293	  /* (no terminate code required) */
294	}
295	
296	/*
297	 * File trailer for generated code.
298	 *
299	 * [EOF]
300	 */

RESULT:-

And hence, the Model is created for the Adaptive Cruise Control model, and the following things were done as the part of the Model Based Development.

Learnings:-

  1. Requirement analysis
  2. Model creation
  3. Requirement tagging
  4. Configuration settings changes
  5. Model advisory Check
  6. Model Advisory report generation
  7. C- Code generation
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.