Try this. It uses shift registers to get the old data from the last iteration with the new data just acquired. I can't test it, and I don't usually use dynamic data types so it's possible the math operations won't work right. But this should give you the idea.