Phase difference calculation for non divisible sample rate to frequency I am learning DSP and I am trying to simulate a simple phase difference calculator between two sinusoidal signals using GNU radio.

My flowchart looks like this:

As can be seen on the chart, one of the signals is using a delay block (controlled by the "delay sig" range GUI).

Other interesting points are:


fft_width variable:
Calculated by an expression - int(freq/20)
freq variable:
Controlled by a GUI range with steps of 1.2KHz. Min 1.2KHz, Max 9.6KHz
The skip head and Keep M in N blocks - used together to extract only the FFT bin in interest. To do so the skip head calculates the first N blocks to be skipped via this expression: int((samp_rate/fft_width))+2 . Idea taken from this video: https://youtu.be/GJKbD--MsLM?t=326


The problem:

This flowchart works when the samp_rate and freq are divisible - say samp_rate=10k and freq = 1k. However, for more of a real world scenario I have chosen variables that have lower ratio and are not divisible. In particular: samp_rate=11k and freq=1.2k. As a result of this the phase calculation fluctuates between 180 degree difference - for example 3.42 and 3.42-pi.

The question:

How do I make this flowchart work when the samp_rate and freq are not divisible? Furthermore how do I make it work for samp_rate of 11k, but different frequencies (chosen by the freq range GUI)?

What I tried:

Not much unfortunately, as I cannot find much information about this problem. That said, I read somewhere that clock synchronization via a PLL or Clock Recovery MM might help, but I do not know how to apply the relevant GNU radio blocks to this flowchart. Furthermore, if PLL is used would it not change the phase difference between the signals when trying to synchronize them?

Thank you for your time!

EDIT:
I tried putting a PLL ref output block between the throttle and FFT blocks:


For the parameters I used:

loop bandwidth: pi/200 (documentation states it should be either that or 2*pi/100)

min_freq &amp; max_freq: (2*pi*1.1e3)/samp_rate (documentation states it needs to be in radians per sample)

My goal was to try to make it work for 1.2k frequency, but unfortunately I still face the same problems. How can I fix it?
Re-reference your FFT phase measurement reference point to the center of your data window by doing an FFTShift (N/2 vector rotate) before the FFT.  That moves the portion of data where there is a circular discontinuity (due to non-integer periodicity) away from the phase reference point of a typical FFT.