why buffer on simulink (r2019b) creates delay and how to solve it?

2 vues (au cours des 30 derniers jours)
Naufal Arfani
Naufal Arfani le 9 Jan 2021
Commenté : Walter Roberson le 10 Jan 2021
I use a buffer on simulink r2019b to produce 1000 samples per frame (per channel), but why is there a delay so that it produces a leading zero in front of it,
why can this happen and how to solve it? Thank you very much
  5 commentaires
Naufal Arfani
Naufal Arfani le 9 Jan 2021
whereas this is the scope of the DSP sin discrete mode output with the same sample time and samples per frame @Walter Roberson

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 9 Jan 2021
The DSP Buffer block is defined to hold the previous content until enough new samples have been received to fill a complete frame, at which point the output changes to the appropriate number of previous values.
Between the time the buffer operation starts and the time a full frame of samples have been received, the "previous content" is typically 0. You can configure for a different initial value in the properties of the DSP Buffer block, which also permits you to name a variable to receive the initial values from.
Note: you should probably also configure your scope to Frame Based: https://www.mathworks.com/help/simulink/slref/scope.html#d122e187735 "Input Processing"
  3 commentaires
Naufal Arfani
Naufal Arfani le 10 Jan 2021
I usually use array plots instead of scopes but I use scope to show the delay I mean Mr @Walter Roberson
Walter Roberson
Walter Roberson le 10 Jan 2021
Step 1: right click the Buffer block and select Block Parameters (Buffer)
Step 2: Fill in new Initial conditions
Then click Apply, and then OK.
However if you fill in a constant here, then the fft() result for the first buffer full is just going to be (length of buffer) times (that constant) for the first bin, and all of the other fft results for that first buffer full is going to be 0.
There is no peak available for the first buffer-full.
You need to either change your S-function to handle that case (which can happen anyhow because of silence!!), or else you need to use some kind of if/else or enabled block so that your S function is not called for the first buffer-full, or else you need to mix in some signal to interpose an artificial peak for the cases where your signal would otherwise be constant.

Connectez-vous pour commenter.

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by