Main Content

Run Simulink PLC Coder Model Advisor Checks

The Simulink PLC Coder checks in Simulink Model Advisor checks a model or subsystem for variable names, name lengths, comments, and so on that can result in a failure to import the generated code. The Model Advisor produces a report that lists the checks that were run and the conditions that caused warnings.

Open the Model Advisor

To open the Model Advisor:

  • In the Modeling tab, select Model Advisor. In the System Selector dialog box, select the model or subsystem that you want to analyze, and click OK.

  • Open the PLC Coder app. Select the model or subsystem. In the PLC Code tab, select Model Advisor.

Run Checks in the Model Advisor

In the Model Advisor window, you can run individual checks or a group of checks. To run a check, select the check box next to the check, and then click Run This Check.

To run a group of checks within a folder:

  1. Select the checks that you want to run.

  2. Select the folder that contains these checks, and then click Run Selected Checks.

For example, to run all the checks in the Industry standard checks folder, select the folder, and then click Run Selected Checks.

Display Check Results in the Model Advisor Report

To display an HTML report of the check results, before you run the checks, select Show report after run. Use this setting to generate a report for all the checks in the Simulink PLC Coder folder or for all checks within a subfolder, such as the Industry standard checks folder.

If you did not select Show report after run, you can generate a report after you run the checks by selecting Generate Report. Specify the Directory, Filename, and Format of the HTML report that you want to generate.

This report shows typical results for a run of the Standard industry checks folder.

The report displays a run summary of the checks in the specified folder. As you run the checks, the Model Advisor updates the reports with the latest information for each check in the folder. When you run the checks at different times, timestamps appear at the top right of the report to indicate when checks have been run. Checks that occurred during previous runs have a timestamp following the check name. You can filter checks in the report to show checks that display a Warning, show checks that Passed, and so on.

Fix Warnings or Failures

When a model or subsystem has conditions that do not meet Industry standard checks, checks can fail. After you run a Model Advisor analysis, this icon indicates checks that have warnings. A warning result is informational. You can fix the reported issue or move on to the next task.

To fix warnings or failures, in the Result subpane, view the items that caused the warnings, take action to fix those items and rerun the checks.

Save and Restore Model Advisor State

By default Simulink® saves the state of the most recent Model Advisor session. The next time Model Advisor is activated, it returns to the saved state. You can also save the current settings of the Model Advisor to a named restore point. A restore point is a snapshot in time of the model, base workspace, and Model Advisor. Later, you can restore your saved settings by loading the restore point data into the Model Advisor.

You can use this data restore point to revert changes to your model in response to recommendations from the Model Advisor. For example, you can save a model and restore point to undo your changes if the Model Advisor reports a warning after running a certain check. You can also restore the default configuration of the Model Advisor. In the Model Advisor window, select Settings > Restore Default Configuration.

To save the Model Advisor state, in the Model Advisor window, select File > Save Restore Point As. Enter a Name and Description, and then click Save. You can save more than one restore point.

To restore a Model Advisor state, in the Model Advisor window, select File > Load Restore Point. Select the restore point and click Load. When you load a restore point, the Model Advisor warns that the restoration overwrites the current settings.