Project 2 - Development of TFT Cluster Speedometer Software Component
Project 2
Solution
Here is a detailed step-by-step guide for developing the TFT Cluster Speedometer Software Component in Simulink, creating the SLDD file, and performing the V&V workflow as per the requirements.
Step 1: Create the Simulink Model
- Open Simulink:
- Launch MATLAB.
- Open Simulink by typing simulink in the MATLAB Command Window.
- Create a New Model:
- In Simulink, click File > New > Model.
- Save the model as TFT_Cluster_Speedometer.slx.
Step 2: Create and Link SLDD File
- Create SLDD File:
- Open the Model Explorer (View > Model Explorer).
- Right-click and select New > Simulink Data Dictionary.
- Save the file as TFT_Cluster_Speedometer.sldd.
- Define Parameters in SLDD:
- Open the SLDD file and add the following parameters:
- Main_Filter_Speed_Value = 1.0 (default value)
- Auxiliary_Filter_Speed_Value = 1.0 (default value)
- Link SLDD to the Model:
- Open File > Model Properties.
- In the External Data tab, link the SLDD file to the model.
Step 3: Implement the Model
Subsystem 1: Calculating TFT Display Speed
- Add Input:
- Drag an Inport block from the Simulink Library Browser.
- Rename it as Average_Vehicle_Speed.
- Add Logic for Speed Limiting:
- Drag three Constant blocks:
- Lower limit (2).
- Upper limit (250).
- Add two Compare To Constant blocks:
- Compare if Average_Vehicle_Speed < 2.
- Compare if Average_Vehicle_Speed > 250.
- Add two Switch blocks:
- First switch outputs 2 if the speed is below the lower limit, else it passes Average_Vehicle_Speed.
- Second switch outputs 250 if the speed exceeds the upper limit, else it passes the output of the first switch.
- Add Output:
- Add an Outport block and name it DisplaySpeed.
- Connect Blocks:
- Connect the blocks as per the logic:
- Average_Vehicle_Speed → First Compare Block → First Switch → Second Compare Block → Second Switch → DisplaySpeed.
Subsystem 2: Main Data Filtering
- Create a Subsystem:
- Drag a Subsystem block.
- Rename it to Main Data Filtering.
- Add Trigger for 10 ms Activation:
- Double-click the subsystem.
- Replace the default content with a Triggered Subsystem.
- Set the trigger type to Time-Based with a sample time of 0.01.
- Implement Filtering Logic:
- Inside the triggered subsystem:
- Multiply DisplaySpeed by 0.65 using a Gain block.
- Divide the result by Main_Filter_Speed_Value using a Divide block.
- Multiply the output by 0.05 using another Gain block.
- Add Output:
- Add an Outport block and name it DisplaySpeed1.
- Connect Blocks:
- Connect the blocks as per the filtering logic.
Subsystem 3: Auxiliary Data Filtering
- Create a Subsystem:
- Drag another Subsystem block.
- Rename it to Auxiliary Data Filtering.
- Add Trigger for 10 ms Activation:
- Double-click the subsystem.
- Replace the default content with a Triggered Subsystem.
- Set the trigger type to Time-Based with a sample time of 0.01.
- Implement Auxiliary Filtering Logic:
- Inside the triggered subsystem:
- Multiply DisplaySpeed1 by 0.78 using a Gain block.
- Divide the result by Auxiliary_Filter_Speed_Value using a Divide block.
- Subtract 0.03 using a Subtract block.
- Add Output:
- Add an Outport block and name it DisplaySpeed_Filter.
- Connect Blocks:
- Connect the blocks as per the filtering logic.
Subsystem 4: TFT Speed Output
- Implement Absolute Difference Logic:
- Subtract DisplaySpeed_Filter from DisplaySpeed using a Subtract block.
- Pass the result through an Abs block to calculate the absolute difference.
- Compare the Difference:
- Use a Compare To Constant block to check if the difference exceeds 1.5.
- Switch Between Outputs:
- Use a Switch block:
- Input 1: DisplaySpeed.
- Input 2: DisplaySpeed_Filter.
- Condition: Output of the comparison block.
- Add Output:
- Add an Outport block and name it Vehicle_Speed_Display.
- Connect Blocks:
- Connect the blocks to implement the logic.
Step 4: Verification and Validation Workflow
4.1 Requirement Traceability
- Use Simulink Requirements to document the four requirements (1.1 to 1.4).
- Link each requirement to its corresponding subsystem or block.
4.2 Testing Using Test Harness
- Create a test harness for the model:
- Simulink Test > Test Manager > Create Test Harness.
- Define test cases:
- Test inputs for Average_Vehicle_Speed in different ranges:
- Below 2 kmph.
- Between 2 kmph and 250 kmph.
- Above 250 kmph.
4.3 Coverage Analysis
- Use Simulink Coverage to ensure all model logic paths are tested.
- Verify that:
- All branches in the model are covered.
- The filtering and output logic work as expected.
4.4 Code Generation
- Generate code using Simulink Coder.
- Perform Software-in-the-Loop (SIL) or Processor-in-the-Loop (PIL) simulations to validate the code.
Screenshot :
Attached