I want to build a real-time phase error correction circuit to correct the phase degree error of a feedback loop to prevent oscillation. For this I need an electronically controlled phase shifter for frequencies between 10hz and 20khz. I want it to simply offset the phase of the entire input signal fully intact. Can this be done?

  • 3
    \$\begingroup\$ (A) What for? (B) constant delay, or constant phase angle? \$\endgroup\$ – pjc50 Mar 1 '18 at 14:36
  • \$\begingroup\$ I need an adjustable phase angle. I need the feedback of my circuit to be within a few phase degrees of the original input signal. The phase degree of the feedback varies so I need an automatic correction solution. This signal is an audio signal so it is not a simple sinewave. \$\endgroup\$ – coinmaster Mar 1 '18 at 16:05
  • \$\begingroup\$ It sounds like you are looking for a clairvoyant circuit. Look around to see if large glass balls come in PCB mount versions. \$\endgroup\$ – Olin Lathrop Mar 1 '18 at 16:30
  • \$\begingroup\$ Next question : what feedback? Microphone feedback, or is this more like noise cancellation? \$\endgroup\$ – pjc50 Mar 1 '18 at 19:48
  • \$\begingroup\$ Motional feedback. The problem is the phase angle of higher frequencies limits the bandwidth of the feedback. I'm trying to correct this by actively correcting the phase angle before it reaches the input. \$\endgroup\$ – coinmaster Mar 1 '18 at 20:57

If you just want adjustable delay (phase shift varies as a function of frequency), then use a ring buffer of digital samples. With 20 kHz being the upper frequency limit, you need to sample at least at 40 kHz. However, 100 kHz would be better and leave more room for the external analog filters to work.

The lowest frequency of interest is 10 Hz, which has a 100 ms period. Since you ask about "phase shift", we can infer that 100 ms is therefore the upper limit on delay. At 100 kHz sample rate and up to 100 ms delay, you need a buffer that can hold 10 kSamples. That much RAM is easy to find in many microcontrollers with plenty of room to spare. You might use 16 kWords of 16 bits each, for example.

The rest is rather simple firmware. Samples are written into the circular buffer at a fixed 100 kHz rate. You also pick a sample out of the buffer at the same rate, but the offset from the input position to the output position varies on the fly according to the delay time you are trying to achieve.

100 kHz sample rate means 10 µS per sample. That gives you 700 instruction cycles per sample for a dsPIC running at 70 MIPs, for example. That's way more than needed for this. If you want the delay to be controlled by a voltage, then you'd run the voltage into a A/D input. That can also be sampled at 100 kHz and still not get close to the 700 cycles/sample budget.

  • \$\begingroup\$ I'm a bit rusty in this area and I'm trying to read up on it but I'm not there yet so sorry about my ignorance. I'm trying to build a real-time phase correction circuit to correct phase errors in feedback loops. Will your proposed circuit work for my needs? \$\endgroup\$ – coinmaster Mar 1 '18 at 15:02
  • \$\begingroup\$ To clarify, it's not a phase delay I need, it's phase correction. A delay will just make things worse. \$\endgroup\$ – coinmaster Mar 1 '18 at 15:37
  • 2
    \$\begingroup\$ You can only delay phase. To 'advance' phase you would just delay by > 2*pi rads. Advancing phase would violate causality. \$\endgroup\$ – Andrew Cragg Mar 1 '18 at 16:21
  • \$\begingroup\$ I planned on using a phase comparator circuit to measure the phase difference between the input signal and the feeback signal and then correct the phase of the feedback with a phase shifter. Since the frequencies are 10hz-20khz it should be doable with a fast circuit. Maybe I'm stupid? Am I missing something? \$\endgroup\$ – coinmaster Mar 1 '18 at 16:54
  • \$\begingroup\$ @coi: First, what you want isn't really a phase compensator, but a delay compensator. The problem is that those don't exist because they would have to output a signal that hasn't occurred yet. \$\endgroup\$ – Olin Lathrop Mar 1 '18 at 18:55

The usual approach as used in things like Cartesian loop transmitters is to take the feedback signal as an I/Q analytic pair (Or do a hilbert transform to get it into that form) then just multiply by a point on the unit circle corresponding to the desired rotation, easy.

Difficult to do over a wide bandwidth with analogue parts because a sufficiently broadband 90 shift is tricky (big lattice filter with many, many precision components, radio hams do it over 300 - 3kHz for 'phasing method' SSB, but adding two decades makes for a big network), a small DSP or FPGA running a hilbert transform and complex plane multiplier is much easier and more repeatable.

Regards, Dan.

  • \$\begingroup\$ I wish I knew what you just said :P \$\endgroup\$ – coinmaster Mar 1 '18 at 17:02
  • \$\begingroup\$ I said, do it in DSP, much easier then analogue for this sort of thing! \$\endgroup\$ – Dan Mills Mar 1 '18 at 17:18
  • \$\begingroup\$ DSP is quite a large subject that I know little about. Before I begin studying, are you sure this solution will work for my needs? The people above seem to think I need a clairvoyant circuit but I don't see why. \$\endgroup\$ – coinmaster Mar 1 '18 at 17:24
  • \$\begingroup\$ You have not really given sufficient detail to tell... Time to fire up matlab and have a play. You do have to respect causality (which is I think what they are sweating), so delay thru the non linear element must be small compared to the correction bandwidth, on you to decide if that is true in your case. You may find digging up the block diagram of a cartesian loop transmitter to be instructive. \$\endgroup\$ – Dan Mills Mar 1 '18 at 19:05
  • \$\begingroup\$ As far as I understand the bandwidth of the correction circuit need only be 40khz minimum in order to closely assimilate the phase of the input signal and the phase of the feedback signal. I don't need 100% perfect alignment, only within a few degrees. Since the highest correction frequency is 20khz a correction circuit of much higher bandwidth should have no issue with the phase correction. There's no "future" sensing, just a very small delay. At least this is how I understand it. Am I wrong? \$\endgroup\$ – coinmaster Mar 1 '18 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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