Main Content

Projector Controller Testing Using verify and Real-Time Tests

Perform real-time testing on a target computer and verify system behavior against requirements.

This example demonstrates testing a projector control system using model simulation and real-time execution on a target computer. The tests verify the controller against its requirements using test sequences that exercise the top-level controller model. The controller uses a push button input and a temperature sensor input, and outputs signals controlling the fan, fan speed, and projector lamp.

This example uses Simulink® Real-Time™. Before beginning, review the Simulink Real-Time system requirements. This example also uses a requirements document in Microsoft® Word format.

Set the test file, model, and harness names for the example.

testFile = 'sltestProjectorCtrlTests.mldatx';
testHarness = 'Req_scenario_4';
model = 'sltestProjectorController';

Open the model:


View Requirements Links

The model and test suites link to requirements specified in ProjectorControlRTRequirements.slreqx. Open the Requirements Editor to view these requirements. Functional requirements are grouped under Index 1 and map to entities in the Simulink model. Use Highlight Links in the Requirements app in the model to trace requirements to their implementation. Test requirements are grouped under Index 2 and map to test cases in the test manager.


Highlight requirements in the test harness and test sequence editor to view the linked items.,testHarness)

Open the Test File and Configure the Real-Time Target Computer

Open the test file by entering: open(testFile)

The test file contains two test suites, each of which tests four scenarios. One suite simulates the model, while the second executes tests on a real-time target computer. The test harnesses use a Test Assessment block which tests high-level requirements. Before running the example:

  1. Configure your target computer using the Simulink Real-Time Explorer.

  2. Connect to your target computer.

  3. If your target computer is not the default target, update Target Computer in each test case's System Under Test section.

For more information on real-time configuration see System Configuration (Simulink Real-Time).

Run the Model Simulation Tests

Run the model simulation test suite. After simulation completes, click the Results and Artifacts pane in the test manager.

Expand the Req_scenario_4 results and expand the Verify Statements section. The verify statements demonstrate fail, pass, and untested results:

  • The controller does not operate in high-temperature or overheat mode, so the associated verify statements are untested.

  • The controller passes the requirement that if the lamp is on, the fan is also on: verify_lamp_implies_fan.

  • The controller passes the test that the system stays off if the on_off button is pressed when the temperature is above a limit: verify_sc4_on.

  • The controller fails the test that the system shuts off if the on_off button is pressed when the temperature is above a limit: verify_sc4_off. Resolving this failure requires modifying the OnOff Check subsystem in the main model.

For more information, see Assess Model Simulation Using verify Statements.

Select the verify_sc4_off and verify_lamp_implies_fan results to visualize the verify statement results.

Once tests have executed, verification status is automatically available in the Requirements Editor. Navigate to the Requirements Editor and turn on Verification Status in the View section to see cumulative test status.

Execute the Real-Time Tests and Review the Results

The real-time test suite verifies that real-time execution results match model simulation results, and that the verify statements pass. The test harnesses log the data using File Log blocks.

Set the current working directory to a writable directory. In the test manager, run the real-time test suite.

The Baseline Criteria Result section shows comparisons of real-time logged data to data captured from the model simulation. The results are identical.

The Verify Statements section shows similar results to the model simulation.

clear testFile testHarness model;