The trouble is, you don't know the center point until you get the=20 average, and need the center point to to get the average. If you use the method I posted earlier, I believe it will work. If (highest reading - lowest reading) > 180 // Wrap occurred for each reading, if reading > 180, reading =3D reading - 360 //=20 Convert to negative value Average =3D sum of readings / number of readings Examples: 358, 359, 1, 2 Highest - lowest (359-1) is > 180, so convert readings by subtracting 360 f= rom each one over 180. Results are -2, -1, 1, 2, average is 0. 178, 179, 181, 182 Highest - lowest (182-178) is < 180, so don't convert readings. Results ar= e 178, 179, 181, 182, average is 180. Kerry =20 IVP wrote: >> What happens if the average is 180, and the readings are 178, >> 179, 181 and 182? >> =20 > > Hmmm. OK. We're into the trial-and-error stage of development ;-)) > > I see what you mean. Results will revolve around any arbitrary > centre point unless compensated > > In the example above > > (+ 178 + 179 - 1 -2) / 4 =3D 88.5 or > (-2 -1 + 181 + 182) / 4 =3D 90 > > So.......strip off the centre point to make absolute differences and > then add it back as an offset ? > > The obvious answer is 180, which could be arrived at by > > (-2 -1 + 1 + 2) + 180 > > Joe > > > =20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .