I am programming a phase-locked loop to track the resonance of a tuning fork so that the tuning fork is always on resonance. This will be used in condensed matter physics through atomic force microscopy.

Now, I am not certain about how to carry this out, so I was wondering if someone here could help me.

I have programmed an FPGA to output an arbitrary driving voltage, and this drives a tuning fork. This tuning fork then generates a signal that is eventually converted to a voltage and read by my device. Now, I also have a lock-in amplifier to detect the phase lag between my DAC (technically, the NCO that outputs via DAC) and ADC signals. I have made a graph of the phase difference after taking 4000 steps around the resonance frequency. Also, there is a graph of the LIA's detected magnitude*2.

I do not know what any of the transfer functions are, I apologize.

enter image description here Phase difference (phase lag) graph on left. Resonance centered at 32.7635 kHz enter image description here However, my phase difference graph is likely incorrect. I found the following that displays continuous "pretty" graph that may be what I am supposed to have.

Phase lag in blue

Does anyone know why phase graph has a max/min of 1/-1? If so, does anyone know how I may fix it?

Thank you
  • $\begingroup$ Your phase in the Labview plot, is in normalized radians, right? That is +1 = 180 degrees and -1 = 180 degrees? $\endgroup$
    – Ben
    Commented Feb 9, 2021 at 18:53
  • $\begingroup$ I would assume so. However, I did not explicitly specify for the detected phase to be normalized, nor did I normalize the data. $\endgroup$ Commented Feb 9, 2021 at 18:54
  • 1
    $\begingroup$ You could unwrap the phase, and the discontinuity would go away $\endgroup$
    – Ben
    Commented Feb 9, 2021 at 19:06
  • $\begingroup$ I tried using the LabVIEW "Unwrap Phase PtByPt" subVI, but it produces the same output zone.ni.com/reference/en-XX/help/371361R-01/ptbypt/… $\endgroup$ Commented Feb 9, 2021 at 19:18
  • 1
    $\begingroup$ the VI expects an input with a ±pi range. You have a ± 1 range. You should miltiply your phase by $\pi$ $\endgroup$
    – Ben
    Commented Feb 9, 2021 at 19:19

1 Answer 1


You seem to have 3 problems

1 - You have a phase wrap. It happens when the phase goes past 180 degrees. The phase will wrap back to -180 degrees. You can fix this by unwrapping the phase.

2 - Your phase is in normalized radians instead of being in radians or degrees. This is not a problem per se but when you try to unwrap the phase, you should be aware that phase unwrap blocks usually expect a phase in radians, not in normalized radians.

3 - The measured phase seems to be inverted compared to what you expect.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.