Hi, not sure if this should be PIC or EE, but I have opted for PIC =20 I have an application where I need to measure the phase difference between = =20 two sine waves of same frequency. I'm using two zero crossing detectors to = =20 trigger the CCP1 and CCP2 inputs of a PIC. The CCP counter is clocked by a= =20 PLL/VCO at 360 x the sine wave frequency, so the difference between the=20 CCP1 and CCP2 counts provides a direct phase measurement with a resolution= of=20 1 degree. =20 So far so good, however the sine waves have some jitter so I thought I =20 would take the average of a few consecutive phase measurements. That is wh= ere=20 I come unstuck, how do you average phase readings? =20 To illustrate the problem, if the phase is jittering about zero degrees=20 giving 4 phase readings of say, 358, 359, 1 and 2 degrees, a simple averag= e=20 calculation yields 180 deg, which is obviously wrong. Does anyone know how= =20 calculate the true average, which should be 0 degrees? I'm sure the answe= r=20 is obvious, but it has defeated me so far.=20 =20 Richard Golding =20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .