Challenge

Project 1- Traffic Jam Assistant Feature

AIM

  • To develop a MATLAB Simulink model of the Traffic Jam Assistant feature

OBJECTIVES

  • The 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 and linked to the model.
  • Perform Model Advisor Report and Code Generation.

General Overview

                          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 km/h, the driver can activate the functionality with the press of a button. The vehicle will now automatically follow the vehicle in front, takes over driving off, accelerating, 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). The Algorithm implemented here in this project is predominantly based on IPC units.

SIMULINK MODEL

MODEL DEVELOPMENT

SLDD creation

  • first, the given input, output, local signals, and calibration values are added to Simulink Data Dictionary
  • Goto modeling - link to data dictionary - create .sldd file

  • go to model explorer then under external data, under the dictionary you created, select design data
  • by using add Simulink parameter, the constants (calibration) are added
  • by using add Simulink signal, the input/output/local signals are added
  • all the data types, values, min/max, and storage class are entered and saved

Solver and code generation settings

  • goto modeling-model settings
  • change the solver settings to fixed type, discrete(no continuous states), sample time-0.01
  • in code generation - select browse - ert.tlc embedded coder 

    

Creating subsystems

  • there are two subsystems for two requirements. Requirement1 and Display_unit
  • The input signal - Input_Voltage is given to Requirement1 and the output from this is considered as local signal Optimum_Voltage.
  • there are three inputs given to the Display_unit, Optimum_Voltage, Input_Switch, and Enable_Display. the output signal is Output_Display

  • the signals used for the first time are resolved and after that, the same signals used are propagated.
  • to resolve and propagate, right-click on the signal - properties.
  • we can also use <> and enter for propagating signals

  

Requirement1

  • The Input Signal “Input_Voltage” is compared against voltage values “VOLTAGE_MINIMUM_RANGE” and “VOLTAGE_MAXIMUM_RANGE” using relational operators.
  • “Input_Voltage” must be greater than or equal to “VOLTAGE_MINIMUM_RANGE” and less than or equal to “VOLTAGE_MAXIMUM_RANGE”.
  • The output signal “Optimum_Voltage” act as a local signal and is given as input to the subsystem “DisplayUnit”.

Requirement2: Display_unit

  • The Input Signals are “Optimum_Voltage”, “Input_Switch”, and “Enable_Display”.
  • the signal “Enable_Display” is connected to a saturation block with lower limit 0 and upper limit 7. and compared against pre – defined set of values in a multiport switch. The total data ports in the multiport switch are 5.
  • Multiport switch inputs 1 & 2 are connected to calibration signal “ON_MODE”, Multiport switch inputs 3 & 4 are connected to calibration signal “OFF_MODE”, and Multiport switch input 5 is connected to calibration signal “STANDBY_MODE”.
  • The output from the 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 the input signal “Input_Switch”, “Optimum_Voltage”, and the output from the comparison of the calibration signals “INTERRUPT_1” and “INTERRUPT_2”  using the relational operator are connected to the AND logical operator. The output of the AND gate is given as the second input of the switch block.
  • The output from the switch block is “Output_Display”.

Requirement tagging

  • open the word file containing the requirement document
  • select the word (Requirement No 1) on the word file which is going to be tagged with the subsystem (Requirement1)
  • then right-click on the subsystem -- Requirements -- Link to selection in word.

   

  • after linking, right-click on subsystem -- requirements -- select the word which was tagged.
  • the requirement document will be opened automatically

  

  • the same procedure is used for the second subsystem as well.

Model Advisor Check

  • The Model Advisor checks the created Simulink model follows, proper conditions and configuration settings 
  • The Model Advisor checks can help you verify compliance with industry standards and guidelines. 
  • select modeling -- model advisor

       

  • under By Task, select only Modeling standards for MAB
  • then select Run selected checks

  • after running selected checks and reducing the warnings

  • then select generate report

  • the model advisor report has been generated.

CODE GENERATION

  • for generating C code, Goto apps -- embedded coder

  • then select build option and the C code will be generated.

Generated C code

/*
 * File: trafficjam_assistant.c
 *
 * Code generated for Simulink model 'trafficjam_assistant'.
 *
 * Model version                  : 1.5
 * Simulink Coder version         : 9.3 (R2020a) 18-Nov-2019
 * C/C++ source code generated on : Sun Jun 19 19:59:03 2022
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "trafficjam_assistant.h"
#include "trafficjam_assistant_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 */
RT_MODEL_trafficjam_assistant_T trafficjam_assistant_M_;
RT_MODEL_trafficjam_assistant_T *const trafficjam_assistant_M =
  &trafficjam_assistant_M_;

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

  /* 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: '/Constant3'
   *  Constant: '/Constant4'
   *  Constant: '/Constant5'
   *  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' incorporates:
     *  Constant: '/Constant'
     *  Constant: '/Constant1'
     *  Constant: '/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: '/Multiport Switch' */
  } else {
    Output_Display = NO_DISPLAY;
  }

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

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

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

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

RESULT

  • Thus a MATLAB Simulink model of the Traffic Jam Assistant feature is successfully developed under MBD guidelines. the Simulink Data Dictionary creation, Requirements tagging, Model Advisor Report, and code generation are performed.
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.