How to understand sample time in Simulink

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
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
braghettos am 9 Dez. 2011
I think that the time step simulation in this example is 1 s but it's not written anywhere. Did you see the result of the simulation? around 477 seconds the temperature goes till 20,04 degrees but, from this point, temperature never raises over 20. I think that controller is forwarding on/off to the boiler plant before that temperature increases or decreases so the final answer is: why temperature reaches 20,04 degrees once and the never upon 20?
Fangjun Jiang
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
braghettos am 9 Dez. 2011
Did you see 20.032 multiple times? I just saw 20,04 in the first overshooting but then never higher than 20 using the default solver. I also tried to used a fixed time step of 1 s with Euler solver but nothing changed. I don't understand why controller switches off boiler when temperature is 20, i really don't get it
braghettos
braghettos am 9 Dez. 2011
I mean, if the temperature is 20, cold() is true or warm() is false and it doesn't switch it off because of 20 seconds passed after the last ON
Fangjun Jiang
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
braghettos am 9 Dez. 2011
I did it and i found out that @478 the temperature decreases when the real temperature is 20,04 but @521, when the temperature is 20, the boiler switches off. Why? If the reference temperature is 20, 20<=20 is true so it cold()=true or warm()=false, why the controller switches off boiler plant?
braghettos
braghettos am 9 Dez. 2011
the transition from HIGH to NORM inside Heater.On is made every time On is reached? Passing from HIGH to NORM takes 1 time step simulation?
Fangjun Jiang
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
braghettos am 9 Dez. 2011
if the simulation time is 1s, I think that it's not possible for the temperature sensor reading such value because it increases of 0,04 or decreases of 0,004 the previous real temperature

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu General Applications finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 8 Dez. 2011

Community Treasure Hunt

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

Start Hunting!

Translated by