From 08:00 PM CDT Friday, August 12 - 01:00 PM CDT Saturday, August 13, will be undergoing system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.


Showing results for 
Search instead for 
Did you mean: 

Realtime Array Building

Go to solution



I have a realtime acquisition that happens every 1/10 of a second (the loop fires about every 100ms)... I would like to continually build an array of 5 collected values and then send it off to another part of the program (produced consumed), and then zero the array and do it again, continually.


Any suggestions on how to do this? My example just seems to build an array of 5 of the current reading, not the last 5 readings... wondering if there is a way to only execute the loop on "consumed deque" (not sure if I'm saying that right).


thank you



0 Kudos
Message 1 of 4


I solved it I think... changed it to a while loop instead of the FOR loop which was executing 5 times every while loop iteration.

0 Kudos
Message 2 of 4
Accepted by topic author downerdce

It is generally a bad idea to constantly resize arrays (does not matter too much with such small arrays, but it's a bad habit!)

All you need is an array initialize with 5 element where you replace the oldest and send it off whenver five have been replaced.


Here's a quick draft. Modify as needed.




Message 3 of 4

Thank you!

0 Kudos
Message 4 of 4