Project 1 (Mini Project on Vehicle Direction Detection
AIM: To create a Simulink model for vehicle direction determination:
Step-1
- To Create a sldd file to update all the given inputs, outputs & parameters on this file later calling these variables on the Simulink blocks are shown in the fig.

Step-2
Model explanation:

- First we can create two sub-systems and name as requirement-1 & requirement-2 as given in question.

Requirement-1 subsystem:
- 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 & the output of this requirement is a local signal (Signal Name: Vehicle_Turn_Status).
- As per the requirements, 1 can design this model, when the steering yaw degree is considered as input is connected to the relational operator and the relational operator is connected with the switch based on the if-else condition the switch is given the output as a boolean number.
- For eg if we given -120 deg as input means when the relation operator checks the given input once it fails means its automatically switch the false statement when the false statement is connected to the left-turn_drive so the the switch given the output the left-turn value.

Requirment:2 Subsystem:
- Keep this requirement as a separate subsystem. Inputs to this requirement are a local signal from requirement 1 (Signal Name: Vehicle_Turn_Status) & an input signal from the 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 outputs is compared against the camera input signal,
- Using a logical operator block, only one among them is finally given as the output signal (Signal Name: Vehicle_Direction_Indicator).
- As per requirement statement-2 we have to compare the vehicle turn status and the camera sign once is true means the vehicle can conclude the turn is based on the road sign.
- So, we have to taken the vehicle turn status as input and it would be given to the relational operator which is the road sign is compared with the vehicle turn status.
- and we use the And gate block which is used to given the any one output to the Or gate at a time for if left turn status is true means right turn and straight turn will be fale so that's why we using the And gate in this subsytem.
- The basic objective of the subsystem is to comapare the vehicle turn status with the road sign.

Step-3:
- In this case, we have updated our signals inputs in the sldd file so we have to add the signal into the connection lines to get the proper output.
- once right-click the line a popup window can be opened select properties option to open the resolve and propagate option.
- In that window, we may type the required input signals which is updated in the ssld file and select the resolve option to resolve the signal.


Step-4 : To conclude the variant test process:
- Before doing this test have to change the atomic unit and solver to gather
- also select system target file as a embeded coder


Step 5: Requirement Tagging
all the requirements are tagged in order for better understandability, anyone who is reviewing the model or who is trying to update the model can get a clear idea of what logic is used in the system. from the requirement manager, we can see what are all are tagged and the description



Step 6: Model Advisory Report
- A model advisor is a tool that automatically checks the model for errors using pre-defined checks.
- Model advisor as a tool is available in the core Simulink block set that automatically enables the user to check for common modeling mistakes which we miss out to notice during model development.
- The model advisor can analyze the entire model or a sub-set of the model. Upon selecting the model advisor option as shown below, the developer can choose which version he would like to test. here we choose the MAB guidlines as shown in below screenshot.


- Press the run button which is mentioned in the above fig. after analyzing all the blocks it shows the results as no of pass, no of fail, and no of warnings.
- After that, we have to generate the report for that and it the report can explain our model very clearly can shown below fig.

Step 7: Code generation
Following are the steps to generate the embeded code from simulink model
- click on APP which is on the toolstrip as shown below then click on the embeded coder then click on generate code.

- and you will get a code as shown below right side of the window


Generated Code is as per below.
/*
* File: Subsystem1.c
*
* Code generated for Simulink model 'Subsystem1'.
*
* Model version : 1.36
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Tue Oct 25 22:21:21 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Subsystem1.h"
#include "Subsystem1_private.h"
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
boolean_T Vehicle_Direction_Indicator; /* '
/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T LeftTurn_RoadSign = -120;/* Referenced by: '
const int16_T Left_Turn_AngularLimit = -120;
/* Referenced by: '
const int16_T RightTurn_RoadSign = 30; /* Referenced by: '
const int16_T Right_Turn_AngularLimit = 30;
/* Referenced by: '
const int16_T Straight_Drive_Steering_Angle = 0;
/* Referenced by: '
const int16_T Straight_RoadSign = 0; /* Referenced by: '
/* Real-time model */
static RT_MODEL_Subsystem1_T Subsystem1_M_;
RT_MODEL_Subsystem1_T *const Subsystem1_M = &Subsystem1_M_;
/* Model step function */
void Subsystem1_step(void)
{
/* local block i/o variables */
int16_T Vehicle_Turn_Status;
/* Outputs for Atomic SubSystem: '
/* Switch: '
* Inport: '
* Switch: '
*/
if (SteeringWheel_YawDegreeInput > 25) {
/* Switch: '
* Constant: '
*/
Vehicle_Turn_Status = Right_Turn_AngularLimit;
} else if (SteeringWheel_YawDegreeInput > 0) {
/* Switch: '
* Constant: '
* Switch: '
*/
Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
} else {
/* Switch: '
* Constant: '
* Switch: '
*/
Vehicle_Turn_Status = Left_Turn_AngularLimit;
}
/* End of Switch: '
/* Logic: '
* Constant: '
* Constant: '
* Constant: '
* Inport: '
* Logic: '
* Logic: '
* Logic: '
* Logic: '
* Logic: '
* Logic: '
*/
Vehicle_Direction_Indicator = ((CameraInput_RoadSign && ((Vehicle_Turn_Status
!= 0) && (RightTurn_RoadSign != 0))) || (CameraInput_RoadSign &&
((Vehicle_Turn_Status != 0) && (LeftTurn_RoadSign != 0))) ||
(CameraInput_RoadSign && ((Vehicle_Turn_Status != 0) && (Straight_RoadSign
!= 0))));
/* End of Outputs for SubSystem: '
}
/* Model initialize function */
void Subsystem1_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void Subsystem1_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
Step 8: Generation of S function
Right click on subsystem then click on the c/c++ code then click on the generate S function.
then below window will open and click on the built option
then one folder(Subsystem1_ert_rtw) is created where you saved your simulink model as shown below
Conclusion-
- In this project we create a simulink model to Identify the direction of the vehicle, as per the given two requirements.
- We create the SLDD file to link the various signals which are used to generate the code.
- Generate the code from the Simulink model.
- Use the advisory tool as per the MAB guidelines to check the system condition.