ok so I am trying to do moving average on voltage and current values for my bldc motor circuit...

I have an array of 8 elements for both the analogues...Its arranged as a FIFO, with indexes being incremented and capped by modular arithmatic.

I am getting average value that is less than what I expected...

Basically I have Sum_n = Sum_(n-1) + NewValue - EarliestValue.

The above formula makes sure the oldes value is dropped and new value is added to the FIFO sum. I then calculate:

Avg_n = Sum_n/8

It seems if I do Avg_n = Sum_n/7, I would get the currect figure. Am I missing something? I initialize the array with zero values to start with... :|