# Equation for Phase Response of a SOS

Started by May 20, 2008
```I'm close to an answer on this topic, but there is something I'm missing.
I have found the following equation in a textbook for determining the phase
response of a second-order circuit:

PHI(w) = Angle(K) - atan(((w/wc) - (wc/w))/(1/Q));

where
w : range from 0:pi (nyquist)
Q : Quality/Damping factor

But when I tried this exact code in Matlab and compared it to an Allpass
filter they don't match.  The Allpass code is known to be in good working
order because I've used this function in other applications with no
problems.  So my reference code is alright.

In Matlab I had to play with this just a bit to make it look
close-to-right on my plot.  The exact code I used was:

=================================================
PHI = -pi/2 - 2*atan(((w./wc) - (wc./w))/(1/Q));
=================================================

The plots when compared look almost like there is a Q difference, but I'm
using the same Q in code.  In addition on the High-end of the frequency
axis, the above formula takes longer to approach -360 degrees.

Am I missing something from this equation?  Is there a different version
handy?

Thanks,
Jeff

```
```On 20 Mai, 20:12, "sparafucile17" <sparafucil...@hotmail.com> wrote:
> I'm close to an answer on this topic, but there is something I'm missing.
> I have found the following equation in a textbook for determining the phase
> response of a second-order circuit:
>
> PHI(w) = Angle(K) - atan(((w/wc) - (wc/w))/(1/Q));
>
> where
> &#2013266080; &#2013266080;wc: Filter cutoff in radians
> &#2013266080; &#2013266080;w : range from 0:pi (nyquist)
> &#2013266080; &#2013266080;Q : Quality/Damping factor
>
> But when I tried this exact code in Matlab and compared it to an Allpass
> filter they don't match. &#2013266080;The Allpass code is known to be in good working
> order because I've used this function in other applications with no
> problems. &#2013266080;So my reference code is alright.
>
> In Matlab I had to play with this just a bit to make it look
> close-to-right on my plot. &#2013266080;The exact code I used was:
>
> =================================================
> PHI = -pi/2 - 2*atan(((w./wc) - (wc./w))/(1/Q));
> =================================================
>
> The plots when compared look almost like there is a Q difference, but I'm
> using the same Q in code. &#2013266080;In addition on the High-end of the frequency
> axis, the above formula takes longer to approach -360 degrees.
>
> Am I missing something from this equation? &#2013266080;Is there a different version
> handy?

At first glance you might want to use ATAN2 instead of ATAN...
apart from that, is the formula generally valid for SOSs?

Rune
```
```>
>At first glance you might want to use ATAN2 instead of ATAN...
>apart from that, is the formula generally valid for SOSs?
>
>Rune
>

Rune,

Thanks for the tip.  I guees I've forgotten that there were two tan
functions.  Not looking too deply into this function, it seems I have to
supply real and imaginary numbers.   Do you have a clue what I should be
feeding into it?  Sorry for the vague comments, but I have to leave work
shortly and wanted to at least get this post out.

BTW, according to the circuits textbook I pulled this from, this formula
is generic for all second-order circuits.  It seems like it's working, but
again I'm missing one element to this puzzle.

I did figure out why I had to multiply the atan by 2 coincidentally... I'm
using a 2nd order allpass to compare to, which has the phase response of a
4th order system!!  So I multiplied by 2 to get the 4th order response.  At
least I think I did this part correctly.

Just to prove this isn't a problem, I'm going to test the orginal equation
against a 1st order allpass which should have the response of a 2nd order
non-allpass filter (LPF,HPF, whatever)

Jeff

```
```>Just to prove this isn't a problem, I'm going to test the orginal
equation
>against a 1st order allpass which should have the response of a 2nd
order
>non-allpass filter (LPF,HPF, whatever)
>
>Jeff
>

Nope same problem for the 2nd/1st combo.  So there is definately something
wrong with the equation above.  I'll see if I can't post a link to a
picture of what I'm seeing in Matlab...

Jeff
```