main content

debugging equivalence test failures using model slicer -凯发k8网页登录

this example shows how to debug simulink test equivalence failures by highlighting functional dependencies using model slicer. for more information, see (simulink check). the example files include a predefined equivalence test to use with the sldemo_fuelsys_dd_controller model. 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 the capabilities and limitations section of .

setting up the artifacts

run the test case and view the results.

1. open the sldemo_fuelsys_dd_controller model:

open_system('sldemo_fuelsys_dd_controller');

2. log the output by the signals coming out of airflow_calc and fuel_calc subsystems and the stateflow chart control_logic to generate a visualization after the analysis. to log signals, click the signal and, in the action bar, click log selected signal.

3. in the apps tab, in the model verification, validation, and test section, click simulink test to open the simulink test toolstrip.

4. in the tests tab, click simulink test manager to open the test manager.

5. to open the test file, click open and select sltestequivalencefailureex from the example folder.

6. after the test file loads, select new test case 1 in the test browser pane.

7. click run.

8. the new test results appear in the results and artifacts pane. right-click the result and select expand all under to see the equivalence criteria result and verify statements 1 section.

observe that only one signal failed: airflow_calc. consider changing the device details from 32 bits to 64 bits from hardware and implementation pane after clicking on model settings from simulation tab, if you are not able to see the failure.

entering debug session

set up the model slicer to debug the failed airflow_calc signal.

1. to compare the airflow_calc signal in different simulation modes, select the radio button next to the airflow_calc signal. another way to select a failed signal is from the signal to debug dropdown list in the toolbar.

in the plot area, compare the outputs across simulations.

2. in the tools section, click debug. note that you must plot a failed equivalence or verify signal to enable the debug button.

the debug tab opens and hides. the debug tab hides multiple test manager options.

3. to set up the model slicer, click debug 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 the step back or step forward buttons 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 use run, continue, or stop buttons to run, complete, or stop the current simulation, respectively.

2. in the test manager, click continue to failure to 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 at t = 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 the sldemo_fuelsys_dd_controller/airflow_calc/hold integrator switch block. to determine why the control port evaluates to false, highlight the control dependencies in the model.

4. enable display control dependencies from the simulation time window section 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 clicking session > close debug.

2. open the model and log all signals in the observed 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 clicking session > close debug.

2. open the model and update sldemo_fuelsys_dd_controller/airflow_calc/matlab function to 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

网站地图