Project 1 - Wiper control system and Vehicle speed calculation for ABS using Wheel Speed sensor
Solution 1.
Here's a step-by-step guide to develop the Simulink model, create the SLDD (Simulink Data Dictionary) file, and perform V&V workflow for the wiper control system:
Step 1: Define the System Requirements
- Inputs:
- Rain density signal (simulated using a constant block with a knob).
- Outputs:
- Wiper motor speed in RPM (100 RPM, 200 RPM, or 500 RPM).
- Conditions:
- Low Rain Density → Output: 100 RPM.
- Medium Rain Density → Output: 200 RPM.
- High Rain Density → Output: 500 RPM.
Step 2: Design the Simulink Model
- Open MATLAB and Simulink:
- Launch MATLAB and open Simulink.
- Create a new blank model.
- Add Input Block:
- Use a Constant Block to simulate the rain density input. Configure it to use a knob for real-time adjustments.
- Add a Switch Block:
- Use Multiport Switch to define different rain density conditions:
- Low → 1
- Medium → 2
- High → 3.
- Define Conditions:
- Use Switch block and AND logic gate with Constant blocks to evaluate rain density.
- Set thresholds:
- Low Rain Density: 0–30.
- Medium Rain Density: 30–60
- High Rain Density: 60-100.
- Add Output Block:
- Use a Constant or Lookup Table to define the RPM outputs (100, 200, and 500).
- Connect the selected RPM to a Display Block and a Scope.
- Finalize Model:
- Connect the selected RPM signal to a Scope or Display Block to observe output.
- Add labels and organize blocks for clarity.
Step 3: Create SLDD (Simulink Data Dictionary)
- Open Data Dictionary:
- Go to Simulink → File → New → Data Dictionary.
- Define Parameters:
- Add parameters for rain density and RPM outputs:
- RainDensity (input, type: double).
- WiperSpeed (output, type: double, values: 100, 200, 500).
- Link to Model:
- In Simulink, go to File → Model Properties → Link to Data Dictionary.
- Link the created SLDD file.
Step 4: Perform V&V Workflow
- Requirements-Based Testing:
- Define test cases for each rain density condition (low, medium, high).
- Use a Test Sequence block or Simulink Test to create scenarios.
- Model Coverage Analysis:
- Run simulations with test cases.
- Analyze model coverage using Simulink Coverage.
- Static Verification:
- Use Simulink Design Verifier to check for unreachable states or dead logic.
- Dynamic Verification:
- Observe simulation results to verify outputs match requirements.
- Save scope output for documentation.
- Generate Report:
- Generate a verification and validation report using Simulink Report Generator.
Final Notes
- Save the Model:
- Save the Simulink model as WiperControlSystem.slx.
- Documentation:
- Include block diagram snapshots, test results, and coverage reports in the project documentation.
Screenshot:
Attached
Solution 2:
Step 1: Create the Simulink Model
1.1 Add Input Blocks
- Open Simulink and create a new model by selecting File > New > Model.
- From the Simulink Library Browser, drag four Inport blocks into the workspace.
- Rename the blocks as:
- fl (Front Left Wheel Speed)
- fr (Front Right Wheel Speed)
- rl (Rear Left Wheel Speed)
- rr (Rear Right Wheel Speed)
1.2 Add Conversion Blocks
- Drag and drop four Gain blocks from the Math Operations library.
- Set the gain values in each block to:
2πr/60
where r is the wheel radius (define this as a parameter in an SLDD file, e.g., Wheel_Radius).
Example Gain value: 2π×0.3 ≈ 0.0314
- Connect each Inport to a corresponding Gain block.
1.3 Compute the Sum of Linear Speeds
- Add a Sum block from the Math Operations library.
- Configure the Sum block to accept four inputs by setting the input parameter to ++++.
- Connect the outputs of the four Gain blocks to the Sum block.
1.4 Calculate the Average Speed
- Add another Gain block to divide the sum by 4.
- Set the Gain value to 1/4.
- Connect the output of the Sum block to the Gain block.
1.5 Add Output Block
- Add an Outport block from the library and rename it to Vehicle_Speed.
- Connect the output of the Gain block to this Outport.
1.6 Add Stateflow for ABS Logic
- Add a Stateflow Chart block from the Stateflow library.
- Design the Stateflow chart with:
- Input Variables: Linear speeds from the wheels (fl_speed, fr_speed, rl_speed, rr_speed).
- Output Variables: Valid wheel speeds for averaging.
- Logic:
- Compare each wheel speed to the calculated vehicle speed.
- If a wheel deviates beyond a threshold (Deviation_Threshold), exclude it from the averaging process.
- Connect the Stateflow chart outputs to the Sum block for valid speeds.
1.7 Model Finalization
- Save the model as ABS_Vehicle_Speed_Calculation.slx.
- Save the data dictionary (SLDD) file as ABS_Speed_Data.sldd and link it to the model.
Step 2: Link SLDD File
2.1 Create SLDD File
- Open the Model Explorer and create a new data dictionary:
- Go to File > New > Simulink Data Dictionary.
- Save it as ABS_Speed_Data.sldd.
2.2 Define Parameters in SLDD
- Add the following parameters:
- Wheel_Radius: (e.g., 0.3 meters)
- Deviation_Threshold: (e.g., 2 m/s)
- Link the SLDD file to the Simulink model:
- Go to File > Model Properties > External Data and add the SLDD file.
Step 3: Verification and Validation Workflow
3.1 Requirement Linking
- Use Simulink Requirements to document requirements for the system (e.g., speed calculation, ABS logic).
- Link requirements to specific blocks and Stateflow states.
3.2 Simulation Testing
- Create a test harness using Simulink Test:
- Go to Analysis > Test Manager > Create Test Harness.
- Simulate various scenarios, such as:
- Normal driving conditions.
- Slipping wheels (one or more wheels deviate significantly).
- All wheels locked.
3.3 Model Coverage
- Use Simulink Coverage to analyze the model.
- Ensure that all logical paths in the Stateflow chart and model blocks are covered during simulation.
3.4 Fault Injection Testing
- Simulate sensor faults using Test Manager:
- Introduce faults like zero speed or large deviations.
- Verify that the model excludes faulty sensors and calculates speed correctly.
3.5 Code Generation and Testing
- Generate code using Simulink Coder.
- Validate the code against the model to ensure functional equivalence.
Screenshot :
Attached