How is the buffer block filled in an enabled subsystem?
6 views (last 30 days)
Good Morning All
I am trying to log a signal with a sampling frequency of 250 Hz for 6 seconds in a buffer whose size is 1500 (6*250). When putting the components without an enabled subsystem everything works fine and the buffer gets filled and returns the acquired signal. However, this doesn't work when I put the buffer inside an subsystem that is enabled for 6 secs. It works maximum for (3.5*250) buffer size. The enable block is set to hold the output so I think no problems from this prespective.
For more elaboration please see the picture I attached.
I read the answers on this topic but it didn't answer this specific question and the documentation of the buffer block didn't help me understanding this also https://de.mathworks.com/matlabcentral/answers/101750-how-does-the-buffer-block-from-the-signal-processing-blockset-behave-when-placed-in-an-enabled-subsy
I appericate your help !
Sharan Paramasivam Murugesan on 22 Aug 2017
The link you have mentioned actually explains the behavior of a buffer block inside an enabled subsystem. To explain further with a simpler example, I have attached a model (simple_example.mdl). Here is the explanation for the attached model.
Total run time : 10 secs
Counter: Produces 1 sample every second. So it should produce 10 samples overall.
Enabled subsystem: Enabled from 2 sec till 8 sec (period of 6 secs)
Buffer size: 6
When you run the model as it is, you will see that enabled subsystem outputs no data. This doesn't mean the buffer inside the enabled subsystem hasn't buffered the data properly. The buffer hasn't gotten a chance to output its buffered data yet.
Time (in sec) Buffer status
3 [2 3]
4 [2 3 4]
5 [2 3 4 5]
6 [2 3 4 5 6]
7 [2 3 4 5 6 7]
At 8th second, buffer is full and subsystem is enabled. You would expect the buffer to output the stored 6 values now. But what you are missing here is the sample time of the buffer block. Since it is 6, the buffer block's output will change only every 6 seconds. So only at 12th sec, buffer block will be able to output its stored frame [2 3 4 5 6 7] 8  9 [8 9] 10 [8 9 10]
So if you increase the runtime to 12 (simple_example_modified.mdl) and enable the subsystem at 12th second, you will see the frame outputted by the buffer block in the Display.
11 [8 9 10 11]
12 [8 9 10 11 12]
Buffer will output the frame [2 3 4 5 6 7] now. For more information on how the sample period of the buffer block is computed, please refer https://www.mathworks.com/help/dsp/ref/buffer.html?s_tid=srchtitle#bsmlkpd