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.
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.
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.
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.
In this example, you create a simple test sequence for a transmission shift logic controller.
Open the model. At the command line, enter
and select Test Harness > Create for ‘shift_controller’.
In the Create Test Harness dialog box, under Sources
and Sinks, change
The schematic displays the closed-loop configuration between the Test Sequence block and the component under test.
Click OK. The test harness
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.
Create the test sequence.
Rename the first step
add the step actions:
speed = 10*ramp(et); throttle = 100;
Add a second step
Stop and add
the step actions:
throttle = 0; speed = 0;
Accelerate and select Add
sub-step. Create a total of four substeps for
These steps check the component under test during the test sequence.
Add a constant to the block. In the Symbols pane,
hover over Constant and click Add.
Limit for the constant name.
Limit and click Edit.
In the Initial value field, enter
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
Accelerate group to
a When decomposition sequence. Right-click
select When decomposition.
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)
The fourth step
Else takes no
Else handles conditions that make no other
Add a scope to the harness and connect the
gear signals to the scope.
Set the model simulation time to 15 seconds and simulate the test harness.