Project 1 (Mini Project on Vehicle Direction Detection
OBJECTIVE:
- The objective of this project is to create a MBD compliant MATLAB Simulink model for vehicle direction detection as per the requirement specified.
- Tag the requirements to the Simulink model; Requirement 1 & Requirement 2 are tagged to their corresponding subsystems.
- Creation of Data Dictionary for the Simulink model, Perform Model In Loop (MIL) test and Software In Loop (SIL) test.
TASK:
- The inputs to the system are the Steering wheel angular input given as yaw rate (Signal name: SteeringWheel_YawDegreeInput) and a input signal from camera (Signal Name: CameraInput_RoadSign), which confirms the occurrence of a road sign.
- A camera reads the road signs & stores into 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 sytem is a boolean value (Signal Name: Vehicle_Direction_Indicator) which specifies whether the vehicle is turning right, left or going straight.
DEVELOPMENT OF THE SIMULINK MODEL:
The main subsystem 'Vehicle_Direction' along with inputs 'SteeringWheel_YawDegreeInput' , 'CameraInput_RoadSign' and output signal ' Vehicle_Direction_Indicator' is shown below:

Fig 1: 'Vehicle_Direction' subsystem
The main subsystem 'Vehicle_Direction' is further divided into two more subsytems which are 'Requirement1' and 'Requirement2' as shown below:

Figure 2: 'Requirement1' and 'Requirement2' subsystems
Requirement-1:
- In the 'Requirement1' subsystem, the steering wheel yaw degree (Signal name: SteeringWheel_YawDegreeInput) is fed as input to the subsystem and this value 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.
- The input signal 'SteeringWheel_YawDegreeInput' is compared against three angular values using the relational operator '==', 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. In this case, the output of the relational operator '==' is equal to 1 only when the 'SteeringWheel_YawDegreeInput' matches the calibraton value angular limit specified in Right_Turn_AngularLimit, Left_Turn_AngularLimit, or Straight_Drive_Steering_Angle.
- Three switch blocks are used to implement an if-else logic. The output from each relational operator is given as a condition input (input2) to each Switch block. The switch will pass input1 (calibration value) when the condition (input2~=0) condition is satisfied, else input3 (output from the next switch block) is passed as output.
- The signal 'Vehicle_Turn_Status' obtained at the output of the first switch will be a calibration angular value (Right_Turn_AngularLimit OR Left_Turn_AngularLimit, OR Straight_Drive_Steering_Angle). If none of the conditions get satisfied, zero is passed as the output from the last switch. The signal 'Vehicle_Turn_Status' is fed to the outport of subsystem 'Requirement1'.

Figure 3: 'Requirement-1' subsystem
Requirement-2:
- In 'Requirement2' subsystem, the local signal 'Vehicle_Turn_Status' fed from 'Requirement1' subsystem is taken as input and is compared against calibration values (RightTurn_RoadSign, LeftTurn_RoadSign, Straight_RoadSign) using the relational operator '=='.
- The boolean value obatined at the output of the realtional operator is compared against a boolean input signal from camera (Signal Name: CameraInput_RoadSign), which confirms the occurrence of a road sign using 'AND' operotor.
- The boolean output signal obtained from each of the three 'AND' blocks are fed to the outport 'Vehicle_Direction_Indicator' to indicate the vehicle direction. The output 'Vehicle_Direction_Indicator' will be a three dimension signal having three boolean elements, with the first element to indicate 'Right Turn', second element to indicate 'Left Turn' and third element to indicate 'Straight Drive'.

Figure 4: 'Requirement2' subsystem
Requirement Tagging of Simulink Model:
The requirements ‘Requirement-1’ and ‘Requirement-2’ as provided in the Requirements Word document are tagged to their corresponding subsystem in the Simulink Model.
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’

Figure 5: Highlighting the requirement to be tagged in requirement Word document.

Figure 6: Tagging ‘Requirement1’ Subsystem to its requirement in Word document
Creation of Simulink Data Dictionary file (SLDD):
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.

Figure 7: Simulink Data Dictionary Dialog Box
Signals & Calibration Data List:
|
Signal / Calibration Name |
Signal Type |
Data Type |
Dimension |
Min |
Max |
Initial Value |
Units |
|
SteeringWheel_YawDegreeInput |
Input |
Int16 |
1 |
-180 |
180 |
- |
Deg |
|
CameraInput_RoadSign |
Input |
Boolean |
1 |
0 |
1 |
- |
- |
|
Vehicle_Turn_Status |
Local |
Int16 |
1 |
-180 |
180 |
- |
Deg |
|
Right_Turn_AngularLimit |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
30 |
Deg |
|
Left_Turn_AngularLimit |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
-120 |
Deg |
|
Straight_Drive_Steering_Angle |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
0 |
Deg |
|
RightTurn_RoadSign |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
30 |
|
|
LeftTurn_RoadSign |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
-120 |
|
|
Straight_RoadSign |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
0 |
|
|
Vehicle_Direction_Indicator |
Output |
Boolean |
3 |
0 |
1 |
- |
- |

Figure 9: Simulink Data Dictionary Input, Output and Calibration Parameters in Model Explorer
MAAB Guidelines Check in Model Advisor:
A check is performed using ‘Model Advisor’ tool in Simulink to see whether the developed model meets the modeling standards for MAAB.

Figure 10: MAAB Guidelines Check in Model Advisor
Generated C-Code:
/*
* File: Vehicle_Direction.c
*
* Code generated for Simulink model 'Vehicle_Direction'.
*
* Model version : 4.0
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Tue Mar 22 15:19: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"
/* 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;
/* Switch: '
* Constant: '
* Constant: '
* Constant: '
* Inport: '
* RelationalOperator: '
* RelationalOperator: '
* RelationalOperator: '
* Switch: '
* Switch: '
*/
if (SteeringWheel_YawDegreeInput == Right_Turn_AngularLimit) {
/* Switch: '
* Constant: '
*/
Vehicle_Turn_Status = Right_Turn_AngularLimit;
} else if (SteeringWheel_YawDegreeInput == Left_Turn_AngularLimit) {
/* Switch: '
* Constant: '
* Switch: '
*/
Vehicle_Turn_Status = Left_Turn_AngularLimit;
} else if (SteeringWheel_YawDegreeInput == Straight_Drive_Steering_Angle) {
/* Switch: '
* Constant: '
* Switch: '
* Switch: '
*/
Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
} else {
/* Switch: '
* Constant: '
* Switch: '
* Switch: '
*/
Vehicle_Turn_Status = 0;
}
/* End of Switch: '
/* SignalConversion: '
* Constant: '
* Constant: '
* Constant: '
* Inport: '
* Logic: '
* Logic: '
* Logic: '
* RelationalOperator: '
* RelationalOperator: '
* RelationalOperator: '
*/
Vehicle_Direction_Indicator[0] = (CameraInput_RoadSign && (Vehicle_Turn_Status
== RightTurn_RoadSign));
Vehicle_Direction_Indicator[1] = (CameraInput_RoadSign && (Vehicle_Turn_Status
== LeftTurn_RoadSign));
Vehicle_Direction_Indicator[2] = (CameraInput_RoadSign && (Vehicle_Turn_Status
== Straight_RoadSign));
}
/* 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]
*/