Documentation

Introduction to Test Sequences

You can use the Test Sequence block to specify test steps, actions, and transitions. With timeseries inputs, you supply time-defined test vectors. However, the test sequences you create can react to signal and temporal conditions. You can also use them to assess simulation.

Structure of a Test Sequence

A test sequence consists of test steps arranged in a hierarchy. You can use transitions to define the test sequence progression within a hierarchy level.

A test step contains actions and transitions you define using MATLAB® as the action language. Actions execute at the beginning of the step. You use actions to define commands for each test step, such as setting signal levels, verifying logical conditions, or setting variables. You use test step transitions to define conditions that determine when the test sequence exits the current step and enters another step.

A standard transition occurs on a condition that you specify. Once the step exits, the next step that you specify executes.

Test Sequence Hierarchy

Arrange the test sequence hierarchy using parent steps and substeps. Substeps can activate only if the parent step is active. A group of steps in the same hierarchy level shares a common transition type. When you create a test step, the step becomes a transition option for other steps in the same group.

Step Transitions

In a test sequence, the top hierarchy level uses a standard transition. Test sequence execution begins with the top step in the group, and proceeds according to the transition conditions and next steps.

You can change lower-level groups to switch between steps based on signal conditions defined in the step. This switching condition is called a When decomposition. In this case, the parent step evaluates, and then the substeps execute based on their associated conditions. The conditions determine the order in which the substeps execute. For example, the first substep in the table does not necessarily execute first. If multiple steps in a When decomposition group have conditions that are true, the highest step with the true condition is active.

Create a Basic Test Sequence

In this example, you create a simple test sequence for a transmission shift logic controller.

  1. Open the model. At the command line, enter

    sltestTestSequenceExample
  2. Right-click the shift_controller subsystem and select Test Harness > Create for ‘shift_controller’.

  3. In the Create Test Harness dialog box, under Sources and Sinks, change Inport to Test Sequence.

    The schematic displays the closed-loop configuration between the Test Sequence block and the component under test.

  4. Click OK. The test harness for the shift_controller subsystem opens. Double-click the Test Sequence block.

    The Test Sequence Editor opens and displays action and transition tips. Click the X to close the tips. The first line in a Step cell defines the step name.

  5. Create the test sequence.

    1. Rename the first step Accelerate and add the step actions:

      speed = 10*ramp(et);
      throttle = 100;
    2. Add a second step Stop and add the step actions:

      throttle = 0;
      speed = 0;
    3. Right-click Accelerate and select Add sub-step. Create a total of four substeps for Accelerate.

      These steps check the component under test during the test sequence.

    4. Add a constant to the block. In the Symbols pane, hover over Constant and click Add. Enter Limit for the constant name.

    5. Hover over Limit and click Edit. In the Initial value field, enter 2. Click OK.

    6. In the Transition column, enter the transition condition for Accelerate. This condition uses the duration operator and transitions to the next step when the system is in fourth gear for 2 seconds.

      duration(gear == 4) >= Limit

      In the Next Step column, select Stop.

    7. Change the Accelerate group to a When decomposition sequence. Right-click Accelerate and select When decomposition.

    8. Enter the names and actions for the substeps.

      Check1st when gear == 1
      verify(speed < 45)
      Check2nd when gear == 2
      verify(speed < 75)
      Check3rd when gear == 3
      verify(speed < 105)
      Else

      The fourth step Else takes no action. Else handles conditions that make no other when statement valid.

  6. Add a scope to the harness and connect the speed, throttle, and gear signals to the scope.

  7. Set the model simulation time to 15 seconds and simulate the test harness.

See Also

| |

Related Topics

Was this topic helpful?