Challenge

Project 1 (Mini Project on Vehicle Direction Detection

                                                                     STUDENT OF ONLINE EV BATCH 16

ANS :

OBJECTIVE :

  1. Development of MATLAB Simulink model as per requirement.
  2. Tag the requirements to the simulink model; tagging requirement 1 & requirement 2 to their corresponding subsystems.
  3. MBD compliant changes, Data Dictionary creation & code generation.
  4. Choosing code generation, Storage class for Input signals: ImportedExtern; Storage class for Output signal: Export to File; Storage class for local signals: localizable; Storage class for calibration signals: Const.
  5. Choosing sample time for all signals as 0.01

MATLAB FUNCTIONAL MODEL :

  • CHANGE SOLVER SETTING.
  • CHANGE CODE GENERATION SETTING.
  • CREATE SLDD FILE.
  • CREATE REQUIREMENT 1 SUBSYSTEM.
  • CREATE REQUIREMENT 2 SUBSYSTEM.
  • CREATE SUBSYSTEM.
  • TAG THE SYSTEM'S.
  • RESOLVE AND PROPOGATE THE SIGNAL.
  • GO FOR MIL TEST.
  • GO FOR SIL TEST.
  • GENERATE C-CODE.
  • GO FOR MODEL ADVISOR TEST.

CHANGE SOLVER SETTING :

         

CHANGE CODE GENERTION SETTING :

          

CREATE SLDD FILE :

          

Requirement - 1 :

  • Steering wheel input as yaw rate (Signal name: SteeringWheel_YawDegreeInput) is the input for this system.
  • 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-1 SUBSYSTEM :

                 

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-2 SUBSYSTEM :

                                                     

CREATED SUBSYSTEM :

           

TAG REQUIREMENT '1' & '2' :

  • RIGHT CLICK ON SUBSYSTEM.
  • MOVE TO REQUIREMENT.
  • LINK TO SELECTION IN WORD.

          

         

CREATED MODEL :

            

RESOLVE AND PROPOGATE THE SIGNAL :

  • DOUBLE CLICK ON SIGNAL.
  • THEN, RIGHT CLICK.
  • MOVE TO PROPERTIES.
  • PUT THE SIGNAL NAME.
  • ENABLE 'SIGNAL NAME MUST RESOLVE TO SIMULINK SIGNAL OBJECT'.
  • FOR PROPOGATION JUST DOUBLE TAP ON LINE.
  • USE THIS SYMBOL '<>'.
  • PUT ENTER INSIDE THIS.

                                     

                

MIL TEST :

              

MIL TEST OUTPUT :

            

SIL TEST :

          

SIL OUTPUT :

           

MODEL ADVISOR :

  • GO TO MODELING OPTION.
  • MOVE TO MODEL ADVISOR.
  • TAP ON THAT.
  • MOVE TO BY TASK OPTION.
  • ENABLE ONLY MODELING SIMULINK FOR MAB.
  • RUN SELECTED CHECKS.
  • REDUCE WARNINGS.
  • GENERATE REPORT.

STEP-1 :

          

STEP-2 :

           

STEP-3 :

         

C-CODE GENERATION :

  • MOVE TO APPS OPTION.
  • GO FOR EMBEDDED CODER.
  • TAP ON THAT.
  • GO TO BUILD OPTION.
  • GENERATE THE CODE.

STEP-1 :

          

STEP-2 :

         

STEP-3 :

         

C-CODE :

/*
 * File: Vehicle_Direction.c
 *
 * Code generated for Simulink model 'Vehicle_Direction'.
 *
 * Model version                  : 1.24
 * Simulink Coder version         : 9.3 (R2020a) 18-Nov-2019
 * C/C++ source code generated on : Tue Jun 14 21:14:07 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: '/Constant4' */
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: '/Constant3' */
const int16_T Straight_RoadSign = 0;   /* Referenced by: '/Constant2' */

/* Real-time model */
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' */
  /* Switch: '/Switch' incorporates:
   *  Constant: '/Constant'
   *  Constant: '/Constant4'
   *  Switch: '/Switch1'
   */
  if (Vehicle_Direction_ConstB.Compare != 0) {
    Vehicle_Turn_Status = Right_Turn_AngularLimit;
  } else if (Vehicle_Direction_ConstB.Compare_p != 0) {
    /* Switch: '/Switch1' incorporates:
     *  Constant: '/Constant3'
     */
    Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
  } else {
    Vehicle_Turn_Status = Left_Turn_AngularLimit;
  }

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

  /* SignalConversion: '/Signal Conversion' incorporates:
   *  Logic: '/AND'
   *  Logic: '/AND1'
   *  Logic: '/AND2'
   */
  Vehicle_Direction_Indicator[0] = false;
  Vehicle_Direction_Indicator[1] = false;
  Vehicle_Direction_Indicator[2] = false;

  /* 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]
 */
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.