0
\$\begingroup\$

I'm studying the KHN biquadratic section and its outputs to obtain a lowpass filter, a highpass filter and a bandpass filter. I simulated the filter using Mathematica and obtained the following plots, which match the theoretical. enter image description here

Now, then I decided to simulate the circuit using LTSPICE.

enter image description here

Obtaining the following plots:

enter image description here

Now, comparing both plots everything looks fine with the Low pass output and with the High pass output, both in terms of magnitude and phase. My question is with the band pass output. While the magnitude plot looks fine, the phase plot has nothing to do with the one I plotted with Mathematica. Why does this happen? What is the difference between the simulation and the theoretical plot? I didn't expect such an abrupt phase change as the one obtained with Mathematica, but the phase plot obtained has nothing to do with it: the limits are different, the variation is the exact opposite... What am I missing here?

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Mathematica phase plots are limited to lie between -180 deg and +180 deg. such a restriction is not seen in the SPICE result. By the way, the SPICE plot is very difficult to see. Try to increase the line thickness or change the colours. \$\endgroup\$ – AJN Aug 18 '20 at 13:53
  • 1
    \$\begingroup\$ The mathematica phase plot (green color) goes from -100 to -180 then +180 to +90 (which is same as -180 to -270). The spice Green plot goes from -100 to -180, then from -180 to -270. So the result is not surprising ? \$\endgroup\$ – AJN Aug 18 '20 at 13:55
  • \$\begingroup\$ Oh I get it now! The jump in the Mathematica plot is due to reaching -180. It adds 360 and then goes from 180 to 90. In SPICE such restriction does not exist and, therefore, after -180 it continues down to -270. I didn't know about the Mathematica restriction (but it makes sense to keep the phase in the [-180, 180] interval to make it more evident when signals are leading or lagging). Thank you very much! \$\endgroup\$ – Granger Obliviate Aug 18 '20 at 14:08
  • \$\begingroup\$ Phase plots will be relatively the same, they will not start from the same absolute postion. \$\endgroup\$ – Voltage Spike Aug 25 '20 at 21:54
1
\$\begingroup\$

What you see is called phase wrapping, and it's the result of calculating the phase with the four-quadrant version of atan(), atan2(). Its domain is from \$-\pi\$ to \$\pi\$, or, in degrees, from \$-180^\text{o}\$ to \$180^\text{o}\$.

In LTspice (or most other SPICEs), there is an option to unwrap the phase, which displays it continuously, without the jumps: if you're using version XVII then right-click, else left-click on the right side of the waveform window, on the Y-axis. You will see this little dialog come up (ignore the readings, it's a quick test run):

unwrap

The Unravel Branch Wrap is checked, by default. Unchecking it will result in the phase being displayed as you see in Mathematica. If you want for Mathematica to also display it unwrapped, then you'll have to do a bit of calculation involving the derivative of the phase, searching for the jumps, and adding or subtracting \$2\pi\$, as needed. Or maybe there's a builtin function.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you! This is very interesting! I actually prefer the way Mathematica displays it because it makes more obvious if the signal that passes through the filter will be leading or lagging the original signal. \$\endgroup\$ – Granger Obliviate Aug 18 '20 at 19:05

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.