On 07-Jun-11 22:05, RNGolding@aol.com wrote: > Hi, not sure if this should be PIC or EE, but I have opted for PIC > > I have an application where I need to measure the phase difference betwee= n > two sine waves of same frequency. I'm using two zero crossing detectors t= o > trigger the CCP1 and CCP2 inputs of a PIC. The CCP counter is clocked by= a > PLL/VCO at 360 x the sine wave frequency, so the difference between the > CCP1 and CCP2 counts provides a direct phase measurement with a resoluti= on of > 1 degree. > > 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. > > Richard Golding > http://www.webmet.com/met_monitoring/621.html Djula --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .