Challenge

Project 1 (Mini Project on Vehicle Direction Detection

ANSWER 

model :

 

Requirement - 1 

 

Requirement - 2

 

SLDD  :

 

Code generation :

/*
 * File: model.c
 *
 * Code generated for Simulink model 'model'.
 *
 * Model version                  : 1.1
 * Simulink Coder version         : 9.5 (R2021a) 14-Nov-2020
 * C/C++ source code generated on : Mon Apr  3 16:32:03 2023
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "model.h"
#include "model_private.h"

/* Exported data definition */

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

/* External outputs (root outports fed by signals with default storage) */
ExtY_model_T model_Y;

/* Real-time model */
static RT_MODEL_model_T model_M_;
RT_MODEL_model_T *const model_M = &model_M_;

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

  /* Switch: '/Switch' incorporates:
   *  Inport: '/SteeringWheel_YawDegreeInput'
   *  Switch: '/Switch1'
   */
  if (SteeringWheel_YawDegreeInput >= 30) {
    /* Switch: '/Switch' incorporates:
     *  Constant: '/Right_Turn_AngularLimit,'
     */
    Vehicle_Turn_Status = Right_Turn_AngularLimit;
  } else if (SteeringWheel_YawDegreeInput != 0) {
    /* Switch: '/Switch1' incorporates:
     *  Constant: '/Left_Turn_AngularLimit,'
     *  Switch: '/Switch'
     */
    Vehicle_Turn_Status = Left_Turn_AngularLimit;
  } else {
    /* Switch: '/Switch' incorporates:
     *  Constant: '/Straight_Drive_Steering_Angle'
     *  Switch: '/Switch1'
     */
    Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
  }

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

  /* Outport: '/ Vehicle_Direction_Indicator' incorporates:
   *  Constant: '/Constant'
   *  Constant: '/Constant'
   *  Constant: '/Constant'
   *  Inport: '/CameraInput_RoadSign'
   *  Logic: '/Logical Operator'
   *  Logic: '/Logical Operator1'
   *  Logic: '/Logical Operator2'
   *  RelationalOperator: '/Compare'
   *  RelationalOperator: '/Compare'
   *  RelationalOperator: '/Compare'
   */
  model_Y.Vehicle_Direction_Indicator[0] = ((Vehicle_Turn_Status ==
    RightTurn_RoadSign) && CameraInput_RoadSign);
  model_Y.Vehicle_Direction_Indicator[1] = ((Vehicle_Turn_Status ==
    LeftTurn_RoadSign) && CameraInput_RoadSign);
  model_Y.Vehicle_Direction_Indicator[2] = ((Vehicle_Turn_Status ==
    Straight_RoadSign) && CameraInput_RoadSign);
}

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

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

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

 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.