Challenge

Project 1- Traffic Jam Assistant Feature

Aim: Create a model for Traffic Jam Assistance and it will displayed to the driver in the Instrument Panel Cluster (IPC).

Objectives:

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

Introduction to the Feature:

Traffic Jam Assistant is one of the most common features in the 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 the 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 their 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 pressing a button. The vehicle will now automatically follow the vehicle in front, taking over driving off, acceleration, braking and steering within the same lane.

Information regarding the Traffic Jam Assistant will be available to be displayed to the driver in the Instrument Panel Cluster (IPC). To develop one specific requirement of the 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.

Simulink Model:

The above figure shows the traffic Jam Assistance model, these models consist of three input signals, two requirement subsystems and one Output_Display output. Below figure shows the inside the Traffic Jam Assistance subsystem.

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

As per requirement 1, I created the above subsystem and output of these subsystems Optimum_Voltage provides the requirement 2 subsystems.

Requirement 2:

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

As per above requirement I created these subsystems and output of these subsystems will be displayed to the driver in the Instrument Panel Cluster (IPC).

Simulink Data Dictionary:

All the input, output and localised signal similarly calibration constant values used in these models are defined in the simulink data dictionary.

For output and calibration constant value defined Traffic_Jam_Assistance.h as header file and Traffic_Jam_Assistance.c as a definition file.

Model Advisor:

To check if our model is as per MAB guideline or not, I run model advisor check for modelling standard for MAB. After removing some warnings which we got for these model, now it is ready for code generation.

Code Generation:

For C code generation we want to change some model configuration parameters like solver type is Fixed-step, solver is discrete (no continuous states), in the code generation section change the system target file as per our requirement. In our case as per mentioned in requirement I used ert.tlc (Embedded Coder). After completing all these model configuration changes I go for code generation.

C Code:

/*
 * File: Project1_Traffic_Jam_Assistance.c
 *
 * Code generated for Simulink model 'Project1_Traffic_Jam_Assistance'.
 *
 * Model version                  : 1.7
 * Simulink Coder version         : 9.3 (R2020a) 18-Nov-2019
 * C/C++ source code generated on : Sat Dec 18 20:50:40 2021
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "Project1_Traffic_Jam_Assistance.h"
#include "Project1_Traffic_Jam_Assistance_private.h"

/* Real-time model */
RT_MODEL_Project1_Traffic_Jam_T Project1_Traffic_Jam_Assista_M_;
RT_MODEL_Project1_Traffic_Jam_T *const Project1_Traffic_Jam_Assista_M =
  &Project1_Traffic_Jam_Assista_M_;

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

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

  /* Switch: '<S3>/Switch' incorporates:
   *  Constant: '<S3>/Constant3'
   *  Constant: '<S3>/Constant4'
   *  Constant: '<S3>/Constant5'
   *  Inport: '<Root>/Input_Switch'
   *  Logic: '<S3>/Logical Operator'
   *  Logic: '<S3>/Logical Operator1'
   *  RelationalOperator: '<S3>/Relational Operator'
   */
  if ((!Input_Switch) && Optimum_Voltage && (INTERRUPT_1 == INTERRUPT_2)) {
    /* Saturate: '<S3>/Saturation' incorporates:
     *  Inport: '<Root>/Enable_Display'
     */
    if (Enable_Display < 7) {
      tmp = Enable_Display;
    } else {
      tmp = 7U;
    }

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

    /* MultiPortSwitch: '<S3>/Multiport Switch' incorporates:
     *  Constant: '<S3>/Constant'
     *  Constant: '<S3>/Constant1'
     *  Constant: '<S3>/Constant2'
     */
    switch (tmp) {
     case 0:
      Output_Display = ON_MODE;
      break;

     case 1:
      Output_Display = ON_MODE;
      break;

     case 2:
      Output_Display = OFF_MODE;
      break;

     case 3:
      Output_Display = OFF_MODE;
      break;

     default:
      Output_Display = STANDBY_MODE;
      break;
    }

    /* End of MultiPortSwitch: '<S3>/Multiport Switch' */
  } else {
    Output_Display = NO_DISPLAY;
  }

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

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

/* Model terminate function */
void Project1_Traffic_Jam_Assistance_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.