Hi, I guess you *can* do the right shifting 3 times before addition, if you save the shifted-out values also (it is the modulus by division with 8). They can be also cumulated such way as the originals and at the end shift right 3 times also right and the result is to be added to the sum of the previous data. It requires only one more RAM cell. I hope this helps. Imre P.S: Here also an example Original DIV by 8 Remainder 123 15 3 45 5 5 66 8 2 23 2 7 12 1 4 36 4 4 82 10 2 1 0 1 ---------------------------------- 388 45 28 SUM 48.5 45 3.5 AVG On Mon, 26 Apr 1999, Matt Bennett wrote: > I'm trying to figure out how to compute an average of 8 discrete > measurements to reduce noise (on a 16C71). The measurements appear to > have a gaussian type of distribution, centered around some DC value, with > perhaps a 2 bit sigma (noise amplitude). I want that DC value. > > Average = (X1+X2+X3+X4+X5+X6+X7+X8)/8 But the summation of X1 ... X8 would > be possibly greater than eight bits. > > Here's my situation: I recieve 50 bytes of data, (X1.1 .. X1.50) in the > first burst, and store them (in the PICs limited memory). I then recieve > another 50 bytes (X2.1 .. X2.50). Eventually I will recieve 8 bursts (up > to X8.1 .. X8.50). I want to average X1.1, X2.1, ... X8.1, and so on. Is > there any way to do this without losing precision? There is time between > XA.N and XA.N+1 to do some calculations. > > This can be done with just 2 samples (X1.1+X2.1)/2 (utilizing the carry > generated with the add, and keeping the result in 8 bits) I'm wondering if > there is any way to extrapolate this method into a greater number of > samples. > > Doing the division (right shift) before the add won't help- since that > would serve to eliminate immediately the small variations I'm trying to > compensate for. > > This message is not really as clear as I would like it to be, but I don't > see any way to explain it better without a white board in front of me. I > hope I've gotten the point across adequately. > > Matt Bennett > > -- > Matt Bennett > mjb@arlut.utexas.edu > >