Challenge

Project 1- Traffic Jam Assistant Feature

Project 1- Traffic Jam Assistant Feature:

Aim:

-Model Development of a single feature of Traffic Jam Assist using MATLAB & Simulink as well as Code Generation using Embedded Coder

Objectives :

  1. Model Development as per MBD guidelines . Creation of Simulink Data Dictionary .
  2. Code Generation using Embedded Coder Generating Model Advisor Report .

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 thesurrounding 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 the press of a button. The vehicle will now automatically follow the vehicle in front, takes 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). The Algorithm which the students need to implement here in this project is predominantly based on IPC units.

Simulink Model Developement:

-Step1: Requirement Analysis

The Input Voltage , Input Switch , and the Enable switch are the inputs to the system , and the Output Display is the final Output from the system .

The Overall Model of Traffic Jam Assistant Feature is shown below:

-Requirement 1

The Subsystem of the main model as per Requirement 1 is shown below:

  • 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 2 –DisplayUnit Subsystem

The Display Unit Model as per Requirement 2 is shown below:

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

-Step2: Creation of Simulink Data Dictionary file (SLDD):

  • First you go to model then click to link to data dictionary. then click the new and put the sldd file name and browse the file.after browsing the sldd file go to model worksplace and put the all input and output signal in design data box.
  • A Simulink Data Dictionary (SLDD) file is created that contains input, output signals and calibration parameters used in the model. SLDD file is created by clicking on Modeling, then ‘Model Properties’, then ‘External Data’ and specifying a file name for the Data Dictionary.

-Step3: Requirement Tagging

The steps involved in tagging a requirement in the Simulink model is to first highlight the requirement statement in the Word document, then right click on the subsystem in the model that has to be tagged, then select ‘Requirements’ and then ‘Link to Selection in Word’.

-Step4: Configuration Parameter Update:

Various configuration parameters are updated as per the code generation the solver type should be fixed for code generation.

After clicking on model settings the following window will appears. The window presents the configuration of the parameters in our simulink mode.
• In the configuration window, click on solver to model the solver parameters.
• Now change the type to Fixed-step, Solver to discrete (no continuous states) and take sample time as 0.01sec.

Then click Ok.

This settings are shown in the following figure.

In the same configuration window there another settings to model, which is Code generation. Click on code generation, Choose the system targer file as ert.lc (Embedded coder) by clicking on the browse option.
Then click on Ok and close the window.

Resolving and Propagating the Signal at various stages:

-Step5: MAB Guidelines Check For Model Explorer

A check is performed using ‘Model Advisor’ tool in Simulink to see whether the developed model meets the modeling standards for MAB. First go to model advisor and click on ‘MAB’ then run the programme.

-Step6: Embedded Coder (Code Generation)
Using embedded coder convert the simulnik model as a ‘c code’ file. This file is code generation file.
Go to embedded coder then click on building option. Then c code file automatically was created.
After clicking on Build it will generate the C Code of our simulink as shown inn the following figure.
The C code shows all the data of our simulink model. The C code file is also saved in the same folder of our simulink model.
Result:
OUTPUT CODE:
/*
 * File: TrafficJamAssistant.c
 *
 * Code generated for Simulink model 'TrafficJamAssistant'.
 *
 * Model version                  : 1.46
 * Simulink Coder version         : 9.8 (R2022b) 13-May-2022
 * C/C++ source code generated on : Mon Nov 28 18:46:14 2022
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "TrafficJamAssistant.h"
#include "rtwtypes.h"
#include "TrafficJamAssistant_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 = true;/* Referenced by: '/Constant3' */
const volatile boolean_T INTERRUPT_2 = true;/* Referenced by: '/Constant4' */
const volatile uint8_T NO_DISPLAY = 0U;/* Referenced by: '/Constant5' */
const volatile uint8_T OFF_MODE = 2U;  /* Referenced by: '/Constant1' */
const volatile uint8_T ON_MODE = 1U;   /* Referenced by: '/Constant' */
const volatile uint8_T STANDBY_MODE = 3U;/* Referenced by: '/Constant2' */
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_TrafficJamAssistant_T TrafficJamAssistant_M_;
RT_MODEL_TrafficJamAssistant_T *const TrafficJamAssistant_M =
  &TrafficJamAssistant_M_;

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

  /* Logic: '/AND' incorporates:
   *  Constant: '/Constant'
   *  Constant: '/Constant1'
   *  Inport: '/Input_Voltage'
   *  RelationalOperator: '/GreaterThanOrEqual'
   *  RelationalOperator: '/LessThanOrEqual'
   */
  Optimum_Voltage = ((Input_Voltage >= VOLTAGE_MINIMUM_RANGE) && (Input_Voltage <=
    VOLTAGE_MAXIMUM_RANGE));

  /* Switch: '/Switch' incorporates:
   *  Constant: '/Constant3'
   *  Constant: '/Constant4'
   *  Inport: '/Input_Switch'
   *  Logic: '/AND'
   *  Logic: '/AND1'
   *  Logic: '/NOT'
   *  RelationalOperator: '/Equal'
   */
  if (Optimum_Voltage && (!Input_Switch) && (INTERRUPT_1 == INTERRUPT_2)) {
    uint8_T tmp;

    /* Saturate: '/Saturation' incorporates:
     *  Inport: '/Enable_Display'
     */
    if (Enable_Display <= 7) {
      tmp = Enable_Display;
    } else {
      tmp = 7U;
    }

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

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

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

     case 4:
      /* 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: '/Constant5'
     */
    Output_Display = NO_DISPLAY;
  }

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

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

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

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

-Conclusion :

Developed a model of single feature of Traffice Jam Assist as per MAAB Guidelines as well as created Simulink Data Dictionary using MATLAB & Simulink.Generated a code using Embedde Coder and generated a Model Advisor Report.

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.