Challenge

Project 1- Traffic Jam Assistant Feature

AIM:

To explain the following,

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

OBJECTIVES:

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. TO DEVELOP ONE SPECIFIC REQUIREMENT OF TRAFFIC JAM ASSISTANT ALGORITHM WHICH WOULD PREDOMINANTLY FEATURE IN THE IPC ALGORITHM

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

Following were the procedure to create a 'Traffic Jam Assistant Algorithm',

STEP 1 - Open Modelling >>> Model settings. In configuration parameters choose 'Solver' and select solver selection as Fixed-step type, solver as discrete (no continuous states) and solver details of sample time as 0.01

STEP 2 - Choose code generation, In system target file browse "ert.tlc Embedded Coder" and click OK. This makes to adapt all the configuration parameters as per the testing environment

STEP 3 - Now select Modelling tab >>> Link to Data Dictionary. In that pop-up window, Under the 'external data' tab, click New option to create the new data dictionary, name it and click OK

STEP 4 - Open Modelling >>> Model Explorer, choose created the 'traffic_jam_dd' (.sldd) file as below. And click the marked two simulink parameter and signal options to add the inputs to the data dictionary file. Then make a right click on the created file and select save changes

STEP 5 - Now we have to create the subsystem of 'Traffic Jam Assistant algorithm' with three inputs and one output. Inside of this subsystem block we going to construct the given two requirements

STEP 6 - Inside the main subsystem, create 2 subsystems and name it as 'requirement 1' and 'DisplayUnit'

Requirement 1:

DisplayUnit:

STEP 7 - Follow the following points,

  • Connect the 'Input_Voltage' signal to the 'Requirement 1' subsystem as input
  • Connect the 'Optimum_Voltage' local signal of requirement-1's output, 'Input_Switch' and 'Enable_Display' signal to the 'DisplayUnit' subsystem as inputs
  • Make a 'Output_Display' signal as final output

STEP 8 - Now Tagging. Tag the required documents of 'Requirement 1' & 'Requirement 2' to their corresponding subsystems were shown below

  • Create the word document with the given information
  • Select the appropriate word (Requirement 1) from the created document

  • And go to the simulink model and right click on the related subsystem (Requirement 1), then select Requirements >>> link to the selection in word. This makes that selected paragraph on word document to link with this subsystem's description

  • After the linking process, we can cross check as it linked properly or not. So again right click on the subsystem and select Requirements >>> 1. "Requirements 1"

  • Now you can see the targeted word from the document as below

  • Just follow the same steps to tag the description for 'DisplayUnit' subsystem from the word document

STEP 9 - Resolve & Propagate. For resolve(requires that the resolved signal have the same name as the subsystem output or local data). For Propagate (to track a signal label through one block or many blocks)

Follow these steps for resolve:

  • Right-click the signal line connected to the subsystem that you want to resolve and select properties from the context menu
  • In the signal properties dialog box, enter a name for the signal that corresponds to the signal object
  • Enable the signal name must resolve to Simulink signal object check box. Click apply and OK

Follow these steps for propagate:

  • Right-click the signal for which you want to display a propagated signal label and select properties
  • In the signal properties dialog box, enable propagated signals check box. Click apply and OK

  • Following will shows how the model will looks like after the signals resolve and propagate were done,

Traffic Jam Assistant Algorithm subsystem:

Inside the Main subsystem:

Requirement 1 Subsystem:

DisplayUnit Subsystem:

STEP 10 - Now have to change the subsystem's parameter, so right click on the created subsystem and select 'block parameters (subsystem)'

STEP 11 - In this block parameters, enable the 'Treat as atomic unit', this causes simulink to treat the subsystem as a unit when determining block execution order. When it comes time to execute the subsystem, simulink executes all blocks within the subsystem before executing any other block at the same level as the subsystem block

For information,

  • If this option is not selected, simulink treats all blocks in the subsystem as being at the same level in the model hierarchy as the subsystem when determining block execution order
  • This can cause execution of blocks within the subsystem to be interleaved with execution of blocks outside the subsystem

STEP 12 - Model Advisor. Now open the Modelling >>> Model Advisor for MBD compliant changes. In that pop-up window, choose the system have to check and click OK

STEP 13 - Under the 'By Task' option, check 'Modeling Standards for MAB' and click the 'Run Selected Checks' option to starts the complaints checking

STEP 14 - After the check done, the report summary will shows the no.of pass, fail, warning as below,

  • Finally generate the report by selecting the 'Generate Report' option and click OK. The report file will saves in the related folder as in HTML format

STEP 15 - Code Generation. Open the APPS tab and choose the 'Embedded Coder' option to go for the code generation as shown below

STEP 16 - By choosing the 'Embedded Coder', the 'C code' tab will appears. In that tab, check once the 'code for' section for ensuring we're doing the codes for right subsystem and choose the 'Build' option to generate the codes. By this process, after the few moments the "C code" will be generated as shown below

STEP 17 - After the code generation, the 'traffic_jam_Assist_ert_rtw' folder will auto generated. This folder holds the supporting files of Vehicle Direction Determination Subsystem' like codes (.c), MAT (.mat), header (.h) files, etc.,

  • Following will shows the codes were hold by the C source file of 'traffic_jam_Assist.c',
/*
 * File: traffic_jam_Assist.c
 *
 * Code generated for Simulink model 'traffic_jam_Assist'.
 *
 * Model version                  : 1.22
 * Simulink Coder version         : 9.5 (R2021a) 14-Nov-2020
 * C/C++ source code generated on : Sun Jun 12 19:58:36 2022
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "traffic_jam_Assist.h"
#include "traffic_jam_Assist_private.h"

/* Exported data definition */

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

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

/* Real-time model */
static RT_MODEL_traffic_jam_Assist_T traffic_jam_Assist_M_;
RT_MODEL_traffic_jam_Assist_T *const traffic_jam_Assist_M =
  &traffic_jam_Assist_M_;

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

  /* Outputs for Atomic SubSystem: '/Traffic_Jam_Assistant_Algorithm' */
  /* Logic: '/AND' 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: '/Constant4'
   *  Constant: '/Constant5'
   *  Inport: '/Input_Switch'
   *  Logic: '/AND'
   *  Logic: '/NOT'
   *  RelationalOperator: '/Equal'
   */
  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 0:
      /* Switch: '/Switch' incorporates:
       *  Constant: '/Constant'
       */
      Output_Display = ON_MODE;
      break;

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

     case 2:
      /* Switch: '/Switch' incorporates:
       *  Constant: '/Constant1'
       */
      Output_Display = OFF_MODE;
      break;

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

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

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

  /* End of Switch: '/Switch' */
  /* End of Outputs for SubSystem: '/Traffic_Jam_Assistant_Algorithm' */
}

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

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

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

Note: All the workout files were attached by zip file (.slx, .sldd, .m, .c, .html, etc.,) as below

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.