On 07/06/2011 21:05, RNGolding@aol.com wrote: > So far so good, however the sine waves have some jitter so I thought I > would take the average of a few consecutive phase measurements. That is = where > I come unstuck, how do you average phase readings? > > To illustrate the problem, if the phase is jittering about zero degrees > giving 4 phase readings of say, 358, 359, 1 and 2 degrees, a simple aver= age > calculation yields 180 deg, which is obviously wrong. Does anyone know h= ow > calculate the true average, which should be 0 degrees? I'm sure the ans= wer > is obvious, but it has defeated me so far. Not thought this through very carefully but... What about not wrapping to 0 after 360? (i.e unwrapping the phase) So you just keep going, and then after you average the readings you mod=20 by 360 to get the result. So if you have 358, 359, 360, 361, 362. You get an average of 360, then=20 360 % 360 =3D 0 Or if 178,179,180,181,182 -> 180 % 360 =3D 180. Or 720,721,722 -> 721 % 360 =3D 1 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .