Project 2 - Development of TFT Cluster Speedometer Software Component
Answere :
Develop the Simulink model based on the given requirements and also create SLDD file and link the same to the model.
1) Aim : Development of TFT Cluster Speedometer Software Component.
Basic Information :
Cluster Instrument receives the signals from other ECU's via CAN bus interface. It also receives commands from the driver via steering wheel buttons. The signals are then processed by the Cluster ECU, after which the Cluster ECU may send the vehicle information to the LCD or light the LEDs and so forth, according to the results. Therefore, the Cluster ECU can be viewed as a carrier of the information flow.
The diagram below shows the overview of the system.

Requirements :
1.1 Calculating TFT Display Speed :
|
Average Vehicle Speed would be displayed only if its between 2 kmph & 250 kmph. Any value outside this range will be discarded by its lower limit & upper limit |
|
When Average Vehicle Speed is < 2 kmph, DisplaySpeed = 2 kmph |
|
When Average Vehicle Speed is in between 2 kmph & 250 kmph, DisplaySpeed = Average Vehicle Speed |
|
When Average Vehicle Speed is > 250 kmph, DisplaySpeed = 250 kmph |

1.2 Main Data Filtering :
|
Main Data Filtering subsystem will be activated for every 10th millisecond |
||||||
|
DisplaySpeed1 (t) = ((DisplaySpeed (t) x 0.65)/ Main Filter Speed Value) 0.05 |

1.3 Auxiliary Data Filtering :
|
Auxiliary Data Filtering subsystem will be activated for every 10th millisecond |
|||||||
|
DisplaySpeed_Filter (t) = ((DisplaySpeed1 (t) x 0.78)/ Auxillary Filter Speed Value) - 0.03 |

1.4 TFT Speed Output :
|
If |(DisplaySpeedFilter - DisplaySpeed)| > 1.5 |
|
{ |
|
Vehicle Speed Display = DisplaySpeed |
|
} |
|
else |
|
{ |
|
Vehicle Speed Display = DisplaySpeed Filter |
|
} |

Simulink Model :

Subsystem :

2. Simulink Data Dictionary (SLDD) :

3. Requirement Tagging Report :
Create the Functional and SwReq File into the .xls File.


Click on the New Requirement set.

After that Click on Add Requirement.

Linking with Requirement.




Calculating TFT Display Speed :

Main Data Filtering :

Auxiliary Data Filtering :

TFT Speed Output :

Requirement Tagging Report :


4. Fixed-Point Tool :
Run the Model Error Free >> Going to App>> Click on the Fixed-Point Tool >> Iterative Fixed Point Conversion.
Simulink Model :

Simulink Data Dictionary Before the Fixed-point Tool :

Block Before Applying Fixed-Point Tool :


Procedure to Start Fixed-Point Tool :


Prepare :

Collect Range :

Propose Data Type :


Apply Data Type :

SLDD after Applying Fixed-Point Tool :

Blocks After Applying Fixed Point Tool :


5. Model Advisor (JMAAM) Compliance Report :
Going to the Simulink Model >> Click On Modelling >> Model Advisor


6. SLDV Design Error Detection Report :
Goto the Model >> Click on App >> Click on Design Verifier >>Select the Design Error Detection >> Then Click on the Design Error Detection Setting.



Checking Compatibility :

Detect Design Error :


Design Error Detection Report :




7. Functional Test Cases, MIL, SIL Harness, Coverage Report :
Simulink Model :

Functional Test Cases :

Model in Loop(MIL) :

Signal Builder Waveform :

MIL Data Inspector Output :

MIL Coverage :

MIL Coverage Report :






Software in Loop (SIL) :

Signal Builder Waveform :

SIL Data Inspector Output :

SIL Coverage :

SIL Coverage Report :


8. SLDV Test Generation Report :
goto the model and Run it without Error free >> App >> Design Verifier >> Click on the Test Generation.

Click on the Test Generation Setting


Results Summary of Test Generation

SLDV Test Reort :







9. Auto Code Generation main .c & .h Files:


.c Code :
/*
* File: TFT_Cluster_Speedometer.c
*
* Code generated for Simulink model 'TFT_Cluster_Speedometer'.
*
* Model version : 1.71
* Simulink Coder version : 9.7 (R2022a) 13-Nov-2021
* C/C++ source code generated on : Wed Feb 15 01:41:46 2023
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "TFT_Cluster_Speedometer.h"
#include "rtwtypes.h"
#include "TFT_Cluster_Speedometer_private.h"
#include "zero_crossing_types.h"
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
uint16_T Out_VehicleSpeedDisplay; /* '/Switch' */
/* Vehicle Speed displayed by Speedmeter */
/* Definition for custom storage class: Localizable */
static uint16_T DisplaySpeed1; /* '/Subtract' */
/* Display Speed Calculation1 */
static uint16_T DisplaySpeed_Filter; /* '/Subtract' */
/* Display Speed Filter Value */
/* Previous zero-crossings (trigger) states */
PrevZCX_TFT_Cluster_Speedomet_T TFT_Cluster_Speedometer_PrevZCX;
/* Real-time model */
static RT_MODEL_TFT_Cluster_Speedome_T TFT_Cluster_Speedometer_M_;
RT_MODEL_TFT_Cluster_Speedome_T *const TFT_Cluster_Speedometer_M =
&TFT_Cluster_Speedometer_M_;
/* Model step function */
void TFT_Cluster_Speedometer_step(void)
{
int32_T tmp_0;
int32_T tmp_1;
uint32_T tmp;
int16_T tmp_2;
boolean_T rtb_Compare;
/* Saturate: '/Saturation' incorporates:
* Inport: '/Avg_VehicleSpeed'
*/
tmp = (uint32_T)Avg_VehicleSpeed << 1;
if (tmp >= 64000U) {
/* Saturate: '/Saturation' */
Out_VehicleSpeedDisplay = 64000U;
} else if (tmp <= 512U) {
/* Saturate: '/Saturation' */
Out_VehicleSpeedDisplay = 512U;
} else {
/* Saturate: '/Saturation' */
Out_VehicleSpeedDisplay = (uint16_T)(Avg_VehicleSpeed << 1);
}
/* End of Saturate: '/Saturation' */
/* RelationalOperator: '/Compare' incorporates:
* Constant: '/Constant'
* Inport: '/Time_Input'
* Math: '/Rem'
*/
rtb_Compare = ((uint16_T)(Time_Input % 10) == 0);
/* Outputs for Triggered SubSystem: '/Main_Data_Filtering' incorporates:
* TriggerPort: '/Trigger'
*/
if (rtb_Compare &&
(TFT_Cluster_Speedometer_PrevZCX.Main_Data_Filtering_Trig_ZCE != POS_ZCSIG))
{
/* Product: '/Divide' incorporates:
* Gain: '/Gain'
* Inport: '/In_MainFilt_SpeedValue '
* Saturate: '/Saturation'
*/
if (In_MainFilt_SpeedValue == 0U) {
tmp_2 = MAX_int16_T;
/* Divide by zero handler */
} else {
tmp_2 = (int16_T)((((21299U * Out_VehicleSpeedDisplay) >> 19) << 6) /
In_MainFilt_SpeedValue);
}
/* Sum: '/Subtract' incorporates:
* Constant: '/Constant'
* Product: '/Divide'
*/
DisplaySpeed1 = (uint16_T)(((tmp_2 << 15) - 26214) >> 12);
}
TFT_Cluster_Speedometer_PrevZCX.Main_Data_Filtering_Trig_ZCE = rtb_Compare;
/* End of Outputs for SubSystem: '/Main_Data_Filtering' */
/* Outputs for Triggered SubSystem: '/ Auxillary_Data_Filtering' incorporates:
* TriggerPort: '/Trigger'
*/
if (rtb_Compare &&
(TFT_Cluster_Speedometer_PrevZCX.Auxillary_Data_Filtering_Trig_Z !=
POS_ZCSIG)) {
/* Product: '/Divide' incorporates:
* Gain: '/Gain'
* Inport: '/In_AuxillaryFilt_SpeedValue'
* Sum: '/Subtract'
*/
if (In_AuxillaryFilt_SpeedValue == 0U) {
tmp_2 = MAX_int16_T;
/* Divide by zero handler */
} else {
tmp_2 = (int16_T)((((25559U * DisplaySpeed1) >> 18) << 6) /
In_AuxillaryFilt_SpeedValue);
}
/* Sum: '/Subtract' incorporates:
* Constant: '/Constant'
* Product: '/Divide'
*/
tmp_1 = (tmp_2 << 3) - 3;
if (tmp_1 < 0) {
tmp_1 = 0;
} else if (tmp_1 > 65535) {
tmp_1 = 65535;
}
/* Sum: '/Subtract' */
DisplaySpeed_Filter = (uint16_T)tmp_1;
}
TFT_Cluster_Speedometer_PrevZCX.Auxillary_Data_Filtering_Trig_Z = rtb_Compare;
/* End of Outputs for SubSystem: '/ Auxillary_Data_Filtering' */
/* Sum: '/Subtract' incorporates:
* Saturate: '/Saturation'
* Sum: '/Subtract'
* Switch: '/Switch'
*/
tmp_1 = DisplaySpeed_Filter << 1;
tmp_0 = (tmp_1 - Out_VehicleSpeedDisplay) >> 7;
if (tmp_0 < 0) {
tmp_0 = 0;
}
/* Switch: '/Switch' incorporates:
* RelationalOperator: '/GreaterThan'
* Sum: '/Subtract'
* Sum: '/Subtract'
*/
if (tmp_0 <= 3) {
if (DisplaySpeed_Filter > 32767) {
/* Saturate: '/Saturation' incorporates:
* Switch: '/Switch'
*/
Out_VehicleSpeedDisplay = MAX_uint16_T;
} else {
/* Saturate: '/Saturation' incorporates:
* Switch: '/Switch'
*/
Out_VehicleSpeedDisplay = (uint16_T)tmp_1;
}
}
}
/* Model initialize function */
void TFT_Cluster_Speedometer_initialize(void)
{
TFT_Cluster_Speedometer_PrevZCX.Auxillary_Data_Filtering_Trig_Z = POS_ZCSIG;
TFT_Cluster_Speedometer_PrevZCX.Main_Data_Filtering_Trig_ZCE = POS_ZCSIG;
}
/* Model terminate function */
void TFT_Cluster_Speedometer_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
.h Code :
/*
*
* File: TFT_Cluster_Speedometer.h
*
* Code generated for Simulink model 'TFT_Cluster_Speedometer'.
*
* Model version : 1.71
* Simulink Coder version : 9.7 (R2022a) 13-Nov-2021
* C/C++ source code generated on : Wed Feb 15 01:41:46 2023
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef RTW_HEADER_TFT_Cluster_Speedometer_h_
#define RTW_HEADER_TFT_Cluster_Speedometer_h_
#ifndef TFT_Cluster_Speedometer_COMMON_INCLUDES_
#define TFT_Cluster_Speedometer_COMMON_INCLUDES_
#include "rtwtypes.h"
#endif /* TFT_Cluster_Speedometer_COMMON_INCLUDES_ */
#include "TFT_Cluster_Speedometer_types.h"
#include "zero_crossing_types.h"
/* Macros for accessing real-time model data structure */
#ifndef rtmGetErrorStatus
#define rtmGetErrorStatus(rtm) ((rtm)->errorStatus)
#endif
#ifndef rtmSetErrorStatus
#define rtmSetErrorStatus(rtm, val) ((rtm)->errorStatus = (val))
#endif
/* Zero-crossing (trigger) state */
typedef struct {
ZCSigState Main_Data_Filtering_Trig_ZCE;/* '/Main_Data_Filtering' */
ZCSigState Auxillary_Data_Filtering_Trig_Z;/* '/ Auxillary_Data_Filtering' */
} PrevZCX_TFT_Cluster_Speedomet_T;
/* Real-time Model Data Structure */
struct tag_RTM_TFT_Cluster_Speedomet_T {
const char_T * volatile errorStatus;
};
/* Zero-crossing (trigger) state */
extern PrevZCX_TFT_Cluster_Speedomet_T TFT_Cluster_Speedometer_PrevZCX;
/* Model entry point functions */
extern void TFT_Cluster_Speedometer_initialize(void);
extern void TFT_Cluster_Speedometer_step(void);
extern void TFT_Cluster_Speedometer_terminate(void);
/* Exported data declaration */
/* Declaration for custom storage class: ExportToFile */
extern uint16_T Out_VehicleSpeedDisplay;/* '/Switch' */
/* Vehicle Speed displayed by Speedmeter */
/* Real-time Model object */
extern RT_MODEL_TFT_Cluster_Speedome_T *const TFT_Cluster_Speedometer_M;
/*-
* These blocks were eliminated from the model due to optimizations:
*
* Block '/Abs' : Eliminated since data is unsigned
*/
/*-
* The generated code includes comments that allow you to trace directly
* back to the appropriate location in the model. The basic format
* is /block_name, where system is the system number (uniquely
* assigned by Simulink) and block_name is the name of the block.
*
* Use the MATLAB hilite_system command to trace the generated code back
* to the model. For example,
*
* hilite_system('') - opens system 3
* hilite_system('/Kp') - opens and selects block Kp which resides in S3
*
* Here is the system hierarchy for this model
*
* '' : 'TFT_Cluster_Speedometer'
* '' : 'TFT_Cluster_Speedometer/TFT_Cluster_Speedometer_SWC'
* '' : 'TFT_Cluster_Speedometer/TFT_Cluster_Speedometer_SWC/ Auxillary_Data_Filtering'
* '' : 'TFT_Cluster_Speedometer/TFT_Cluster_Speedometer_SWC/Calculating_TFT_Display_Speed'
* '' : 'TFT_Cluster_Speedometer/TFT_Cluster_Speedometer_SWC/Compare To Constant'
* '' : 'TFT_Cluster_Speedometer/TFT_Cluster_Speedometer_SWC/Main_Data_Filtering'
* '' : 'TFT_Cluster_Speedometer/TFT_Cluster_Speedometer_SWC/TFT_Speed_Output'
*/
#endif /* RTW_HEADER_TFT_Cluster_Speedometer_h_ */
/*
* File trailer for generated code.
*
* [EOF]
*/
10. Polyspace Analysis Report/Output :
1. Bug Finder :
- Initially, open the Polyspace in that new project click on start new project.
- The Project Properties dialogue box will open in that give the project name as we saved in the MATLAB,then select the location where it we need to save after that click Next or use the default location.
- Then ,it asks for the Projrct source,click on browserand select the folder where th .c file are generated then optionally we can add the include folder then clock on finish,the polyspace environment will open.
- In the configuraton settings option called Target & compiler select the source code language as c,change the target processor as X86_64.
- In the coding standards & code Metrics in that enable the check MISRA C:2004 also select the calculate the code metrics option
- After that go to bug finder analysis under that select the default one.
Go to reporting enable the generate report option and ouput formet as PDF or any file we need - Finally save the polyspace and run the Bug Finder.
2. Code Prover :
- Befour going to the Code Prover First setup the Configration setting.
- In Configuration go to the Code prover verification and under code prover verification option.
- Click on the Check Behavior and Enable the option (i,e Allow Negative Operand for left shifts).
and also click on the Consider Non-Finite floats. - Then After you go to the Precision
- In Precision Select the Precision level -2 and Verification Level is Software Safety Analysis Level-2.
- then After Click on Save Botton the Configration setting will be save.
- then After We Run the Code Prover.
- And After Click on the Dashboard option and see the Results.
11. Test Manager Report- Baseline & Back to Back Testing :
Baseline Testing :
Goto the Model and run it. >> Click on the App >> Click on the Simulink Test >> After that Click on the Test Manager.


Click on the Test File.

Click on the Requirement option and ADD the Requirement.

After that Click on the System Under Test and Select the Model.

Click on the Inputs and Capture the Inputs.

Click on the Baseline Criteria And Capture it.

Click on the Coverage Setting and Enable the Coverage.

After that Save the Setting and Run it.
Results :

Baseline Criteria Results :

Baseline Testing Report :



Back to Back Testing :
Goto the Model and run it. >> Click on the App >> Click on the Simulink Test >> After that Click on the Test Manager.

After That Click on the Simulink Test Manager.

Click on the New And Select Test For Model Components

Select the Model. Next it




After all Test is done then Model are Created automatically.
MIL :

SIL :

Click on the Requirement and ADD the Requirement.


Simulation Harness is Added.

Click on the Inputs :

After that Click on the Coverage Setting and Enable the Coverage.
Save the Setting and Run it.
Results :

Equivalence Criteria Results :

Back To Back Testing Report :




All Files and Output Results Are Attached in below.
--------------------------------------------------------------------------------------------------------------------------
Note : In This Project MIL,SIL, Baseline Testing and Back to Back Testing etc. are Performed by without Fixed Point tool Model. While Using the Fixed point tool we are getting Not a Proper Outputs. that Way I have Use Without Fixed Point tool model and getting the Proper Outputs for the Same Test.