How to understand sample time in Simulink
Ältere Kommentare anzeigen
Hi everyone! I was trying to understand the example of sf_boiler (Bang-Bang control using Temporal Logic) and there is something I can't understand. If I observe the Bang-Bang controller, I see that
- LED flashes every 5 seconds
- After 40 seconds, if temp<=reference, turn on boiler
- After 20 seconds that the boiler is turn, turn it off
It's not clear when the transition Heater.on.warm takes place. At every time step is it evaluated? what is the timestamp if the solver is variable-step? What step should I set to understand when the transition takes place? The sample time is equal to the time step simulation?
Thank you in advance,
Diego
Antworten (1)
Fangjun Jiang
am 8 Dez. 2011
1 Stimme
It's a good question. Sample time is not particularly just for Simulink models. It's used everywhere. It's how often do you observe or measure the data.
The time step is used to convert a continuous system into a discrete system so it can be solved by a digital computer. One example is to integrate a continuous signal. You have to do the digital calculation at every time step to be able to get the result for integration during a long period of time. And the time step needs to be small enough to make the digital calculation be close enough to the true integration.
Yes. The condition is evaluated at every time step to decide whether turn the boiler on of off. If the solver is variable step, Simulink will try to guess an initial time step and then fine tuning the time step based on other criteria such as the min and max time step limit, the tolerance for absolute error or relative error.
The time step should be smaller than all the sample times and be the common denominator of all the sample times. For example, if you have three sample times in the system, 3ms, 5ms and 10 ms, then the time step should be at least 1 ms to be able to hit all the sample time.
The boiler demo is a discrete event system, the 5 seconds, 20 or 40 seconds are all event time, not sample time, but the same principle applies. The time step needs to be at least 5 seconds to be able to hit all those event. But 5 seconds may be not good enough for other reasons. 2 seconds is not right either because it's not a denominator of 5 seconds.
9 Kommentare
braghettos
am 9 Dez. 2011
Fangjun Jiang
am 9 Dez. 2011
The time step is 1 s. It's not set up directly. If you look at the solver configuration, it's all auto with relative tolerance be 1e-3. Simulink is able to figure it out because there is an continuous integrator in the Boiler plant model.
There are temperature high than 20. I logged the data and see values from 19.7120 to 20.0320 multiple times. That is reasonable. The bang-bang controller is able to control the temperature at the set point with reasonable error. The first overshoot is a little bit bigger, that's also reasonable because initially the temperature starts from 0.
braghettos
am 9 Dez. 2011
braghettos
am 9 Dez. 2011
Fangjun Jiang
am 9 Dez. 2011
Zoom in the curve in the scope, or use a "To Workspace" block to log the temperature data, you will see it oscillate above and below 20.
braghettos
am 9 Dez. 2011
braghettos
am 9 Dez. 2011
Fangjun Jiang
am 9 Dez. 2011
Could you use "format long" and then observe the data? Maybe it's 20.0000001, it is the issue regarding floating point data.
braghettos
am 9 Dez. 2011
Kategorien
Mehr zu General Applications finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!