Maximum step size or automatic timing

9 views (last 30 days)
Hi,
First time here, so please bear with me while I get the hang of this.
I am modelling a dc-dc converter at high frequency using peak current control using SimPowerSystems. I know that simulink uses a variable time steps to speed up the simulation time. Now, my model relies on a set pulse to activate an SR flip flop. The trick here is that the set action only needs to happen at the beginning of the period and begone as soon as possible thereafter to give the control signal the time to reset it when necessary during the period. But with variable timing this does not always happen; i.e. the pulse sets the flipflop but does not quickly disappear because of the large step size.
Now, I was wondering what the best way to over come this is: I could set the maximum step size to for example, 1e-6 seconds or I can set my pulse generator to a period of 1e-4 and the percentage of the duty cycle to 0.01.
I noticed that there is a timing difference between the 2 methods and want to know which method (or any other that people might know) works best (i.e. fastest with highest accuracy).
Regards,
Dirk

Accepted Answer

Guy Rouleau
Guy Rouleau on 27 Apr 2012
Hi Dirk,
This is very good question.
There are 2 ways in Simulink to force a variable-time step solver to take a step at a specific time.
The most common one is zero crossing. In that case, the solver detect that some signal passed a certain threshold and goes back and forth in time t find the exact time when it happened.
I recommend looking at this doc section:
or a at demos like the one titled "Accurate Zero-Crossing Detection"
The other method is variable sample time. this is what the pulse generator block does. Every time it runs, the Pulse Generator block knows when it should run next. For example if you set it to a period of 10sec and a pulse width of 20%, it will run at 0,2,10,12,20,22,...
This doc page should help with that:
Typically, you need to write an s-function for that. This is a bit more complex to implement, but can be more efficient since you do not need to go back and forth in time to bracket the event like with zero-crossing.
If you are interested, I have a blog post where I use a variable sample time s-function here:
In your case, this will probably be simpler than the example in this post.
I think I will write another post on this topic soon.
  1 Comment
Dirk kok
Dirk kok on 30 Apr 2012
Ok. Currently, I am trying to run the simulation but it is complaining about step size violation based on the zero detection. Which clearly runs faster than with the max time step setting.
But, if I can assume that the system in between timesteps is linear I should then be able to define a time step when I know the moments of switching will happen, right?
For example: The simulation will already switch the moment the pulse generator switches (eg 0, 2, 10,12, etc period 10, 20% dutycycle).
The simulation uses a control loop which at some point during the period goes through zero and this is the moment of switching my system needs to respond too. I should be able to detect this point and then switch again, which zero crossing does. But this is where the zero crossing fails.
I read through your last blog report and one of the comments mentioned power converters and switching, which is (I think) exactly what I want to do.
But this variable time s function still confuses me a bit:
The pulse generator tells the model when to switch - clear.
How do I then register the next moment of switching since this is part of a control loop and I am not sure when it will happen inside the period?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!