Main Content

Detect and Fix Model Advisor Check Violations

The Model Advisor checks your model or subsystem for modeling conditions and configuration settings that cause inaccurate or inefficient simulation and inefficient generated code and code that is unsuitable for safety-critical applications. The Model Advisor checks can help you verify compliance with industry standards and guidelines. By using the Model Advisor, you can implement consistent modeling guidelines across projects and development teams.

A subset of Model Advisor checks support edit-time checking. With edit-time checking, you can check for model conditions while you develop a model. Highlighted blocks in the model editor window alert you to issues in the model.

This tutorial uses the example model sldemo_fuelsys. This model is an air-fuel ratio control system designed with Simulink® and Stateflow®.

The figures show portions of the sldemo_fuelsys model. The top-level model is a closed-loop system that consists of a plant (Engine Gas Dynamics) and a controller (the Fuel Rate Control subsystem). The plant allows engineers to validate the controller through simulation early in the design cycle. The control logic is a Stateflow chart that specifies the different modes of operation.

Top-level of the sldemo_fuelsys model

The Fuel Rate Control subsystem in the sldemo_fuelsys model

Stateflow chart for the control logic

Detect and Fix Model Advisor Check Violations While You Edit

  1. Set your current folder to a writeable directory.

  2. Open the model sldemo_fuelsys by typing this command:

    openExample('sldemo_fuelsys')
  3. To use edit-time checking, on the Modeling tab, select Model Advisor > Edit-Time Checks. The Configuration Parameters dialog box opens and you select the check box for Edit-Time Checks.

    The highlighted blocks and subsystems indicate compliance issues.

  4. Pause over a highlighted block and click the warning icon. A dialog box provides a description of the warning. For detailed documentation on the check that detected the issue, click the question mark. These blocks contain edit-time warnings because of incorrect block names.

    Edit-time warning for the block name violation

    To exclude a block from a selected check, you can click Suppress.

  5. Open the Engine Gas Dynamics subsystem by double-clicking it. Pause over the air/fuel ratio output port and click the warning icon.

    Engine Gas Dynamics subsystem with warnings on the input and output ports

    This output port returns warnings because its name violates two checks: Check for unsupported block names and Check port block names.

  6. Address the warnings by replacing the / symbol and the space in the block name with underscores. The block is no longer highlighted.

  7. Address the warnings for the other highlighted blocks in the Engine Gas Dynamics subsystem.

Detect and Fix Model Advisor Check Violations Interactively

  1. On the Modeling tab, select Model Advisor.

  2. Select the top-level model sldemo_fuelsys from the System Hierarchy and click OK.

  3. In the left pane, in the By Product > Simulink Check > Modeling Standards > DO-178C/DO-331 folder, select:

    • Check safety-related diagnostic settings for solvers

    • Check safety-related diagnostic settings for sample time

    • Check safety-related optimization settings for logic signals

  4. Right-click DO-178C/DO-331 Checks node, and then select Run Selected Checks.

    A warning in Model Advisor for the check for safety-related diagnostic settings for solvers. The model configuration parameters are not set to the recommended values.

  5. To review the configuration parameters that are not set to the recommended values, click Check safety-related diagnostic settings for solvers.

  6. To update the parameters to the recommended values, in the toolstrip, click Fix.

    A warning in Model Advisor for the check for safety-related diagnostic settings for solvers. The model configuration parameters are not set to the recommended values.

    Action Report window displays the Model Advisor updates the parameters to the recommended values and details the result.

  7. Repeat step 6 for the Check safety-related diagnostic settings for sample time check.

  8. To verify that your model now passes, rerun the checks.

  9. To generate a results report of the Simulink Check™ checks, select the DO-178C/DO-331 Checks node, and then, in the toolstrip, click Report.

  10. Close the Model Advisor.

Next, collect metric data on the model and fix other compliance issues by using the Metrics Dashboard.