Project 1 (Mini Project on Vehicle Direction Detection
AIM: To create the Vehicle Direction Determination model according to the given requirements
MATLAB Version: MATLAB2018a
Blocks Used: Constant,compare to constant,compare to zero, switch, AND gate ,Relational Operator,Inport,Outport
- Linking of the Simulink Data Dictionary
- Developement of the Desired model
- Configuration Parameter Setting
- Requirement Tagging
- Signal resolving and Signal Propogation
- Model Advisor Report Generation
- C-code generation
Create the simulink Data Dictionary
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.
Development of the Desired Model
Develop the model as per the requirement to develop the vehice direction determination
open the subsystem they are 2 Requirements
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 – 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).
Configuration Settings
Solver Type is changed from variable step to Fixed step and Solver type is selected as Discrete ( No continuous state) and also sample time is declared as 0.01 sec as per the project requirement.
Also under the Code generation option selecting embedded real time as system target file (ert.tlc) under target selection option
Requirement Tagging:-
A MS Word file is created which contain all the requirements and necessary information to develop the model appropiately. This Word file is tagged for both the subsystem requirement1 and Requirement2 respectively.
Requirement2 Tagging
Signal Resolving and Signal Tagging:-
All the input signal are resolved at the root level of the model and propogated accordingly as shown below:-
Model Advisor Report Generation
Click on the Model advisor and click on ok after that report is generated and save the format in html format
Model Advisor Report
Code Generation report
Code Generation Report
File: MiniprojectVD.c
|
1 |
/* |
|
2 |
* File: MiniprojectVD.c |
|
3 |
* |
|
4 |
* Code generated for Simulink model 'MiniprojectVD'. |
|
5 |
* |
|
6 |
* Model version : 1.8 |
|
7 |
* Simulink Coder version : 8.14 (R2018a) 06-Feb-2018 |
|
8 |
* C/C++ source code generated on : Fri Jul 28 12:56:46 2023 |
|
9 |
* |
|
10 |
* Target selection: ert.tlc |
|
11 |
* Embedded hardware selection: Intel->x86-64 (Windows64) |
|
12 |
* Code generation objectives: Unspecified |
|
13 |
* Validation result: Not run |
|
14 |
*/ |
|
15 |
|
|
16 |
#include "MiniprojectVD.h" |
|
17 |
#include "MiniprojectVD_private.h" |
|
18 |
|
|
19 |
/* Exported data definition */ |
|
20 |
|
|
21 |
/* Const memory section */ |
|
22 |
/* Definition for custom storage class: Const */ |
|
23 |
const int16_T LeftTurn_RoadSign = -120; |
|
24 |
const int16_T Left_Turn_AngularLimit = -120; |
|
25 |
const int16_T RightTurn_RoadSign = 30; |
|
26 |
const int16_T Right_Turn_AngularLimit = 30; |
|
27 |
const int16_T Straight_Drive_Steering_Angle = 0; |
|
28 |
const int16_T Straight_RoadSign = 0; |
|
29 |
|
|
30 |
/* External outputs (root outports fed by signals with default storage) */ |
|
31 |
ExtY_MiniprojectVD_T MiniprojectVD_Y; |
|
32 |
|
|
33 |
/* Real-time model */ |
|
34 |
RT_MODEL_MiniprojectVD_T MiniprojectVD_M_; |
|
35 |
RT_MODEL_MiniprojectVD_T *const MiniprojectVD_M = &MiniprojectVD_M_; |
|
36 |
|
|
37 |
/* Model step function */ |
|
38 |
void MiniprojectVD_step(void) |
|
39 |
{ |
|
40 |
int16_T rtb_Vehicle_Turn_Status; |
|
41 |
|
|
42 |
/* Switch: ' |
|
43 |
* Constant: ' |
|
44 |
* Constant: ' |
|
45 |
* Constant: ' |
|
46 |
* Constant: ' |
|
47 |
* Inport: ' |
|
48 |
* RelationalOperator: ' |
|
49 |
* RelationalOperator: ' |
|
50 |
* Switch: ' |
|
51 |
*/ |
|
if (SteeringWheel_YawDegreeInput > 0) { |
|
|
rtb_Vehicle_Turn_Status = RightTurn_RoadSign; |
|
|
} else if (SteeringWheel_YawDegreeInput == 0) { |
|
|
55 |
/* Switch: ' |
|
56 |
* Constant: ' |
|
57 |
*/ |
|
rtb_Vehicle_Turn_Status = Straight_RoadSign; |
|
|
59 |
} else { |
|
rtb_Vehicle_Turn_Status = LeftTurn_RoadSign; |
|
|
61 |
} |
|
62 |
|
|
63 |
/* End of Switch: ' |
|
64 |
|
|
65 |
/* Outport: ' |
|
66 |
* Constant: ' |
|
67 |
* Constant: ' |
|
68 |
* Constant: ' |
|
69 |
* Inport: ' |
|
70 |
* Logic: ' |
|
71 |
* Logic: ' |
|
72 |
* Logic: ' |
|
73 |
* RelationalOperator: ' |
|
74 |
* RelationalOperator: ' |
|
75 |
* RelationalOperator: ' |
|
76 |
*/ |
|
MiniprojectVD_Y.Vehicle_Direction_Indicator[0] = ((rtb_Vehicle_Turn_Status == |
|
|
Right_Turn_AngularLimit) && CameraInput_RoadSign); |
|
|
MiniprojectVD_Y.Vehicle_Direction_Indicator[1] = ((rtb_Vehicle_Turn_Status == |
|
|
Left_Turn_AngularLimit) && CameraInput_RoadSign); |
|
|
MiniprojectVD_Y.Vehicle_Direction_Indicator[2] = ((rtb_Vehicle_Turn_Status == |
|
|
Straight_Drive_Steering_Angle) && CameraInput_RoadSign); |
|
|
83 |
} |
|
84 |
|
|
85 |
/* Model initialize function */ |
|
86 |
void MiniprojectVD_initialize(void) |
|
87 |
{ |
|
88 |
/* Registration code */ |
|
89 |
|
|
90 |
/* initialize error status */ |
|
91 |
rtmSetErrorStatus(MiniprojectVD_M, (NULL)); |
|
92 |
|
|
93 |
/* external outputs */ |
|
94 |
(void) memset(&MiniprojectVD_Y.Vehicle_Direction_Indicator[0], 0, |
|
95 |
3U*sizeof(boolean_T)); |
|
96 |
} |
|
97 |
|
|
98 |
/* Model terminate function */ |
|
99 |
void MiniprojectVD_terminate(void) |
|
100 |
{ |
|
101 |
/* (no terminate code required) */ |
|
102 |
} |
|
103 |
|
|
104 |
/* |
|
105 |
* File trailer for generated code. |
|
106 |
* |
|
107 |
* [EOF] |
|
108 |
*/ |
|
109 |
Result
The vehicle direction determination is modelled as per the requirement, all the signals are defined in Simulink data dictionary(SLDD). All input and output signals are resolved and propagated. Updated the model to check for static errors. Run the model advisor tool to see any errors. since there are no errors in Model Advisor Report. Code has been generated using Embedded Coder.