Project 1- Traffic Jam Assistant Feature
Introduction to the Feature:
Traffic Jam Assistant is one of the most common feature in Advanced Driver Assistance System. Traffic Jam Assistant helps the driver arrive more relaxed at their destination, even in dense traffic or in traffic jams. As a partially automated comfort function, the system takes over the longitudinal & lateral guidance of the vehicle. This means that the car can drive off, accelerate & brake automatically, as well as steer the vehicle within certain constraints. The driver has to permanently supervise the system & be ready to take over the complete control of the vehicle at any time.

Traffic Jam Assistant system helps to avoid rear end collisions in dense traffic conditions & traffic jams. In Traffic jams, the vehicle takes over driving off, acceleration, braking and steering within same lane.
Basic Working Principle:
Traffic Jam Assistant is based on the sensors and the functionality of the Adaptive Cruise Control (ACC) with stop & go and Lane Keeping Support (LKS). When ACC ‘Stop & Go’ is turned ON, the Traffic Jam Assistant continuously analyses the speed of the surrounding vehicles and compares it with the own driving speed. If the system detects dense traffic or a traffic jam at speeds less than 60 kmph, the driver can activate the functionality by press of a button. The vehicle will now automatically follow the vehicle in front, takes over driving off, acceleration, braking and steering within same lane.
Information regarding the Traffic Jam Assistant will be available to be displayed to the driver in the Instrument Panel Cluster (IPC). The Algorithm which the students need to implement here in this project is predominantly based on IPC units.
Problem Statement:
To develop one specific requirement of Traffic Jam Assistant algorithm which would predominantly feature in the IPC algorithm.Please note that the whole Traffic Jam Assistant is a very huge algorithm & only one small part of the logic is implemented here. Idea is to familiarize with concepts of Model Based Development in MATLAB Environment. The Project must be done keeping in mind the following processes & steps.
- This model must be developed in MATLAB Simulink as per MBD guidelines.
- Code Generation Profile must be in Embedded Coder.
- Simulink Data Dictionary must be created for the model & must be linked to the model.
- Model Advisor Report is mandatory & this will be followed by Code Generation.
Input Signals:
|
Name of the Signal |
Data Type |
Range |
|
Input_Voltage |
uint8 |
0 - 255 |
|
Input_Switch |
boolean |
0 – 1 |
|
Enable_Display |
uint8 |
0 - 255 |
Output Signal:
|
Name of the Signal |
Data Type |
Range |
|
Output_Display |
uint8 |
0 - 255 |
Calibration Signals:
|
Name of the Signal |
Data Type |
Range |
Initial Value |
|
VOLTAGE_MINIMUM_RANGE |
uint8 |
0 – 255 |
30 |
|
VOLTAGE_MAXIMUM_RANGE |
uint8 |
0 – 255 |
50 |
|
OFF_MODE |
uint8 |
0 – 255 |
2 |
|
ON_MODE |
uint8 |
0 – 255 |
1 |
|
STANDBY_MODE |
uint8 |
0 – 255 |
3 |
|
INTERRUPT_1 |
boolean |
0 – 1 |
1 |
|
INTERRUPT_2 |
boolean |
0 - 1 |
1 |
|
NO_DISPLAY |
uint8 |
0 – 255 |
0 |
Local Signal:
|
Name of the Signal |
Data Type |
Range |
|
Optimum_Voltage |
boolean |
0 - 1 |
Requirement No 1:
- Input Signal “Input_Voltage” is compared against voltage values “VOLTAGE_MINIMUM_RANGE” & “VOLTAGE_MAXIMUM_RANGE”.
- Incoming input signal “Input_Voltage” must be greater than – equal to “VOLTAGE_MINIMUM_RANGE” and less than – equal to “VOLTAGE_MAXIMUM_RANGE”.
- Output signal from here is “Optimum_Voltage” which will be one of the inputs to the subsystem “DisplayUnit”.
Requirement No 2 (DisplayUnit Subsystem):
- Input Signals are “Optimum_Voltage”, “Input_Switch”,“Enable_Display”. Signal “Enable_Display” must be saturated between the range 0 – 7. Output signal from the subsystem is “Output_Display”.
- Input Signal “Enable_Display” is compared against pre – defined set of values in a multiport switch. Total data ports in the multiport switch is 5.
- Multiport switch inputs 1 & 2 is connected to calibration signal “ON_MODE”, Multiport switch inputs 3 & 4 is connected to calibration signal “OFF_MODE” while Multiport switch input 5 is connected to calibration signal “STANDBY_MODE”.
- The output from Multiport switch is connected to the first input port of the Switch block. The third input port of the Switch block is connected to the calibration signal “NO_DISPLAY”.
- Meanwhile NOT value of input signal “Input_Switch” is compared in an AND gate against input signal “Optimum_Voltage” and the output from comparing if calibration signals “INTERRUPT_1” & “INTERRUPT_2” are equal. The output of the AND gate is the second input of the switch block.
- The output from the switch block is “Output_Display”.

1. This is the main model subsystem that has three inputs Input_Voltage, Input_Switch and Enable_Display entering into Traffic_Jam_Assistant_Feature the subsystem and one output Output_Display.

There are 2 requirements are designed in two subsystem

- Input Signal “Input_Voltage” is compared against voltage values “VOLTAGE_MINIMUM_RANGE” & “VOLTAGE_MAXIMUM_RANGE”.
- Incoming input signal “Input_Voltage” must be greater than – equal to “VOLTAGE_MINIMUM_RANGE” and less than – equal to “VOLTAGE_MAXIMUM_RANGE”.
- The output signal from here is “Optimum_Voltage” which will be one of the inputs to the subsystem “DisplayUnit”.

- Input Signals are “Optimum_Voltage”, “Input_Switch”,“Enable_Display”. Signal “Enable_Display” must be saturated between the range 0 – 7. Output signal from the subsystem is “Output_Display”.
- Input Signal “Enable_Display” is compared against pre – defined set of values in a multiport switch. Total data ports in the multiport switch is 5.
- Multiport switch inputs 1 & 2 is connected to calibration signal “ON_MODE”, Multiport switch inputs 3 & 4 is connected to calibration signal “OFF_MODE” while Multiport switch input 5 is connected to calibration signal “STANDBY_MODE”.
- The output from Multiport switch is connected to the first input port of the Switch block. The third input port of the Switch block is connected to the calibration signal “NO_DISPLAY”.
- Meanwhile NOT value of input signal “Input_Switch” is compared in an AND gate against input signal “Optimum_Voltage” and the output from comparing if calibration signals “INTERRUPT_1” & “INTERRUPT_2” are equal. The output of the AND gate is the second input of the switch block.
- The output from the switch block is “Output_Display”.

2.all the inputs, outputs, calibration parameters are saved in SLDD so while simulation the model takes all the
values and its parameters from the Simulink Data Dictionary

3.The set the Modelling Configuration
sample Time -0.01
Solver Selection Type - Fixed Step
code Generation Set - ert.tlc(Embedded Coder)
4. Signal Resolution for inputs and outputs

the inputs and output signals are resolved so the signals will take the values from sldd and pass them to the logical blocks. Otherwise, it may take some junk values if it is unresolved
5. Model Update.
The model update is done by Ctrl-D. this is done to check for any static errors. If there are no errors coming the model is working fine without any errors.
6. Simulation
The model is simulated too for checking for errors and warnings
8. Model Advisory Report
By running the model advisor tool, we can see commonly made modelling errors.

9 Code generation
build a model for generating code

code Generated
File: ert_main.c
1 /*
2 * File: ert_main.c
3 *
4 * Code generated for Simulink model 'Traffic_Jam_Assistant'.
5 *
6 * Model version : 1.2
7 * Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
8 * C/C++ source code generated on : Mon Jun 5 20:53:50 2023
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
17 #include /* This ert_main.c example uses printf/fflush */
18 #include "Traffic_Jam_Assistant.h" /* Model's header file */
19 #include "rtwtypes.h"
20
21 /*
22 * Associating rt_OneStep with a real-time clock or interrupt service routine
23 * is what makes the generated code "real-time". The function rt_OneStep is
24 * always associated with the base rate of the model. Subrates are managed
25 * by the base rate from inside the generated code. Enabling/disabling
26 * interrupts and floating point context switches are target specific. This
27 * example code indicates where these should take place relative to executing
28 * the generated code step function. Overrun behavior should be tailored to
29 * your application needs. This example simply sets an error status in the
30 * real-time model and returns from rt_OneStep.
31 */
32 void rt_OneStep(void);
33 void rt_OneStep(void)
34 {
35 static boolean_T OverrunFlag = false;
36
37 /* Disable interrupts here */
38
39 /* Check for overrun */
40 if (OverrunFlag) {
41 rtmSetErrorStatus(Traffic_Jam_Assistant_M, "Overrun");
42 return;
43 }
44
45 OverrunFlag = true;
46
47 /* Save FPU context here (if necessary) */
48 /* Re-enable timer or interrupt here */
49 /* Set model inputs here */
50
51 /* Step the model */
52 Traffic_Jam_Assistant_step();
53
54 /* Get model outputs here */
55
56 /* Indicate task complete */
57 OverrunFlag = false;
58
59 /* Disable interrupts here */
60 /* Restore FPU context here (if necessary) */
61 /* Enable interrupts here */
62 }
63
64 /*
65 * The example "main" function illustrates what is required by your
66 * application code to initialize, execute, and terminate the generated code.
67 * Attaching rt_OneStep to a real-time clock is target specific. This example
68 * illustrates how you do this relative to initializing the model.
69 */
70 int_T main(int_T argc, const char *argv[])
71 {
72 /* Unused arguments */
73 (void)(argc);
74 (void)(argv);
75
76 /* Initialize model */
77 Traffic_Jam_Assistant_initialize();
78
79 /* Attach rt_OneStep to a timer or interrupt service routine with
80 * period 0.2 seconds (the model's base sample time) here. The
81 * call syntax for rt_OneStep is
82 *
83 * rt_OneStep();
84 */
85 printf("Warning: The simulation will run forever. "
86 "Generated ERT main won't simulate model step behavior. "
87 "To change this behavior select the 'MAT-file logging' option.\n");
88 fflush((NULL));
89 while (rtmGetErrorStatus(Traffic_Jam_Assistant_M) == (NULL)) {
90 /* Perform other application tasks here */
91 }
92
93 /* Disable rt_OneStep() here */
94
95 /* Terminate model */
96 Traffic_Jam_Assistant_terminate();
97 return 0;
98 }
99
100 /*
101 * File trailer for generated code.
102 *
103 * [EOF]
104 */
105