Challenge

Project 1- Traffic Jam Assistant Feature

TRAFFIC JAM ASSISTANT ALGORITHM

AIM:

To develop one specific requirement of Traffic Jam Assistant algorithm.

OBJECTIVES:

To develop one specific requirement of Traffic Jam Assistant algorithm which would predominantly feature in the IPC algorithm. The Project is done keeping in mind the following objectives.

  • To develop a model in MATLAB Simulink as per MBD guidelines.
  • To do Code Generation Profile in Embedded Coder.
  • To create a Simulink Data Dictionary for the model & to link it to the model.
  • To generate Model Advisor Report.

THEORY:

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

Driving in a traffic jam is always a stressful situation and with this feature, the vehicle estimates the distance from other vehicles and controls acceleration and deceleration whilst holding the vehicle in lane. This means you only have to worry about steering (only available with DSG versions)

STEPS :

1) The requirements are analysed inorder to develop the Simulink model. The inputs to the main model are “Input_Voltage," “Input_Switch”,“Enable_Display” and the output from the system is “Output_Display”.

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”.

2) The Simulink model is developed and it's sub-systems are shown below.

For Requirement No 1, Input Signal “Input_Voltage” is compared against voltage values “VOLTAGE_MINIMUM_RANGE” & “VOLTAGE_MAXIMUM_RANGE” and the output signal from here is “Optimum_Voltage” which will be one of the inputs to the subsystem “DisplayUnit”.

For Requirement No 2, “Input_Voltage," “Input_Switch”,“Enable_Display” are the input signals and after necessary comparisons using multiport-switch and a switch, the final output obtained from the switch block is “Output_Display”.

Traffic Jam Assistant Simulink Model:

Sub-systems of the model:

Requirement No1 subsystem:

Requirement No2 subsystem: (DisplayUnit Subsystem)

3) Requirement tagging is done for each subsystem.

For each subsystem or blocks, corresponding requirement functionality from the document can be tagged for better understanding. Subsystems or components which are tagged with requirements when selected gets highlighted to yellow colour. Here Requirement No1 and Requirement No2 are tagged to corresponding sections in MS Word file. Details are shown here:

Requirement_1 subsystem is tagged to Requirement_1 in Word document

Requirement_2 subsystem is tagged to Requirement No 2 in Word document

4) SLDD Creation

A data dictionary is a persistent repository of data that are relevant to the created model. The dictionary stores design data, which define parameters and signals, and include data that define the behavior of the model. We can also use the base workspace to store design data that are used by the model during simulation. The given signal details are:

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

Steps

  • Choose " Link to Data dictionary" option from "Modelling tab" in matlab in the Model properties window.
  • Select "New" option and uncheck access to base workspace.
  • Clicking on New will enable the developer to choose the working folder, where he would like to keep sldd file.
  • After creation, sldd gest linked to the model as shown in below. A pop-up appears at left corner of the model window.
  • Here a data dictionary named "tja_sldd " is created and saved.
  • The signals to be exported (output ) are stored in Storage class "ExportToFile" and calibration parameters are included in storage class 'ConstVolatile', Local signal under Storage class "Localizable" and input signals under "ImportedExtern".
Simulink Data Dictionary :

5) Signal Resolving for Inputs and Outputs:

Stateflow local and output data in charts can inherit properties from "Simulink.Signal" objects in the model workspace or the base workspace and this process is called signal resolution and requires that the resolved signal have the same name as the chart output or local data.

For signal resolution for an output signal in a MATLAB Function block, the steps are:

  1. In the Simulink model, right-click the signal line connected to the output that you want to resolve and select "Properties" from the context menu.

  2. In the Signal Properties dialog, enter a name for the signal that corresponds to the signal object.

  3. Select the "Signal name must resolve to Simulink signal object" check box and click OK.

Inorder to propogate signals, right-click the signal line connected, select Properties, and select the 'Show propagated signals' check box and click OK.

The above procedure is done for each and every signal in the model. All the signals in the model are named correctly and are resolved and propogated.

6) Configuration Parameters Update:

In the Modelling Tab, Open "Configuration Parameters" and change Solver to "Fixed Type" and Fixed Step size is given(0.01).

All the remaining Configuration Parameters are checked one by one and necessary changes are made to set the parameters either to "warning" or "error''.

7) Model Update:

Inorder to update the Model, press Ctrl+E.

8) Model Advisor Checks and Model Advisor Report

Model Advisor is a tool that automatically checks the model for errors using pre-defined checks.

Under Model Advisor, select 'By Task',---> select 'Model Standards for ISO 26262' and 'Modelling Standards for MAB ' and Run the selected Checks to generate a Report. The model is run without any errors. The images are given below:

Model Advisor Checks:

Model Advisor Report

9) Code Generation:

The steps for Code Generation are:

  • Go to Configuration Parameters, system target file 'ert.tlc' is selected for 'Embedded Coder'. Click Apply.
  • Under Configuration parameters, select 'Code Generation' check the box for 'Create Code generation Report' and 'Open report automatically' and Click Apply.
  • Under 'Apps' tab, select 'Embedded Coder' and Click on 'Generate Code'.
  • Press Ctrl+E to update the model.
  • The code generation report is obtained and the generated code is saved in ''traffic_jam_assistant.c" and 'traffic_jam_assistant.h' files.

Code Generation generates a Model.c file which contains the entry point for the algorithm, Model.h file,which declares the model data structures and a Model_private.h file which contains local macros and data required by the model. Also, it generates a Model_types.h file which provides type definitions for user defined types in the model.

Configuration Parameters for Code Generation:

Generated Code:

Code Generation Report:

The Generated Code is attached here:

/*
 * File: traffic_jam_assistant.c
 *
 * Code generated for Simulink model 'traffic_jam_assistant'.
 *
 * Model version                  : 1.5
 * Simulink Coder version         : 9.5 (R2021a) 14-Nov-2020
 * C/C++ source code generated on : Sun Jan 23 22:12:42 2022
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "traffic_jam_assistant.h"
#include "traffic_jam_assistant_private.h"

/* Exported data definition */

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

/* ConstVolatile memory section */
/* Definition for custom storage class: ConstVolatile */
const volatile boolean_T INTERRUPT_1 = 1;/* Referenced by: '/Constant' */
const volatile boolean_T INTERRUPT_2 = 1;/* Referenced by: '/Constant1' */
const volatile uint8_T NO_DISPLAY = 0U;/* Referenced by: '/Constant2' */
const volatile uint8_T OFF_MODE = 2U;  /* Referenced by: '/Constant4' */
const volatile uint8_T ON_MODE = 1U;   /* Referenced by: '/Constant3' */
const volatile uint8_T STANDBY_MODE = 3U;/* Referenced by: '/Constant5' */
const volatile uint8_T VOLTAGE_MAXIMUM_RANGE = 50U;/* Referenced by: '/Constant1' */
const volatile uint8_T VOLTAGE_MINIMUM_RANGE = 30U;/* Referenced by: '/Constant' */

/* Real-time model */
static RT_MODEL_traffic_jam_assistan_T traffic_jam_assistant_M_;
RT_MODEL_traffic_jam_assistan_T *const traffic_jam_assistant_M =
  &traffic_jam_assistant_M_;

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

  /* Logic: '/OR' incorporates:
   *  Constant: '/Constant'
   *  Constant: '/Constant1'
   *  Inport: '/Input_Voltage'
   *  RelationalOperator: '/Relational Operator'
   *  RelationalOperator: '/Relational Operator1'
   */
  Optimum_Voltage = ((Input_Voltage >= VOLTAGE_MINIMUM_RANGE) || (Input_Voltage <=
    VOLTAGE_MAXIMUM_RANGE));

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

    /* End of Saturate: '/Saturation' */

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

     case 2:
      /* Switch: '/Switch' incorporates:
       *  Constant: '/Constant3'
       */
      Output_Display = ON_MODE;
      break;

     case 3:
      /* Switch: '/Switch' incorporates:
       *  Constant: '/Constant4'
       */
      Output_Display = OFF_MODE;
      break;

     case 4:
      /* Switch: '/Switch' incorporates:
       *  Constant: '/Constant4'
       */
      Output_Display = OFF_MODE;
      break;

     default:
      /* Switch: '/Switch' incorporates:
       *  Constant: '/Constant5'
       */
      Output_Display = STANDBY_MODE;
      break;
    }

    /* End of MultiPortSwitch: '/Multiport Switch' */
  } else {
    /* Switch: '/Switch' incorporates:
     *  Constant: '/Constant2'
     */
    Output_Display = NO_DISPLAY;
  }

  /* End of Switch: '/Switch' */
}

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

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

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

Code Generation folder link:

https://drive.google.com/drive/folders/1PraihkDYGxqNLLKCfkRW8rhzceZJW0cW?usp=sharing

(All other files are attached alongwith the project.)

RESULT:

Developed one specific requirement of Traffic Jam Assistant algorithm which would predominantly feature in the IPC algorithm. The matlab Model is developed as per the requirements and as per MBD guidelines.

The Simulink Data Dictionary is created and linked to the model. The model advisor check is run after developing the model to create Model Advisor Report and the model is converted into code using Embedded coder.

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.