I am having troubles understanding the output of my scope in this simple simulink model:
I am using a fixed step solver (tried with ode3 and ode8).
Pulse type
of the puls generator is set to Sample based
and I varied the Period
and Pulse Width
.
First I set the simulation time to 10 and set the puls generator to Period = 10
and Puls width = 5
. The output of the scope is as expected:
But when I tried with simulation time 10,000 and the puls generator with Period = 1,000
and Puls width = 500
it seems my scope is wrong:
Why is the first falling edge at 5,500? I used the Autoscale button every time.
Using sim time 100,000 and Period = 10,000
and Puls width = 5,000
I don't even get a single falling edge:
Even with longer simulation time there seems to be a single rising edge at the end of the scope window.
What am I doing wrong? Is the scope not suitable for such long simulation times using fixed step solver? Or is it not "safe" to use the Autoscale button?
All of the plots you show are correct. Simulink is fine with long simulation times. It is "safe" to use the Autoscale button.
By default a scope is set to only display the last 5000 simulation time steps. Since your model is taking a step size of 1s (this is based on using the default step size of the Pulse Generator, which is 1s), in your second plot you are only seeing points from t=5000 to t=10000 (so the first down step in that time period is at 5500), and in your third plot you are only seeing points from t=95000 to t=100000 (which is a period in which the value of the pulse is low/zero).
To see all simulation times, open the Scope block's parameters (by clicking the button with a picture of a cog on it), go to the History tab, and deselect the Limit data points to last: check box.
Then rerun your simulation and press the autoscale button. You'll then see what (I think) you are expecting.