Simulink - Tips and Tricks (Debugging)

Simulink - Tips and Tricks (Debugging)

Hello Everyone,
Its been quite a while since I have penned down my last article regarding use of simulink to learn basic mathematics concept. Today, I would like to share with this article some of the basic tips and tricks pertaining to Simulink.

Simulink is akin to regular command based programming languages, except the fact most of the programming is done graphically with the help of predefined or customized set of block libraries. Now, it is no trade secret that one of the most important aspect of a programming tool is the availability of debugging function which can help the developer to step through the code for spotting potential errors, determining execution order, etc. Similar functions exist in Simulink too for debugging and analyzing the execution order.

Simulink Debugger

Lets take an example of how a Simulink debugger works. Shown below is a very simple model which I created to mimic an integrator. On the top is my custom integrator model, and below is the equivalent [1/s] integrator from simulink library. I am using a fixed step solver, with a time step of 1 second.

So, if one were to analyze how the output of the system looks like, the common way is to add a scope block and run the model. However this is always not the most efficiency way to validate the output of the model. A lot of time it is necessary to check the values in different branches to validate if everything is being calculated as expected before converging to the final output. In such cases, the Simulink debugger is really helpful

To enable the debugger, go to the the navigation tab -> Simulation -> Data Display in Simulation -> Toggle Value Labels when Clicked. You can of course use the Hovering option too.

Now go to the Simulink model and click on the branches which you are interested in. On clicking, a yellow box will appear along the branch. Once done locate the step forward button (next to the run button) as shown below in red boxes. This will enable the developer to step through the code.

 

Click the button, and the result at different time steps in the selected branches will be displayed as below.

Simulation results at time 1 second

Simulation results at time 7 second

In order to step back through the code, click the back arrow marked in blue box. To stop the simulation at any time, hit the stop button marked in green!

Voila! You are done. I hope this article was useful to you. In the next article I will include the concept of execution order, which is a very important concept especially in the development of large scale model based design! 

So stay tuned. If you like the article or have some suggestions, please leave your feedback below!

/Masoom

This tip helps me a lot. thank you for your share.

Like
Reply

To view or add a comment, sign in

More articles by Masoom Kumar

  • Power & Torque for Dummies - Part II

    The article is the second article in the series Power and Torque for dummies. It is recommended to go through the first…

  • Power and Torque for Dummies - Part I

    Power and Torque are two important physical measurement units which is used to define the performance aspect of a…

    2 Comments
  • How Mazda's Skyactiv D technology works?

    Rewind to 2012, when Mazda introduced its Skyactiv engine to the world. It was a revelation during its time.

    2 Comments
  • RoHR - Rate of Heat Release

    Welcome back everyone. Today my article is related to a concept - Heat Release Rate (HRR).

    7 Comments
  • Mathematics through Simulink - Differential Equation

    I have always liked mathematics while pursuing my Bachelor’s degree. However, most of the mathematical education was…

    7 Comments
  • SENSOR III - IAT - Intake Air Temperature Sensor

    Today we will be discussing about intake air temperature sensor. It is commonly known as MAT (Manifold air temperature)…

  • SENSOR II - MAP - Manifold Absolute Pressure Sensor

    Welcome back! Today our discussion is about MAP (Manifold Abosolute Pressure Sensor). As the name suggests, it measures…

    5 Comments
  • Sensor I - Engine Position Sensor - Implementation

    In the last section, we talked about the sensing principles of the position sensor. For a quick recap they are divided…

    5 Comments
  • Sensor I - Engine Position Sensor (Sensing Principles)

    An engine position sensor's prime function is to convey the angular position of the engine to the ECU. The ECU uses…

  • PART III - Sensors / Actuators Crash Course

    Hi! Welcome to the third article in the fuel injection series. I hope the last two articles should have served as a…

    2 Comments

Others also viewed

Explore content categories