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!
This tip helps me a lot. thank you for your share.