Test Models in Real Time
You can test your system in environments that resemble your application by using Simulink® Real-Time™ and Simulink Test™. You begin with model simulation on a development computer, then use software-in-the-loop (SIL) and processor-in-the-loop (PIL) simulation. You can use Simulink Test to create baseline, equivalence, and simulation real-time tests or convert desktop test cases to real-time tests. Real-time tests execute an application on a standalone target computer that connects to a physical system. Real-time testing can include effects of timing, signal interfaces, system response, and production hardware.
You can use real-time tests to perform:
Rapid prototyping — Iterative testing on a standalone target connected to plant hardware. You evaluate the system by testing in real time and verifying your results against requirements and model results. Using rapid prototyping results, you can change your model and update your requirements. After refining your design, you retest on the standalone target.
Hardware-in-the-loop (HIL) testing — Testing a system that has passed several stages of verification, typically SIL and PIL simulations. You can use Simulink Test on a Windows® or Linux® computer to run real-time test cases using Simulink Real-Time.
Note
To perform tests using ASAM XIL, see Install and Set Up the Simulink Test Support Package for ASAM XIL Standard and Create and Run Tests Using the ASAM XIL Standard.
Prepare, Create, and Run Real-Time Tests
To create a real-time test, you must set up your model and hardware for testing on real-time applications, then design, run, and report on the real-time test results.
Learn about each step in the process:
Prepare for Real-Time Testing — Prepare your model, tests, and components for real time testing by:
Creating test cases that verify the model against requirements and running the model simulation tests.
Configuring the real-time target settings.
Creating test harnesses and marking signals for logging. You can also add
verify
statements to Test Assessment blocks to evaluate logical expressions that asses the real-time execution.Configuring model parameters.
Create and Run Real-Time Tests — Create real-time test cases, specify test properties, run the test and view results by:
Using the Test Manager to create a baseline, equivalence, or simulation real-time test case.
Specifying the model or test harness, the simulation setting overrides, and where to load the target application from.
Using the Pre-start real-time application callback to execute commands before the real-time application executes.
Setting up test iterations to execute the test case with different data.
Executing the tests, analyzing the results in the Test Manager, and reporting the results.
Real-Time Testing Considerations
If you want to reuse a desktop simulation test case on a real-time target, use
verify
statements. In a real-time environment,verify
statement failures only appear in the Verify Statements section of the test case results in the Test Manager. You can also access information about theverify
runs usinggetVerifyRuns
.Your target computer must have a file system to use
verify
statements and test case logging.When you use
verify
statements, you can choose to log onlypass
andfail
results to reduce the transfer of data, which leads to greater simulation efficiency. To log onlypass
andfail
results, on the Tests or Harness tab, in the Test Cases section, click Suppress Untested Results.Baseline or equivalence comparisons can fail because of missing data or time-shifted data from the real-time target computer. When investigating real-time test failures, look for time shifts or missing data points.
Real-Time Testing Limitations
In Test Sequence blocks or Stateflow® charts,
assert
statements are not supported for code generation and are ignored, so no error occurs if the assert condition fails during a Simulink Real-Time simulation. However,verify
statements are supported for Simulink Real-Time code generation and automatically log results for a test case in the Test Manager. The same logging behavior is available when using a Simulink Assert block.You cannot use variant configurations.
You cannot log states or, on some platforms, output ports.
You cannot override the real-time execution sample time for applications built from models containing a Test Sequence block. The code generated for the Test Sequence block contains a hard-coded sample time. Overriding the target computer sample time can produce unexpected results.