Main Content

Prepare for Real-Time Testing

Use Simulink® Test™ to execute simulation tests and prepare your model for real-time tests. By testing your model using desktop simulation, you can refine and debug your design before you run real-time tests, which typically take longer to execute. After you complete your simulation tests, you can configure your target computer, and the model or test harness for testing with Simulink Real-Time™. You can create baseline, equivalence, or simulation test cases to test your system in real-time. If you choose a simulation test case, you can add verify and assert statements to blocks in your model to assess real-time execution and define test criteria.

Complete Model Simulation Testing

Real-time testing often takes longer than comparative model testing, especially if you execute a suite of real-time tests that cover several scenarios. Before executing real-time tests, complete testing using desktop simulation. Then, use the desktop simulation results to:

  • Debug your model or make changes to your design to meet requirements.

  • Debug your test sequence. Use the debugging features in the Test Sequence Editor. See Debug a Test Sequence.

  • Update your requirements and add corresponding test cases.

When you create the simulation test cases, you can define the test input data in external files and map the data to inputs in the model. Later, when you convert the test cases to real-time test cases, the test cases use the same mapping as the original inputs. For more information, see Use External Data for Real-Time Tests. Alternatively, you can create real-time test cases and specify the test properties in the Test Manager after you configure your model. See Create and Run Real-Time Tests.

Set Up the Target Computer

Real-time testing requires a target computer or external hardware test bench. running Simulink Real-Time. Use the Simulink Real-Time Explorer to configure the target computer configuration settings. For more information, see Simulink Real-Time Explorer (Simulink Real-Time) and Target Computer Settings (Simulink Real-Time). Alternatively, you can configure the settings programmatically. See Simulink Real-Time Command-Line Interface in MATLAB (Simulink Real-Time).

Configure the Model for Testing

Before you create a real-time test case, you can configure your model to fit your testing needs. You can create a test harness to test your model in an isolated environment, select signals for logging, and add assessments to your model or test harness to execute in real time.

Create a Test Harness

You can create test harnesses for your top-level model or one or more components in your model. You can also reuse test harnesses from model simulation testing. For more information about test harnesses, see Test Harness and Model Relationship and Create or Import Test Harnesses and Select Properties.

Configure Signals for Logging

Before you create a real-time test case, configure logged signals:

  1. In the Configuration Parameters dialog box, in the Data Import/Export pane enable the Signal logging parameter.

  2. In your model, select a signal to log.

  3. In the Property Inspector, select Log signal data.

  4. Enter a name in the Signal name field.

You can assign unnamed signals a default name that does not match the name of the baseline or equivalence signal. In this example test harness, the logged signals are fan_on, fan_speed, and lamp_on. The logging badge indicates that the signal is configured for logging.

Test harness showing logged signals

Add Run-Time Assessments

When you create a baseline or equivalence real-time test case, you compare signal data to baseline or equivalence criteria that you specify in your test. If you plan to create simulation real-time test case, you can assess behavior by adding verify statements in Test Assessment blocks in your model or test harness. For more information about test case type, see Add a Real-Time Test Case.

verify statements evaluate logical expressions and return pass, fail or untested results. For more information about adding verify statements to Test Assessment blocks, see Verify Model Simulation by Using when Decomposition. For more information about using verify statements in real-time tests, see Real-Time Testing Considerations.

Set Configuration Parameters

Before you perform real-time testing, you must configure the code generation and data import and export parameters in your model or test harness.

Code Generation

A real-time test case requires a real-time system target file. To confirm or set the system target file for your model:

  1. In the Apps tab, click Simulink Coder. In the Prepare section, click Settings.

  2. In the Configuration Parameters dialog box, click Code Generation and verify that the System target file parameter is set to a Simulink Real-Time model. If the file is incorrect, next to System target file click Browse and select the Simulink Real-Time system target file.

If your model requires a different system target file, you can set the parameter using a test case or test suite callback. For more information, see Assign Code to Real-Time Callbacks.

For more information, see System target file (Simulink Coder).

Data Import/Export Format

To use your model in a real-time test case, your model must use a data format other than dataset. To set the data format:

  1. Open the Configuration Parameters dialog box. In the Modeling tab, click Model Settings.

  2. In the left pane of the Configuration Parameters dialog box, select Data Import/Export.

  3. In the Format options section of the right pane, set the Save format field.

See Also

Apps

Functions

Topics