Electronic – How to keep the sinusoid in phase with its input after filtering

filterfrequencylow pass

A section of a circuit I'm working with makes a sinusoid from a square wave by passing it through an 8th order filter (MAX293). Up until now, everything was ok, but I was told recently that the input (square wave) and output (sinusoid) have to be in phase. Because of the LPF, it adds a phase shift and because the input frequency is variable (0-5khz), the phase shift is also variable.

How can I keep them in phase for the entire frequency region they operate at ? What should I be looking at ?

Best Answer

You have two options apart from the PLL (which may or may not meet your requirements : there will inevitably be delays between input and output if the frequency changes, while the PLL settles to the new frequency. Given the comments, a PLL capable of tracking down to 0.1Hz will be quite a beast to get right)

1) Delay the input signal in the same manner that the filter delays the output.

This is easier if the filter is a linear phase filter such as a Bessel, or you can use digital filters such as an FIR filter, and a matching digital delay.

It's not impossible otherwise : you can design an "all pass network" aka "group delay equaliser" with the same delay characteristics (phase response) as the filter : however after this, the square wave will generally no longer be a square wave. Whether that matters or not I can't say, I don't know the application.

Given a linear phase filter, the group delay equaliser should be relatively simple and preserve the square wave.

2) Generate one waveform from the other without filtering.

It is possible to generate a triangle waveform from a square by integration (this generates a 90 degree phase shift so you may need to generate two square waves in quadrature). From the triangle, you can use a non-linear network (resistors and diodes, as a "soft clipper) to approximate a sine wave. Better that 2% harmonic content is possible : see the "ICL8038" for an old example of this technique. This only works well if the square wave amplitude is constant.

But it's much simpler to generate a square from a sine, if your application permits...