wrote: I do not see a circular buffer in your examples, you are just enqueuing data. You need to think about how you want to implement your buffer, it is lossy, do you want to skip adding points to it if it is busy processing, etc.
There are lots of other things in your example that could be fixed, but I do not know whether you just put it together for an example.
Attached is a real hack of the program that will get it to do what you want, but I highly suggest you just look at it to see what can be done and rethink you problem.
mcduff
@mcduff, really appreciate your help and thanks for taking out time to modify the program.
1. You are right, i have used wrong nomenclature, it's just buffer and not circular buffer. I have buffered previous 3 data blocks using shift register.
2. In your program, PSD will be calculated at every 4 second. Basically it waits for 4 seconds data to gather. Whereas I am trying to achieve continuous PSD, being calculated at 1 sec, with previous 3 seconds data from shift register.