Project 2 Adaptive Cruise Control
Aim: To develop an MBD-compliant Adaptive Cruise Control feature as per the provided requirement document using MATLAB Simulink.
Objectives:
1. To develop logic and create a Simulink model of ACC as per the Requirement data.
2. Create a data dictionary and link it to the model.
3. To generate Model advisor reports and code generation.
Steps to model the Adaptive cruise control algorithm:
1)Creating a Simulink model of the ACC algorithm
- Three subsystems are created for the three provided requirements namely Lead_Vehicle, Drive_Vehicle, and ACCAlgorithm
Lead_Vehicle subsystem: The camera and radar inputs values are taken as inputs and Lead vehicle speed will be the output as specified in requirement1


Drive vehicle subsystem: This block follows the conditions of Requirement2 and takes 3 input values for Camera input, radar input, and acceleration mode. There will be 2 outputs of drive vehicle speed and lead vehicle detection signal.


ACC algorithm subsystem: This subsystem is developed on Requirement 3 and is made using the concept of Stateflow. It takes 8 inputs and gives the acceleration mode as the final output.


ACC Algorithm Stateflow diagram: The Stateflow chart is developed based on the 6 sub-requirements specified in Requirement 3.

- The 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 are fed back as an input signal into this state machine block.
- Additionally, the 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.
Statlow symbol pane:

3) Signal resolving and propagation
- Name the imports and signals by method of signal resolving and propagation.
- A signal is resolved when it appears for the first time and the signal is then propagated then onwards
- Signal to resolve: Right Click on the signal > properties > enter a valid signal name and click on the SLDD suggestion > check the resolve signal box > OK
- Signal propagation: Double-click on the signal, add <>, and press enter.
- Or Click on the signal > properties > Check the "Show propagated signal" option > OK
- The resolved signal will be propagated
- Avoid signal overlapping by using the goto and from blocks
4) Requirement tagging
- Require tagging is the process of linking the model with a document or a file that explains the model requirements by just clicking on the name
- The Word document with requirement details is opened.
- Select the heading and highlight it.
- Right Click on the subsystem that explains the highlighted portion > requirements > Link to selection in word
- We can now see in the requirement section that the subsystem is linked to the word document.
- If anyone clicks on the requirement tag, the Word document containing its details will be opened.
5) Configuration of Solver settings and Code generation
- Go to model settings > Solver > select type: Fixed step ; solver: discrete (no continuous states) ;Fixed step size:0.01 > OK
- Go to code generation > system target file: select ert.tlc >OK
6) Model advisor check
- Model advisor checks are done to check compliance of the model with different guidelines
- Run the model and check for any errors
- If the model is error-free, we can proceed with the advisor check
- Here we are just performing the model advisor check on MAB standards
- Go to model advisor > select the whole system >OK
- Model advisor > select "By task"
- Select "modeling standards for MAB"
- Click on generate report. The file name and the location where the generated file will be stored are displayed there
- Once the report is generated, the advisor results can be seen with the total number of the pass, fail, warnings, and tasks.
- The errors must be eliminated to 0 numbers
- The warnings must be reduced to a minimum.
- To correct a warning, select the folder for which the warning is shown > select the subfolder with the warning sign > The warning parameters and correction methods as shown here
- Follow the correction recommendation and click OK when done correcting
- Now the warning number can be seen reduced.
7) Code generation:
- Once the warnings are reduced to the maximum, we can generate a C code for the model created
- Go to model explorer > open requirement 2 > set the parameters
- Go to APPS tab > Embedded Coder > Select the model name >Gerate code /Build
- The code will be displayed and it's also saved in the selected directory.

Simulink blocks used:
- Subsystem
- Add block
- Signal conversion
- Chart
- In-port and outports
- Unit Delay
Procedure:
As per the Requirement document, implemented the Adaptive Cruise Control feature.
Lead vehicle:
- To detect the lead vehicle speed, simply added both the radar & camera inputs & the corresponding output is read as Speed profile output.
Drive Vehicle:
- To regulate the "Drive Vehicle speed", as per the Requirement document added CameraInput, RadarInput & Acceleration_Mode feedback from ACC Algorithm.
- To detect the Lead vehicle, RadarInput is converted using a "Signal Conversion Block".
- To avoid the algebraic error "Unit delay" block is used for the Acceleration_Mode feedback.
ACC Algorithm:
- The 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 are fed back as an input signal into this state machine block.
- Additionally, the 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.
- The rest of the algorithm is developed as per the Requirement.
Result:
- The adaptive cruise control is modeled in Simulink as per the given requirements and MBD guidlines
- Performed requirement tagging on the requirement subsystem blocks
- Solver and code generators are configured
- SLDD file is created and linked to the model also the signals are resolved and propagated
- Model advisor report is generated and verified
- The c-code for the model is generated and attached
The Simulink model, the model Word document, the SLDD file , and the advisor report are attached in the form of a zip file below







