Challenge

Project 2 - Development of TFT Cluster Speedometer Software Component

Develop the Simulink model based on the given requirements and also create SLDD file and link the same to the model.

Perform the complete V and V workflow for the obtained model

Ans:

Development of TFT Cluster Speedometer Software Component

Cluster Instrument receives the signals from other ECU 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.

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

}

SLDD Creation:

A data dictionary file is created. All the signals such as input, output and the local signals are added in the Simulink data dictionary.

The following image shows signals in the Sldd file.

Requirement Tagging:

Requirement tagging is done using the Requirement Manager app. At first the app is launched within the Matlab environment. Then we open the requirement editor and add new requirement set using the plus button in the top ribbon.

After the requirement set added, we can add requirements to that particular set. Here, we have created a set and added the four requirements to that set. A file with extension slreqx is generated after the requirement set is added.

Then, each requirement is linked with the subsystem of the model where it is implemented. The subsystem in the simulink model is selected first, then in the requirement editor window particular requirement is linked with the ‘Add Link’ on the top

JMAAB Checks:

Then the model is check for JMAAB compliance. The model advisor tool is loaded and JMAAB checks were selected. Then checks were run and a report is generated.

Simulink Design Verifier:

In the Simulink design verifier, we check the model for any design errors that may slipped through from the previous checks(i.e. jmaab). The design verifier tool is loaded from the App section.

Now we check for design errors by clicking green play button at the top. After few seconds the detection is completed and a report is also generated. Here is the summary of the verifier-

SLDV Test Generation report:

In the next step, test geneartion is done in the Design verifier tool. The test generation coverage is set to MCDC and other settings were left at default value.

By clicking the run button the tests were generated and a html report is also created.

Model in Loop test + coverage:

Before going in to Model in loop testing the few configuration setting settings were taken care of such as Enabling coverage and setting Coverage metrics to MCDC.

Now to test the model first we need a test harness. The test harness can be created by right clicking on the top level subsystem and selecting ‘Test Harness ’ from the context menu. This opens a dialogue box, where we can select the input and output of the component or model under test. Here we have selected signal builder for input and to workspace block for the output. The figure below shows the dialogue box parameters used-

Now, test cases were written for the model. They are written in a spreadsheet and then imported to the signal builder in test harness. A screenshot of the test cases is shown below-

This data is then imported to the signal builder using the import form file option. Both the calculated output and the model output is send to workspace using ‘To Workspace’ block. These two workspace variables will be compared after the test.

So,the final model of the harness looks like the fig. below-

he model is then run for the total time of 1 sec with fixed step(discrete) solver with sample time of 0.01 sec. The output from test is then compared with the calculated value using the data inspector tool.

After we have run the model, the here is the comparison graph-

Software in Loop Test:

The software in loop (SIL) test is also performed by making another test harness. In SIL, we actually test code of the model instead of the simulink blocks.

The test harness creation is same as of MIL , but with two more steps.

  • First, the top model is made atomic subsystem (from the subsystem parameters dialog box).

  • Then, we open the test harness dialog as before, input the same parameters and additionally we go to advanced section and select Software in loop .

  • After that similar steps were followed as MIL to make the final harness for the SIL test.


Code Generation:

To generate C- code for the model, we can use the Embedded Coder app within Matlab. But, first we have to adjust the code generation settings in the model configurator. The target file is st to ert.tlc which represents embedded real time coder.

/*
* Event Support License -- for demonstration use and event support. Not
* for government, research, commercial, or other organizational use.
*
* File: TFTCluster_Exercise.c
*
* Code generated for Simulink model 'TFTCluster_Exercise'.
*
* Model version : 1.17
* Simulink Coder version : 9.7 (R2022a) 13-Nov-2021
* C/C++ source code generated on : Thu Feb 23 20:54:14 2023
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "TFTCluster_Exercise.h"
#include "rtwtypes.h"
#include "TFTCluster_Exercise_private.h"
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
uint16_T Out_VehicleSpeedDisplay; /* '<S9>/Switch' */
/* Definition for custom storage class: Localizable */
static uint16_T DisplaySpeed1; /* '<S8>/Add' */
static uint16_T DisplaySpeedFilter; /* '<S5>/Add' */
/* Real-time model */
static RT_MODEL_TFTCluster_Exercise_T TFTCluster_Exercise_M_;
RT_MODEL_TFTCluster_Exercise_T *const TFTCluster_Exercise_M =
&TFTCluster_Exercise_M_;
/* Model step function */
void TFTCluster_Exercise_step(void)
{
/* Outputs for Atomic SubSystem: '<Root>/Subsystem' */
/* Outputs for Atomic SubSystem: '<S1>/Subsystem1' */
/* Outputs for Atomic SubSystem: '<S2>/Subsystem' */
/* Switch: '<S10>/Switch2' incorporates:
* Inport: '<Root>/Avg_VehicleSpeed'
* RelationalOperator: '<S10>/LowerRelop1'
* RelationalOperator: '<S10>/UpperRelop'
* Switch: '<S10>/Switch'
*/
if (Avg_VehicleSpeed > 250) {
/* Switch: '<S10>/Switch2' incorporates:
* Constant: '<S7>/Upper_Limit'
*/
Out_VehicleSpeedDisplay = 250U;
} else if (Avg_VehicleSpeed < 2) {
/* Switch: '<S10>/Switch2' incorporates:
* Constant: '<S7>/Lower_Limit'
* Switch: '<S10>/Switch'
*/
Out_VehicleSpeedDisplay = 2U;
} else {
/* Switch: '<S10>/Switch2' */
Out_VehicleSpeedDisplay = Avg_VehicleSpeed;
}
/* End of Switch: '<S10>/Switch2' */
/* Outputs for Enabled SubSystem: '<S4>/AuxDataFilter' incorporates:
* EnablePort: '<S5>/Enable'
*/
/* Outputs for Enabled SubSystem: '<S4>/MainDataFilter' incorporates:
* EnablePort: '<S8>/Enable'
*/
/* RelationalOperator: '<S6>/Compare' incorporates:
* Constant: '<S6>/Constant'
* Inport: '<Root>/Timer_Input'
* Math: '<S4>/Rem'
*/
if ((uint16_T)(Timer_Input % 10) == 0) {
/* Product: '<S8>/Divide' incorporates:
* Inport: '<Root>/Main_Filter'
*/
if (Main_Filter == 0U) {
/* Sum: '<S8>/Add' */
DisplaySpeed1 = MAX_uint16_T;
/* Divide by zero handler */
} else {
/* Sum: '<S8>/Add' incorporates:
* Gain: '<S8>/Gain'
*/
DisplaySpeed1 = (uint16_T)(((21299U * Out_VehicleSpeedDisplay) >> 15) /
Main_Filter);
}
/* End of Product: '<S8>/Divide' */
/* Product: '<S5>/Divide' incorporates:
* Inport: '<Root>/Aux_Filter'
*/
if (Aux_Filter == 0U) {
/* Sum: '<S5>/Add' */
DisplaySpeedFilter = MAX_uint16_T;
/* Divide by zero handler */
} else {
/* Sum: '<S5>/Add' incorporates:
* Gain: '<S5>/Gain'
*/
DisplaySpeedFilter = (uint16_T)(((25559U * DisplaySpeed1) >> 15) /
Aux_Filter);
}
/* End of Product: '<S5>/Divide' */
}
/* End of RelationalOperator: '<S6>/Compare' */
/* End of Outputs for SubSystem: '<S4>/MainDataFilter' */
/* End of Outputs for SubSystem: '<S4>/AuxDataFilter' */
/* Switch: '<S9>/Switch' incorporates:
* Constant: '<S11>/Constant'
* RelationalOperator: '<S11>/Compare'
* Sum: '<S9>/Subtract'
*/
if ((uint16_T)(Out_VehicleSpeedDisplay - DisplaySpeedFilter) <= 2) {
/* Switch: '<S10>/Switch2' incorporates:
* Switch: '<S9>/Switch'
*/
Out_VehicleSpeedDisplay = DisplaySpeedFilter;
}
/* End of Switch: '<S9>/Switch' */
/* End of Outputs for SubSystem: '<S2>/Subsystem' */
/* End of Outputs for SubSystem: '<S1>/Subsystem1' */
/* End of Outputs for SubSystem: '<Root>/Subsystem' */
}
/* Model initialize function */
void TFTCluster_Exercise_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void TFTCluster_Exercise_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
BaseLine Test:
Back To Back Test
Conclusion:
The complete V and V workflow for the obtained model was developed and attached.
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.