Challenge

Project 1- Traffic Jam Assistant Feature

Project -1 : Traffic Jam Assistant Feature

Aim: To develop a model in MATLAB environment for Traffic Jam Assistant feature as per MBD guidelines including SLDD creation, Model advisor report and Code generation.

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.

Model:

According to the specific requirement a MATLAB model is developed for the Traffic Jam Assistant algorithm which would predominantly feature in the IPC algorithm. The whole Traffic Jam Assistant is a very huge algorithm & only one small part of the logic is implemented here. The modelling is done keeping in mind the MBD guidelines.

The block diagram of final model is shown below-

The model consists three inputs and gives out one output signal. Inside the Traffic_Jam subsystem there are two more subsystems namely ‘Requierement_1’ and . The fig. is shown below-

The output of the Requirement_1 subsystem in a input of the second subsystem named DisplayUnit_Subsystem. Both of these two subsystems are discussed below.

Requirement 1:

The Input signal to this subsystem is “Input_Voltage”. It 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”; this is achieved using relational operator and logical operator. Output signal is the “Optimum_Voltage” which will be one of the inputs to second the subsystem “DisplayUnit”.

The figure shows the construction of the subsystem-

Requirement No 2 (DisplayUnit Subsystem):

In the second subsystem there are three input signals namely - “Optimum_Voltage”, “Input_Switch”,“Enable_Display” ; and only one output signal which is “Output_Display”.

  • Signal “Enable_Display” is saturated between the range 0 – 7, and then the signal is compared against pre – defined set of values in a multiport switch having 5 data ports.
  • 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”. The output from the switch block is “Output_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 signal are routed properly and the final look of the DisplayUnit Subsystem is shown in the following figure-

SLDD Creation :

The given signals shown in the table below; are used to create a Simulink data dictionary file for the model.

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

The SLDD file is created and linked with the model using the drop-down menu in the modelling tab. A snapshot of the sldd is attached below.

Signal Resolving and propagation :

The signals are resolved where they appear for first time. This is done by clicking on the signals and going to signal properties by right clicking on it. A snapshot is added.

After resolving signals , they are propagated by writing ‘<>’ on the signal name. It automatically takes the name of the signals.

Requirement Tagging:

For tagging the subsystems with the requirement document , we just have to select the part in the word document and keep it the background. While in the simulink window we need to select the subsystem we want to tag, right click on it and select ‘Requirements’ from the context menu. This allows us to tag with a word document.

Model Advisor:

The model is checked for MBD guidelines in Model Advisor. The model advisor window is loaded and checked for MAB guidelines and report is generated. The model has passed without any fail but a few warnings showed up which can be ignored.

Code Generation:

To generate code for the model first we have to adjust the model settings. In the model settings under code generation , the target file is selected to be ‘ert.tlc’ , this allows to generate Embedded C-code for the model.

After the settings are applied, we proceed with code generation part.

Now, to generate code the Embedded Coder App is selected from the top ribbon menu of Simulink. Then by clicking on Build button the gets generated.

This takes 1 or 2 mins to generate the code. The generated code is saved in a new folder with name ending with ‘_ert_rtw’ under the current working path. The summary of the code generation report is shown below.

C-code:

/*
* File: Project_traffic.c
*
* Code generated for Simulink model 'Project_traffic'.
*
* Model version : 1.2
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Mon Jan 31 01:32:52 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/

#include "Project_traffic.h"
#include "Project_traffic_private.h"

/* Exported data definition */

/* Definition for custom storage class: ExportToFile */
uint8_T Output_Display; /* '<S2>/Switch' */

/* Real-time model */
static RT_MODEL_Project_traffic_T Project_traffic_M_;
RT_MODEL_Project_traffic_T *const Project_traffic_M = &Project_traffic_M_;

/* Model step function */
void Project_traffic_step(void)
{
/* local block i/o variables */
boolean_T Optimum_Voltage;
uint8_T tmp;

/* Logic: '<S3>/AND' incorporates:
* Constant: '<S3>/Constant'
* Constant: '<S3>/Constant1'
* Inport: '<Root>/Input_Voltage'
* RelationalOperator: '<S3>/Relational Operator'
* RelationalOperator: '<S3>/Relational Operator1'
*/
Optimum_Voltage = ((VOLTAGE_MINIMUM_RANGE >= Input_Voltage) && (Input_Voltage <=
VOLTAGE_MAXIMUM_RANGE));

/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant6'
* Constant: '<S2>/Constant7'
* Inport: '<Root>/Input_Switch'
* Logic: '<S2>/AND'
* Logic: '<S2>/NOT'
* RelationalOperator: '<S2>/Relational Operator'
*/
if (Optimum_Voltage && (INTERRUPT_1 == INTERRUPT_2) && (!Input_Switch)) {
/* Saturate: '<S2>/Saturation' incorporates:
* Inport: '<Root>/Enable_Display'
*/
if (Enable_Display < 7) {
tmp = Enable_Display;
} else {
tmp = 7U;
}

/* End of Saturate: '<S2>/Saturation' */

/* MultiPortSwitch: '<S2>/Multiport Switch' */
switch (tmp) {
case 1:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant'
*/
Output_Display = ON_MODE;
break;

case 2:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant1'
*/
Output_Display = ON_MODE;
break;

case 3:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant2'
*/
Output_Display = OFF_MODE;
break;

case 4:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant3'
*/
Output_Display = OFF_MODE;
break;

default:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant4'
*/
Output_Display = STANDBY_MODE;
break;
}

/* End of MultiPortSwitch: '<S2>/Multiport Switch' */
} else {
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant5'
*/
Output_Display = NO_DISPLAY;
}

/* End of Switch: '<S2>/Switch' */
}

/* Model initialize function */
void Project_traffic_initialize(void)
{
/* (no initialization code required) */
}

/* Model terminate function */
void Project_traffic_terminate(void)
{
/* (no terminate code required) */
}

/*
* File trailer for generated code.
*
* [EOF]
*/

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.