Challenge

Project 1 - Wiper control system and Vehicle speed calculation for ABS using Wheel Speed sensor

1.

To develop a Simulink/Stateflow model for a wiper control system based on the given conditions and perform the complete verification and validation (V&V) workflow, follow these steps:

### Step 1: Develop the Simulink/Stateflow Model

#### 1.1 Create a New Simulink Model

1. Open MATLAB and Simulink.

2. Create a new blank model.

#### 1.2 Add Stateflow Chart for Wiper Control Logic

1. Drag and drop a "Stateflow Chart" block from the Simulink Library Browser into your model.

2. Double-click the Stateflow Chart to open the Stateflow editor.

3. Define the inputs and outputs:

Input: `rain_density`

Output: `wiper_speed`

4. Create the following states and transitions:

**State: Low**

Entry: `wiper_speed = 100`

Transition: `[rain_density == 'Medium']` to `Medium`

Transition: `[rain_density == 'High']` to `High`

**State: Medium**

Entry: `wiper_speed = 200`

Transition: `[rain_density == 'Low']` to `Low`

Transition: `[rain_density == 'High']` to `High`

**State: High**

Entry: `wiper_speed = 500`

Transition: `[rain_density == 'Low']` to `Low`

Transition: `[rain_density == 'Medium']` to `Medium`

5. Define the transitions and actions in the state flow chart.

#### 1.3 Define Inputs and Outputs in Simulink

1. Add a constant block to simulate the `rain_density` input.

2. Add an **Outport** block to output the `wiper_speed`.

3. Connect these blocks to the Stateflow Chart:

Connect the `Constant` block to the input of the state flow chart.

Connect the output of the Stateflow Chart to the `Outport` block.

#### 1.4 Configure the Simulink Model

1. Set the value of the `Constant` block to different values to simulate `Low`, `Medium`, and `High` rain densities.

2. Configure the simulation parameters:

Go to Simulation > Model Configuration Parameters.

Set the solver type to "ode45" (or a suitable solver).

Set the stop time to an appropriate value (e.g., 10 seconds).

### Step 2: Create SLDD File and Link to the Model

1. Create a new Simulink Data Dictionary (SLDD) file:

In the Simulink model, go to File -> Model Properties -> Link to Data Dictionary.

Create a new Data Dictionary file (e.g., `WiperControlSystem.sldd`).

2. Define the necessary parameters in the SLDD file:

Open the SLDD file.

Define parameters for `rain_density` and `wiper_speed`.

3. Link the SLDD file to the Simulink model:

In the model properties, ensure the data dictionary is linked to your model.

### Step 3: Verification and Validation (V&V) Workflow

#### 3.1 Requirement Specification

1. Create a requirements document specifying the wiper control logic:

Low rain density: `wiper_speed = 100 rpm`

Medium rain density: `wiper_speed = 200 rpm`

High rain density: `wiper_speed = 500 rpm`

2. Link the requirements to the model:

Use Simulink Requirements to link the requirements to the corresponding blocks in the model.

#### 3.2 Model Testing

1. Create test cases to verify the wiper control logic:

Test Case 1: `rain_density = Low`, expected `wiper_speed = 100 rpm`

Test Case 2: `rain_density = Medium`, expected `wiper_speed = 200 rpm`

Test Case 3: `rain_density = High`, expected `wiper_speed = 500 rpm`

2. Use Simulink Test to create and execute test cases:

Create a new test harness for the model.

Define the test cases using the Test Manager.

Run the test cases and verify the outputs against the expected results.

#### 3.3 Model Coverage Analysis

1. Perform model coverage analysis to ensure all states and transitions are tested.

Go to Analysis -> Coverage -> Settings.

Enable coverage analysis and run the simulation.

2. Review the coverage report to ensure all parts of the model are tested.

#### 3.4 Model Verification

1. Use Simulink Design Verifier to formally verify the model:

Go to Analysis -> Design Verifier -> Settings.

Set up properties to verify, such as ensuring the wiper speed is within the expected range.

Run the analysis and review the results.

### Step 4: Document the V&V Workflow

1. Document the entire V&V workflow, including:

requirement specifications and how they are linked to the model.

test cases and their expected outcomes.

coverage analysis results.

Verification results from the Simulink Design Verifier.

By following these steps, you will develop a Simulink/Stateflow model for the wiper control system, create an SLDD file, and perform the complete V&V workflow to ensure the model meets the specified requirements.

### Example Simulink Model Diagram

```plaintext

+---------+ +---------+ +---------+

| Constant|--->| Stateflow|--->| Outport |

| | | Chart | | |

+---------+ +---------+ +---------+

```

### Example Stateflow Chart Design

```plaintext

+--------------+ +----------------+

| Low |<--------------->| Medium |

| wiper_speed= | [rain_density ==| wiper_speed= |

| 100 | 'Medium'] | 200 |

+--------------+ +----------------+

^ ^

| |

| [rain_density == 'Low'] | [rain_density == 'High']

| |

v v

+--------------+ +----------------+

| High |<--------------->| Medium |

| wiper_speed= | [rain_density ==| wiper_speed= |

| 500 | 'Medium'] | 200 |

+--------------+ +----------------+

```

This setup ensures that the wiper speed changes according to the rain density input, and the V&V workflow ensures that the model is thoroughly tested and verified against the requirements.

2. Vehicle speed calculation for ABS using a Speed sensor

Develop Simulink/state flow model for the vehicle speed calculation unit inside the ABS system for the below conditions.

Description of Challenge:

fl, fr, rl and rr are the wheel speeds of front left, front right, rear left and rear right, respectively.

Note: Based on the conditions, requirements can be framed up.

To develop a Simulink/Stateflow model for vehicle speed calculation using wheel speed sensors within an ABS (Anti-lock Braking System) for the given conditions, follow these steps:


### Step-by-Step Implementation


### Step 1: Define the Requirements


1. Calculate the vehicle speed based on the wheel speeds of front left (fl), front right (fr), rear left (rl), and rear right (rr).

2. The vehicle speed can be calculated as the average of the wheel speeds.


### Step 2: Create a New Simulink Model


1. Open MATLAB and Simulink.

2. Create a new blank model.


### Step 3: Add Input Blocks


1. Add four **Inport** blocks to represent the wheel speeds: `fl`, `fr`, `rl`, and `rr`.


### Step 4: Add Calculation Blocks


1. Add four **Gain** blocks to normalize the wheel speeds if necessary (set the gain to 1 for simplicity in this case).

2. Add a **Sum** block to sum up the wheel speeds.

3. Add a **Constant** block with a value of 4 to represent the number of wheels.

4. Add a **Divide** block to calculate the average wheel speed (i.e., vehicle speed).


### Step 5: Add Output Block


1. Add an **Outport** block to output the calculated vehicle speed.


### Step 6: Connect the Blocks


1. Connect the four Inport blocks to the Sum block.

2. Connect the output of the Sum block to the Divide block.

3. Connect the Constant block (with value 4) to the denominator input of the Divide block.

4. Connect the output of the Divide block to the Outport block.


### Step 7: Create SLDD File and Link to the Model


1. Create a new Simulink Data Dictionary (SLDD) file:

- In the Simulink model, go to File -> Model Properties -> Link to Data Dictionary.

- Create a new Data Dictionary file (e.g., `VehicleSpeedCalculation.sldd`).


2. Define the necessary parameters in the SLDD file:

- Open the SLDD file.

- Define parameters for `fl`, `fr`, `rl`, `rr`, and `vehicle_speed`.


3. Link the SLDD file to the Simulink model:

- In the model properties, ensure the data dictionary is linked to your model.


### Step 8: Verification and Validation (V&V) Workflow


#### 8.1 Requirement Specification


1. Create a requirements document specifying the vehicle speed calculation logic:

- The vehicle speed is the average of the wheel speeds: \( \text{vehicle\_speed} = \frac{fl + fr + rl + rr}{4} \).


2. Link the requirements to the model:

- Use Simulink Requirements to link the requirements to the corresponding blocks in the model.


#### 8.2 Model Testing


1. Create test cases to verify the vehicle speed calculation logic:

- Test Case 1: `fl = 100`, `fr = 100`, `rl = 100`, `rr = 100`, expected `vehicle_speed = 100`

- Test Case 2: `fl = 80`, `fr = 90`, `rl = 85`, `rr = 95`, expected `vehicle_speed = 87.5`


2. Use Simulink Test to create and execute test cases:

- Create a new test harness for the model.

- Define the test cases using the Test Manager.

- Run the test cases and verify the outputs against the expected results.


#### 8.3 Model Coverage Analysis


1. Perform model coverage analysis to ensure all parts of the model are tested:

- Go to Analysis -> Coverage -> Settings.

- Enable coverage analysis and run the simulation.


2. Review the coverage report to ensure all parts of the model are tested.


#### 8.4 Model Verification


1. Use Simulink Design Verifier to formally verify the model:

- Go to Analysis -> Design Verifier -> Settings.

- Set up properties to verify, such as ensuring the vehicle speed is calculated correctly.

- Run the analysis and review the results.


### Step 9: Document the V&V Workflow


1. Document the entire V&V workflow, including:

- Requirement specifications and how they are linked to the model.

- Test cases and their expected outcomes.

- Coverage analysis results.

- Verification results from Simulink Design Verifier.


### Example Simulink Model Diagram


```plaintext

+--------+ +--------+ +--------+ +--------+ +--------+

| Inport | | Inport | | Inport | | Inport | | Outport|

| fl | | fr | | rl | | rr | |vehicle_|

+--------+ +--------+ +--------+ +--------+ | speed |

| | | | |

v v v v v

+---------------------------------------------------------+

| Sum |

| fl + fr + rl + rr |

+---------------------------------------------------------+

|

v

+--------+ +-----------+

| Divide |<------| Constant |

| | | 4 |

+--------+ +-----------+

|

v

+--------+

| Outport|

|vehicle_|

| speed |

+--------+

```


### Detailed Explanation of the Stateflow Chart


Since the logic is straightforward, we will use basic Simulink blocks. However, if the logic were more complex, involving state transitions, we could use a Stateflow chart.


This setup ensures that the vehicle speed is calculated as the average of the wheel speeds and provides a framework for verification and validation to ensure the model meets the specified requirements.


### SLDD File Creation


1. Create a new Simulink Data Dictionary (`VehicleSpeedCalculation.sldd`).

2. Add entries for:

- `fl`, `fr`, `rl`, `rr` (wheel speeds as inputs)

- `vehicle_speed` (output)


### Verification and Validation


1. **Requirements Traceability**: Link requirements to model components.

2. **Test Harness**: Create test harnesses for unit testing.

3. **Test Cases**: Implement test cases for different scenarios.

4. **Model Coverage**: Ensure all logic paths are tested.

5. **Design Verification**: Use Simulink Design Verifier for formal verification.


By following these steps, you will create a robust Simulink model for vehicle speed calculation in an ABS system, linked to an SLDD file, and ensure thorough verification and validation.

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.