Challenge

Project 1 (Mini Project on Vehicle Direction Detection

AIM:-

  • The Aim of this project is to create a MBD compliant MATLAB simulink model for vehicle direction as per the requirement specified.
  • Tag the requirements to the simulink model: Requirement & Requirement  are tagged to their corresponding subsystem.
  • Creation of data sictionary for the simulink model, perform model in Loop (MIL) test and software in Loop (SIL) test.

Task:-

  • The input to the systems are the steering wheel angular input
  • as yaw rate (signal name: SteeringWheel_YawDegreeInput)
  • And input signal from camera (Signal Name: CameraInput_RoadSign) , which confirms the occurance of a road sign.
  • A camera needs the road signs & stiores its memory unique values for left turn, right turn &straight drive.
  • Depending on the direction the vehicle takes, a final indication is given to the driver - if he is driving in the recommended direction or not.
  • The output of the system is a boolean value (Signal Name: Vehicle_Direction_Indicator), which specifies whether the vehicle is turning right,left or going straight.

Development of simulink  model:-

  • The main subsystem 'Vehicle_Direction; along with the inputs 'SteeringWheel_YawDegreeInput' 'CameraInput_RoadSign'  and output signal 'Vehicle_Direction_Indicator' as shown below:

Vehicle direction subsystem:-

  • And then the main subsystem again divided into two subsystem as 'Requirement1' &'Requirement2' as shown below:

Requirement1 & Requirement2 subsystem:-

Requirement-1:-

  •  In the 'Requirement1' subsystem, the Steering wheel input as yaw rate (Signal name: SteeringWheel_YawDegreeInput) is the input for the subsystem .
  • This is compared against 3 angular values, one each for left turn, right turn & straight drive (Calibration Values: Right_Turn_AngularLimit, Left_Turn_AngularLimit, Straight_Drive_Steering_Angle) to say which specific direction the steering wheel is turning towards.
  • Use switch blocks to compare & develop this requirement. Keep this requirement in a subsystem & output of this requirement is a local signal (Signal Name: Vehicle_Turn_Status).

Requirement – 2:

  • Keep this requirement as a separate subsystem. Inputs to this requirement are local signal from requirement 1 (Signal Name: Vehicle_Turn_Status) & an input signal from camera (Signal Name: CameraInput_RoadSign), which confirms the occurrence of a road sign.
  • Signal Vehicle_Turn_Status is compared against calibration values (Calibration Values: RightTurn_RoadSign, LeftTurn_RoadSign, Straight_RoadSign), if each of them is found equal, then each of the three corresponding output is compared against the camera input signal,
  • Using a logical operator block, only one among them is finally given as output signal (Signal Name: Vehicle_Direction_Indicator).

Requirement of tagging of model:-

  • The requirements 'Requirement1' &'Requirement2' is provided in the document are tagged to their corresponding subsystem by the following way.
  • We have to select the word in the word document and then we need click on requirements and link to selection in word.

Creation of SLDD file:-

  • By selecting the Link to data dictionary in the modelling parameters we can select the sldd file.
  • Below shown the image to create the sl file.

Signals & Calibration data list:-

  • The below signals and parameters are given in the question itselfs so we will put these values into the model by which is in the sldd file.
  • To access the sldd file we need to go to model explorer for better understanding please check the below image for reference.

MODEL ADVISOR for MAB guidelines:-

  • To check the model as per our MAB guidelines we have to perform using 'model advisor' tool.
  • Where the model meets the MAB standards.

Hardware in loop testing:-

  • To the model we perform model in loop (MIL) testing and software in loop (SIL) testing we can give inputs to the model and check the system output and gets the result.
  • By following method we can perform the MIL test, by clicking on the test harness option in properties - and then select the signal builder in sources and sinks,and keep the advanced settings as same.

  • After inputting the test case from excel file as we saw in previous method those steps are applied here also, after inserting we will compare the output by using the sum blocks
  • Where Output-input =0 .

  • From the below scope we can see the exactly in scope results we get zero and another scope1 is the actual output from the model.

Software in Loop Testing :-

  • By following method we can perform the MIL test, by clicking on the test harness option in properties - and then select the signal builder in sources and sinks, and click on advanced options and change to the software in loop testing(SIL)

  • We get the same results as we received from the MIL test.

CODE GENERATION:-

  • We have to build a c code for the model, so we need to click on apps - embedded code- build.
  • We can view the code even after we close .

C COde:-

/*
 * File: Vehicle_Direction.c
 *
 * Code generated for Simulink model 'Vehicle_Direction'.
 *
 * Model version                  : 1.15
 * Simulink Coder version         : 9.5 (R2021a) 14-Nov-2020
 * C/C++ source code generated on : Thu May 26 16:39:42 2022
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "Vehicle_Direction.h"
#include "Vehicle_Direction_private.h"

/* Exported data definition */

/* Definition for custom storage class: ExportToFile */
boolean_T Vehicle_Direction_Indicator[3];/* '/Signal Conversion' */

/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T LeftTurn_RoadSign = -120;/* Referenced by: '/Constant1' */
const int16_T Left_Turn_AngularLimit = -120;/* Referenced by: '/Constant1' */
const int16_T RightTurn_RoadSign = 30; /* Referenced by: '/Constant' */
const int16_T Right_Turn_AngularLimit = 30;/* Referenced by: '/Constant' */
const int16_T Straight_Drive_Steering_Angle = 0;/* Referenced by: '/Constant2' */
const int16_T Straight_RoadSign = 0;   /* Referenced by: '/Constant2' */

/* Real-time model */
static RT_MODEL_Vehicle_Direction_T Vehicle_Direction_M_;
RT_MODEL_Vehicle_Direction_T *const Vehicle_Direction_M = &Vehicle_Direction_M_;

/* Model step function */
void Vehicle_Direction_step(void)
{
  /* local block i/o variables */
  int16_T Vehicle_Turn_Status;

  /* Outputs for Atomic SubSystem: '/Vehicle_Direction' */
  /* Outputs for Atomic SubSystem: '/Requirement_1' */
  /* Switch: '/Switch' incorporates:
   *  Constant: '/Constant'
   *  Constant: '/Constant'
   *  Inport: '/SteeringWheel_YawDegreeInput'
   *  RelationalOperator: '/Compare'
   *  RelationalOperator: '/Compare'
   *  Switch: '/Switch1'
   */
  if (SteeringWheel_YawDegreeInput > 0) {
    /* Switch: '/Switch' incorporates:
     *  Constant: '/Constant'
     */
    Vehicle_Turn_Status = Right_Turn_AngularLimit;
  } else if (SteeringWheel_YawDegreeInput < 0) {
    /* Switch: '/Switch1' incorporates:
     *  Constant: '/Constant1'
     *  Switch: '/Switch'
     */
    Vehicle_Turn_Status = Left_Turn_AngularLimit;
  } else {
    /* Switch: '/Switch' incorporates:
     *  Constant: '/Constant2'
     *  Switch: '/Switch1'
     */
    Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
  }

  /* End of Switch: '/Switch' */
  /* End of Outputs for SubSystem: '/Requirement_1' */

  /* Outputs for Atomic SubSystem: '/Requirement_2' */
  /* SignalConversion: '/Signal Conversion' incorporates:
   *  Constant: '/Constant'
   *  Constant: '/Constant1'
   *  Constant: '/Constant2'
   *  Inport: '/CameraInput_RoadSign'
   *  Logic: '/AND'
   *  Logic: '/AND1'
   *  Logic: '/AND2'
   *  RelationalOperator: '/Relational Operator'
   *  RelationalOperator: '/Relational Operator1'
   *  RelationalOperator: '/Relational Operator2'
   */
  Vehicle_Direction_Indicator[0] = ((Vehicle_Turn_Status == RightTurn_RoadSign) &&
    CameraInput_RoadSign);
  Vehicle_Direction_Indicator[1] = ((Vehicle_Turn_Status == LeftTurn_RoadSign) &&
    CameraInput_RoadSign);
  Vehicle_Direction_Indicator[2] = ((Vehicle_Turn_Status == Straight_RoadSign) &&
    CameraInput_RoadSign);

  /* End of Outputs for SubSystem: '/Requirement_2' */
  /* End of Outputs for SubSystem: '/Vehicle_Direction' */
}

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

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

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

RESULT:-

Thus we have built a model by using the inputs from the question and we followed the MAB checks using model advisor , we performed MIL and SIL test for the model & Created the C code for the model and attached whole file as a zip folder for verification

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.