# How to find the direction of phase difference of sine signals using multiplier phase detector?

I am using a multiplier phase detector like here 1to find the phase difference between two phase shifted sine signals, and I got the value of magnitude but how to find if the signal 2 is leading/laging wrt signal 1? The cosine would give a positive value for both negative and positive angles.

I also thought of checking the first sample point of both signal 1 and signal 2 to see which has greater magnitude and deduce a conclusion based on that. if (signal 1 > signal 2 => sig 2 is lagging and vice versa).

But I am trying to implement this in a stm32 and I am for some reason, not being able to do that. Is there any other robust way?

• One method might be to invert one of your inputs and add the samples. The difference represents the phase difference. Basically the sum of two sines 180deg apart is 0. Jul 10 at 14:22
• Yes, but i will be using this in a PLL(DDS + PI loop) and in Real time to constantly phase compensate. The phase is shifting towards zero but then it slips towards other direction.
– Rima
Jul 10 at 14:26
• Normally you’d compare zero crossings and determine which signal is leading or lagging, but nevertheless, what I described will do much the same Jul 10 at 14:31