How to understand sample time in Simulink

8 views (last 30 days)
braghettos
braghettos on 8 Dec 2011
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

Answers (1)

Fangjun Jiang
Fangjun Jiang on 8 Dec 2011
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 Comments
Fangjun Jiang
Fangjun Jiang on 9 Dec 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 on 9 Dec 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

Sign in to comment.

Categories

Find more on General Applications in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!