Main Content

Debugging Equivalence Test Failures Using Model Slicer

This example shows how to debug Simulink Test equivalence failures by highlighting functional dependencies using Model Slicer. For more information, seeHighlight Functional Dependencies(Simulink Check). The example files include a predefined equivalence test to use with thesldemo_fuelsys_dd_controllermodel. The sample test case compares the model simulation in normal and software-in-the-loop (SIL) mode. The model includes a numerical discrepancy. In this example, you use Model Slicer to trace the faults and identify the discrepancy. For more information about debugging test failures, see theCapabilities and Limitationssection ofDebugging Test Failures Using Model Slicer.

Setting Up the Artifacts

Run the test case and view the results.

1. Open thesldemo_fuelsys_dd_controllermodel:

open_system('sldemo_fuelsys_dd_controller');

2.Log the output by the signals coming out ofairflow_calcandfuel_calcsubsystems and the Stateflow chartcontrol_logicto generate a visualization after the analysis. To log signals, click the signal and, in the action bar, click Log Selected Signal.

3. In theAppstab, in theModel Verification, Validation, and Testsection, clickSimulink Testto open the Simulink Test toolstrip.

4. In theTeststab, clickSimulink Test Managerto open the Test Manager.

5. To open the test file, clickOpenand selectslTestEquivalenceFailureExfrom the example folder.

6. After the test file loads, select新的测试Case 1in theTest Browserpane.

7. ClickRun.

8. The new test results appear in theResults and Artifactspane. Right-click the result and selectExpand All Under去看Equivalence Criteria ResultandVerify Statements 1section.

Observe that only one signal failed:airflow_calc. Consider changing theDevice detailsfrom 32 bits to 64 bits fromHardware and Implementationpane after clicking onModel Settingsfrom Simulation tab, if you are not able to see the failure.

Entering Debug Session

Set up the Model Slicer to debug the failedairflow_calcsignal.

1. To compare theairflow_calcsignal in different simulation modes, select the radio button next to theairflow_calcsignal. Another way to select a failed signal is from theSignal to Debugdropdown list in the toolbar.

In the plot area, compare the outputs across simulations.

2.In theToolssection, clickDebug. Note that you must plot a failed equivalence or verify signal to enable theDebugbutton.

TheDebugtab opens and hides. The debug tab hides multiple Test Manager options.

3. To set up the Model Slicer, clickDebug Using Slicer.

Model Slicer prepares the debugging session by:

  1. Rerunning the test case and creating new debugging results. This action ensures that the failure still exists in the current state of the test model.

  2. Launching the Model Slicer on the test model.

  3. Automatically plotting the selected failed signal in the debugging results and setting the failed signal as the starting time point.

  4. Pausing the simulation at the model start time to continue debugging.

Debugging Using Model Slicer

Identify the reason for the failure by using the debugging features of the Model Slicer.

1. Use theStep BackorStep Forwardbuttons to move one step back or forward in simulation time. The left data cursor moves to the current simulation time. Observe the changes in the data dependencies by noting the changed model highlighting and port value labels for the active signals at every time stamp.

You can also useRun,Continue, orStopbuttons to run, complete, or stop the current simulation, respectively.

2.In the Test Manager, clickContinue to Failureto continue the model simulation to the beginning of the next failure region. The data cursors show the bounds of the failure region.

3. Observe these changes at the failure:

  • Simulation pauses atT = 4.81.

  • The data cursors update accordingly.

From the Model Slicer highlighting, you can observe the branch of the model that causes the error.

Notice that the constant, 0 passes through thesldemo_fuelsys_dd_controller/airflow_calc/hold integratorSwitch block. To determine why the control port evaluates tofalse, highlight the control dependencies in the model.

4. Enable显示控制依赖关系from theSimulation Time Windowsection in the Model Slicer Dialog pane. Observe the chain of blocks that the Model Slicer highlights as the probable cause of the discrepancy. To further visualize the numerical differences between the simulation modes, end the debugging session, log the signals in the active chain, and debug the model again.

Refining the Debugging Results

1. Exit the debugging session by clickingSession > Close Debug.

2.打开模型观察和记录所有信号ved path before.

3. Save the model.

4. Repeat steps 1 to 3 from the Debug Using Model Slicer section.

Observe that the Enumerated Constant value is being set in the MATLAB function block based on the simulation mode.

Incorporating the Fix

1. Exit the debugging session by clickingSESSION>Close Debug.

2.Open the model and updatesldemo_fuelsys_dd_controller/airflow_calc/MATLAB functionto return the same value irrespective of the simulation mode.

3. Save the model.

4. Run the test case and view the results.

Observe that the test results test results pass.

See Also

Baidu
map