Project 2 Adaptive Cruise Control
AIM: To develop a Adaptive Cruise Control feature as per the Requirement Document using MATLAB Simulink by following all the MBD related processes: Requirement Tagging & Traceability, SLDD creation, Configuration Parameter changes, Model Advisor check & Code Generation.
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
Steps involved in the Modeling:
1. Requirement1 Implementation (Lead Vehicle):
i) Take one subsystem with inputs CameraInput_LeadVehicle & RadarInput_LeadVehicle
ii) Add both the radar & camera inputs & the corresponding output is read as speed profile output, LeadVehicle_Speed

2. Requirement2 Implementation (Drive Vehicle):
i) Take one subsystem with inputs CameraInput_DriveVehicle, RadarInput_DriveVehicle & Acceleration_Mode
ii) Add above three input signals and the corresponding output is read as Signal DriveVehicle_Speed
iii) One more output is LeadVehicle_Detected and is renamed from Input Signal RadarInput_DriveVehicle by mere use of Signal Conversion block

3. Requirement3 Implementation (Adaptive Cruise Control Algorithm):
i) 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
ii) The input signals to this state machine system are (Signal Name: Time_Gap, Set_Speed, Set_Gap, CruiseSwitch, SetSwitch)
iii) 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
iv) Additionally, output signal (Signal Name: LeadVehicle_Speed) from requirement-1 is given as an input signal to this state machine block as well
v)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.

vi) Defined input and output signals for the chart in the symbol plane and updated in the model explorer >>chart

vii) From the above points, a chart block with 8 inputs and one output is developed as shown below

4. Requirement3a Implementation(ACC OFF MODE):
i) This is the default state inside state machine logic. Output signal Acceleration_Mode is at value 0 in this state
ii) This state is governed by input signal CruiseSwitch
iii) 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

5. Requirement3b Implementation(ACC STANDBY MODE):
i) This is the second activated state inside state machine logic. Output signal Acceleration_Mode is at value 1 in this state
ii) This state is governed by both input signals CruiseSwitch & SetSwitch
iii) 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
iv) 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.

6. Requirement3c Implementation(ACC ON MODE):
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)]

7. Configuration Parameter Settings:
Before run the model, we have to change the solver settings
i) solver type as fixed step and in solver choose discrete (no continue states) and step size is 0.01

ii) Under the Code generation section select the embedded real time as system target file (ert.tlc) under target selection option.

8. Create Simulink Data Dictionary for input and output signals:
SLDD file is created with file name 'Adaptive_cruise_controlDD' and signals are added as per the given specifications with the following steps
modeling > model properties >external data > new( create new sldd file)


9. Signal resolve and propagation:
for signal resolve, select signal > right click signal > properties > signal name > check signal name
must resolve to simulink object > ok

for propogation of signal
select signal>right click signal > properties > check show propogated signals >ok

10. Requirements Taggings:
i) Take one word document and copy all the requirements given in the problem and save it in the folder where the model is saved
ii) highlght the Requirement1, back to the model and follow the steps below
select the Requirement1 model > right click on it > Requirements > link to selection in word

iii) Repeat the same procedure for Requirement2 & 3.
iv) go to APPS > select Requirement Manager
v) Requirement tagging is done

10. Model Advisor Report:
Modelling > Model Advisor Report > Select Model Standards for MAB > Run selected checks

11. Code Generation:
goto APPS > Embedded Coder > Press Build option

Generated Code:
RESULT:
Developed Adaptive Cruise Control feature as per the Requirement Document using MATLAB Simulink and simulink model, SLDD file, Requirements word document and Model Advisor genarated reports are attached