I'm working on a circuit which measures the phase difference between to signals that work in ultrasound range (~20 kHz).

With help I could achieve the circuit that I expected: enter image description here

But now I need to use only positive DC.

The changes I made in the circuit allow me to detect positive phase difference (when I change the bottom generator) but it gives only ~0v when I put a negative value in the generator.

I want to bias the output so the circuit works as the old one but mounted to a DC. The range will be divided by two but it doesn't matter.

Here are the links to both circuits in LTSpice https://www.dropbox.com/sh/be6k6jhx6h9ipo5/AACywKL40KTgJz2wyFPXie0sa?dl=1

  • \$\begingroup\$ Firstly, you are powering the LT1720 with 10 V which is above the Absolute maximum of 7 V. Secondly, pulling TTL signals below ground (your -ve Vin) does nothing. If you need to be able to compare both +ve and -ve input voltage then you need to design you interface to do that conversion. \$\endgroup\$ Jan 19, 2017 at 17:58
  • \$\begingroup\$ Hi! thanks for your response. If you check the new circuit, the comparators are only powered with 5v. On the other hand, I didn't understand what are you meaning with the second point \$\endgroup\$ Jan 19, 2017 at 18:37
  • \$\begingroup\$ Assuming an input signal symmetrically +/- around zero. You are only able to detect the -ve to +ve transition of the input signal. Effectively you half wave rectify the input signal. Can you draw some waveforms of what you expect to detect? \$\endgroup\$ Jan 19, 2017 at 18:56
  • \$\begingroup\$ The signals that I want to detect are almost sines. It's the same signal but one input is the current and the other is the voltage. I need to measure when the phase difference is almost zero. \$\endgroup\$ Jan 19, 2017 at 19:29
  • \$\begingroup\$ Ah...closer to the problem. Do you want to know just whether the current signal leads or lags the voltage or do you need to know when the difference between the two (whether lead or lag) is within a very small window? If so what is the window size... uS, nS? In other words do you want to know the phase angle or do you want to know when they are exactly (close as can be) to in phase. \$\endgroup\$ Jan 19, 2017 at 19:42

2 Answers 2


I'd suggest you consider trying to capture the phase difference digitally rather than in analog form and then digitize. I had some difficulties with LTspice in terms of keeping amplitudes of input signals in line, so I took out the DC offsets in the circuit below. This produces a count of phase shift (Lead or Lag) based on a 10 MHz clock.
I'm not suggesting you'd do it this way, but it serves as a sample.
I'd suggest that the digital section would be a small MCU (you could test on an Arduino type hardware platform for example) with the XOR being the enable for a Timer-counter.

enter image description here

I broke several rules in the circuit above, such as no DC offset and no clip on the input, but it produces the right sort of output.

  • \$\begingroup\$ Hi! Thanks for your response! I just finished doing the circuit and I don't understand how to process the output given by the circuit with an Arduino to get the phase angle. I just have to count the number of clock pulses? Sorry but I never work with digital features of Arduino \$\endgroup\$ Jan 20, 2017 at 19:04
  • \$\begingroup\$ I'm not actually suggesting you use the circuit proposed AND an Arduino to provide the solution. For example I'd not want to create V3, but use the MCU clock (or some derivative) to provide the measurement clock. You could start with an Arduino by simply incrementing a register in a tight loop base don the width of the XOR gate output. \$\endgroup\$ Jan 21, 2017 at 5:57
  • \$\begingroup\$ Hi! Sorry for the delay. I like your proposal, that's why I keep asking you :) I'm currently working with an Arduino Due to digitalize the values from the phase shift, so it would be very useful your aproximation. I don't understand very well what are the problems. Can you help me to achieve the expected circuit? \$\endgroup\$ Jan 23, 2017 at 15:49
  • \$\begingroup\$ Hi, I worked around your circuit to achieve the circuit that I expected. Now I'm trying to improve some features of the circuit. If you are interested, I can share it with you so we can see it \$\endgroup\$ Jan 27, 2017 at 20:00
  • \$\begingroup\$ Sure, I'd love to see how you have progressed. If my answer added value you should accept it too. \$\endgroup\$ Jan 27, 2017 at 21:33

1) Use an op amp to generate a pseudo-ground at 2.5 volts.

2) AC-couple your inputs, and reference the inputs to the pseudo-ground.

3) Reference output filter to pseudo-ground,

4) Add another comparator (not an LT1720) to level shift the XOR gate output to pseudo-ground. Alternatively, if you're not that interested in accuracy, level shift by providing a voltage divider from the XOR to +5, with equal value resistors. A fine trim pot at the middle of the divider is probably a good idea.

5) Replace Q1 with an analog gate such a CD4066.

6) Reference your output meter to pseudo-ground, not ground.

  • \$\begingroup\$ Thanks for your answer! I have two questions: 1) Which comparator would suit best (from point 4), a fast one or not? 2) Is there any other option than CD4066. I'm couldn't find a third party model :( \$\endgroup\$ Jan 20, 2017 at 13:47
  • \$\begingroup\$ @AugustoBonelliToro - 1) Unless you are doing super-precise phase measurement, consider the phase error of 1 usec at 20 kHz. Your phase resolution and operating frequency determine the required speed. 2) There are any number of analog switches, but I picked the CD4066 because it is widely available and dirt cheap. \$\endgroup\$ Jan 20, 2017 at 14:30
  • \$\begingroup\$ @AugustoBonelliToro - On second thought, a 4066 is not a good choice - with a 5 volt supply its on-resistance can be as high as 500 ohms. Google on "analog switch". Likewise, there should be no need for a 3rd comparator - drive the switch from the flip-flop directly. \$\endgroup\$ Jan 20, 2017 at 14:38
  • \$\begingroup\$ Ok, I'll try with FF directly. Sorry to still asking questions, but I don't understand why I need to use another comparator. From my maths, ideally I need 0.1us phase error, because it's 1º for 20 kHz \$\endgroup\$ Jan 20, 2017 at 14:53
  • \$\begingroup\$ @AugustoBonelliToro - Umm, what part of "there should be no need for a 3rd comparator" don' t you understand? \$\endgroup\$ Jan 20, 2017 at 18:52

Your Answer

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

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