Guy on Simulink

Simulink & Model-Based Design

New options for debugging in R2012b

Today I want to highlight R2012b features very useful when debugging a model.

Using the simulation stepping and conditional breakpoints, you should be able to run your simulation up to a certain point and move back and forth in time around this point to test things without re-running the entire simulation.

Simulation Stepper

You probably noticed that the Simulink toolbar now has 2 new buttons to step forward and backward:

Stepper toolbar

To use this feature efficiently, I think it is important to understand how it works.

On one side, the next step button is obvious. Pushing it makes the simulation move forward by one step.

Moving backward involves a bit more. Just like with your DVR (or VCR as I first wrote), to go backward data must be recorded. Under the hood, the simulation stepper saves snapshots of the simulation using SimState.

When you click the previous step button for the first time, a dialog opens:

Stepper configuration dialog

In this dialog, you can specify how many previous snapshots are saved and the number of major steps between those snapshots. Based on the size of your model, you need to choose numbers that avoid using too much memory or saving snapshots too frequently that might slow down your simulation.

Breakpoints

Before stepping backward, you first need to run and then pause the simulation. This can be done with breakpoints.

To pause at a specific simulation time, you can use the dialog shown above.

What is more interesting is to break based on signals values. When you right-click on a signal line, you can add conditional breakpoints:

Stepper toolbar

You define the conditions for the breakpoint:

Stepper toolbar

Of course, you can add multiple conditions for the same signal. Once you added all your breakpoints, you can manage them by clicking on the breakpoint icon next to the line:

Stepper toolbar

Now it's your turn

Look at the documentation for a detailed example of Stepping Through a Simulation and let us know what you think of this new debugging technique by leaving a comment here.

|
  • print

コメント

コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。