Guy on Simulink

Simulink & Model-Based Design

My First Debugging Steps

Seth sometimes tells me: Grab the low hanging fruit. When debugging Simulink models, this means looking at the information easily available.

Here are the first three things I usually look at when I see unexpected results in a model.

Signal Dimensions

When dealing with matrices and vectors, I like to enable Port/Signal Displays of Signal Dimensions and Wide Nonscalar Lines

Displaying signal dimensions

With those options enabled, I can easily identify that the following state-space system has 2 inputs, 3 outputs and 4 states.

Example model showing signal dimensions

Data Types

In Simulink, you do not need to specify the data type of each signal. In most cases, you specify the data types of a few sources and the Simulink engine propagates it to other blocks. When a model gives unexpected results, it is always a good idea to display the Port Data Types

Displaying port data types

For example, how could someone explain that Simulink thinks that 5 is equal to 1? Take a look at this model:

Displaying port data types, two Boolean signals are compared

Sample Time Colors and Legend

You always want to confirm that your signals are at the rate you expect. For that, turn on the Sample Time Colors and look at the Sample Time Legend:

Sample Time Colors

I have seen too many cases like the following model, where the user designs a position controller to run at 4ms, but forgot to set the sample time of the driver block reading the position of the motor:

Color showing unexpected sample times.

Now it's your turn

What are the things you usually look at when debugging a model? Leave a comment here.

|
  • print

コメント

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