Phase shift help (how's your maths?!)

Status
Not open for further replies.
I’m trying to work out the phase shift for 330Hz through an all pass filter which has a value of 68K for R1 & 10nf for C1.....

shack.us/i/diagram1.gif/]
An externally hosted image should be here but it was not working when we last tested it.
[/URL]



Now formulas aren’t a strongpoint of mine, but apparently, this one will provide the phase shift for any given frequency through the above circuit ….

An externally hosted image should be here but it was not working when we last tested it.



(source = http://www.maxim-ic.com/appnotes.cfm/an_pk/559


Where where w is the frequencies in rad/s.

I want to determine the phase shift for 330Hz, so I used this online calculator to get that converted to radians per sec

http://www.sciencelab.com/data/conversion_calculators/frequency-conversion.shtml

therefore w (radians per second) for 330Hz is 2,073.451149

R1 = 68,000
C1 = 0.00000001


Ok, don't laugh, but I tried to use that formula above....

Top part of the equation (within the brackets)….

2 x 2,073.451149 totalling 4146.902298

divided by 68,000 (ie R1 @68K) x 0.00000001 (C1 @10nF) totalling 0.00068

Therefore 4146.902298 divided by 0.00068 = 6098385.7323529411764705882352941 (this is the top number within the brackets)



Bottom part of the equation (again within the brackets)….

4299199.667289420201 (ie ‘w’ or 2,073.451149 squared)

Minus….

1 divided by 0.00068 = 1470.5882352941176470588235294118

Which then must be squared = 2162629.7577854671280276816608997

Therefore we end up with 4299199.667289420201 - 2162629.7577854671280276816608997, resulting in....

2136569.909503953072972318339101 (this is the bottom number within the brackets)

Therefore to get the number within brackets, we must divide the top number by the bottom number…

6098385.7323529411764705882352941 / 2136569.909503953072972318339101

Therefore the number in brackets is 2.8542879431306799315135558591161

Now a scientific calculator tells ne that the tan of the above number is 0.049857973507496406210421036060919 degrees.

now tan -1 means I must shift the decimal point one place to the right?

So, am I right in thinking that the phase shift @330Hz through the above all pass is just a mere 0.5 degrees?
 
Last edited:
some of us are just lazy - let (Free!) software do the math

allpass.png


the inset is SciLab console calc for those who need better than the LtSpice cursor resolution
 
Last edited:
Thanks richie00boy - I knew that if there was likely to be a mistake, it'd be in the last part ...as I've not used tan, cos, etc since leaving school about 30 years ago (& thanks for not laughing!). On the standard XP 'calculator ...in scientific mode, do you know how to do an inverse tan on it?

That said, in the light of jcx's post above - it looks like either the formula in that Maxim sheet is wrong...or my interpretation of it is!


jcx ...I'm all for letting the software take the strain - & I note that it's got to a different outcome than my calculations - 331Hz through that circuit has a 109 degree lag ...I'd love to know why! (I'm assuming there's is right!). I'll try & work out how to get access to what you've got there - it looks funky (though the thought of having to knock up the whole circuit just to establish a phase shift isn't that appealing - I guess once it's done once though....)
 
Last edited:
Simply tick the Inv checkbox on the second row of buttons below the display.

Many thanks!

Sometimes simulated circuits show different results because op-amps have their own phase shifts as well, but it's usually just a very small difference. Something else is amiss.

That'll be me!

When I get a mo, I'll try again, but this time rather than covert to radians per sec, maybe I'll just give it a go with Frequency, extract from that datasheet....

An externally hosted image should be here but it was not working when we last tested it.



"where w is the frequencies in rad/s, or 2×pi×f, when f is in Hertz. "
 
Last edited:
Ok, I used Excel (using Radians per sec again)...

Input Values….
Resitance =68,000
Capacitance =0.00000001
R1C1 =0.00068000
w (Radians per sec) =2,073.451149
w² =4,299,199.66728942

Top Line of formula
2w = 4,146.90229800
R1C1 = 0.00068
Result (2w / R1C1) = 6,098,385.73235294

Bottom Part of formula (sub brackets)
1 / R1C1 = 1,470.58823529

Bottom Part of formula
w² minus 1 / R1C1 = 4,297,729.07905413
[w² minus 1 / R1C1]² = 18,470,475,236,947.4

Inverse Tangent of 18,470,475,236,947.4 =89.99900000 (let's call it 90 degrees!)

So a different figure again!

I am uncertain which order to do the maths on the lower part of the equation....

do I square 1/R1C1 then subtract that result from w²

*or*

do subtract 1/R1C1 from w² & then square that result?
 
Ok, richie00boy ....we were right with our first calculation!

The phase shift at 330Hz for an all pass filter circuit with the values of 68K & 10nf is +70.69213237 degrees

How do I know?

Well, I know the centre frequency for that circuit with those resistance & capacitance values - it's approx 235Hz (where this will yield a 90 deg phase shift). Here's the formula for the centre frequency...

1 / 2xPi x C1R1

So then I created a spreadsheet to work out what the same circuit's phase shift would be for 330Hz....it came out at +70.69213237 degrees.

Then, in my Excel spreadsheet's cell - where I enter the frequency as an input - I changed it to 235Hz (the centre frequency of the circuit) ....& the spreadsheet result changed to 90 degrees (ie the centre freq phase shift) ....bingo!

Alas, I'm unable to upload the spreadsheet, as this forum doesn't allow Excel Spreadhseet uploads. But if anyone wants a copy of the spreadsheet drop me a PM with your email address.
 
Last edited:
109.307... degrees is the "correct" answer

the sim's -109 comes from the software's phase unwrapping algorithm

a simple calculator style atan function is going to return a value between +/- pi/4 rad == +/-90 degrees while the "true" value of the phase shift may have an additional +/-n*180 degree phase

at "0" freq the cap is open and the circuit has a +1 gain == 0 phase shift

at high freq the cap is a short and the circuit is an inverter with -1 gain == 180 (or -180) degree phase shift

so the phase shift smoothly varies from 0 to either of +/-180 which means it goes beyond the +/-90 range of the elementary atan function

I believe the sign ambiguity enters with +/-180 degrees being "equal" so the software chooses one - probably using the magnitude response slope - which would be correct for a minimum phase circuit - which this is not


if you sim the circuit with a .tran you can see the phase shift is clearly greater than 90 degrees at 330 Hz, a frequency sweep should show the phase smoothly varying as I described above
 
Last edited:
Firstly, jcx - you're on firmer ground than I!

I'm kinda outta my league here, but it seems there are two possible phase shifts possible ... depending how C1 & R1 are arranged in that all pass circuit - either 'Inverting' or 'Non-Inverting' (source = http://sound.westhost.com/pcmm.htm#s22 ...fig 2.4).

The circuit I posted is a Non-Inverting All Pass (& this is very significant wrt the manner in which to calculate the phase shift!)

Re the values he has used on that website Figure 2.4 (R1 = 2.2K & C1 = 39nF), I note this extract...

"Phase shift at 3kHz is 116° or 64°, depending on the phase polarity selected"

(Incidentally, both those figures add up to 180°)

Well, when I tap his C1 & R1 values from Fig 2.4 into my spreadsheet, at 3Khz I get 63.45850366° as the phase shift. So it looks like my spreadsheet has been calculating the 'Inverting' All Pass filter phase shift (as opposed to the Non-Inverting circuit I'm using)

Coming back to my spreadsheet's calculation on my original circuit, it arrived at 70.69213237° ...and your software came in at 109.307°. Once again both add up to 180° (give or takes the odd 0.00001!).

I'll take your result as being right jcx (since both the software & your good self seem to know what you're talking about!)....it's a simple tweak to my spreadsheet, which now yields Inverting & Non-Inverting all pass phase shifts!

Anyway, I've learnt a bit today (not least about how to do Inverse Tan calculations within Excel!)...all's well that ends well.

Many thanks to both of you for your input/help.
Hank.
 
Last edited:
Hank,

Is it possible that you are using the wrong schematic. It looks like the formula you posted is for figure 2 and not figure 1. The spice results for figure 2 agree with your 70.69213237°.



Firstly, jcx - you're on firmer ground than I!

I'm kinda outta my league here, but it seems there are two possible phase shifts possible ... depending how C1 & R1 are arranged in that all pass circuit - either 'Inverting' or 'Non-Inverting' (source = http://sound.westhost.com/pcmm.htm#s22 ...fig 2.4).

The circuit I posted is a Non-Inverting All Pass (& this is very significant wrt the manner in which to calculate the phase shift!)

Re the values he has used on that website Figure 2.4 (R1 = 2.2K & C1 = 39nF), I note this extract...

"Phase shift at 3kHz is 116° or 64°, depending on the phase polarity selected"

(Incidentally, both those figures add up to 180°)

Well, when I tap his C1 & R1 values from Fig 2.4 into my spreadsheet, at 3Khz I get 63.45850366° as the phase shift. So it looks like my spreadsheet has been calculating the 'Inverting' All Pass filter phase shift (as opposed to the Non-Inverting circuit I'm using)

Coming back to my spreadsheet's calculation on my original circuit, it arrived at 70.69213237° ...and your software came in at 109.307°. Once again both add up to 180° (give or takes the odd 0.00001!).

I'll take your result as being right jcx (since both the software & your good self seem to know what you're talking about!)....it's a simple tweak to my spreadsheet, which now yields Inverting & Non-Inverting all pass phase shifts!

Anyway, I've learnt a bit today (not least about how to do Inverse Tan calculations within Excel!)...all's well that ends well.

Many thanks to both of you for your input/help.
Hank.
 
Hank,

Is it possible that you are using the wrong schematic. It looks like the formula you posted is for figure 2 and not figure 1. The spice results for figure 2 agree with your 70.69213237°.

lepomis,

Yes, you've hit the nail on the head - in the real world, I'm actually using an inverting all pass circuit (which I've actually breadboarded up with a variable resistor for R1). I then hastily created this thread late last night (hoping that I'd have an answer when I woke up here UK time!), but in my haste I linked to the wrong schematic 'variant' (posted up in order to help explain the situation to forum reader) Doh!

So my long hand (no Excel) calculation for my implementation of the all pass circuit was right (apart from the last bit that richie00boy corrected!)....ie the phase shift @330hz for C1 = 10nf, R1 = 68K is indeed 71°

*BUT*...

With the schematic I actually linked to in that first post (a non-inverting all pass), jcx was completely right - the phase shift there is 109.307°

😱

I'm still chuffed though, not having tackled such formulas for the best part of 30 years, it was quite an intimidating one for me to face up to! (& then learn how Excel -ise)
 
Last edited:
Could someone with one of those fancy calculators please punch in the following values....

R1 68k
C1 1nF
Frequency = 234.05Hz


My spreadsheet (which may still be wrong - dunno, still grappling with its output!), shows that for a non-inverting all pass filter circuit, the phase shift is 270°....& for an inverting all pass the phase shift is -90°.

I'm having some diffs grasping 270°vs -90° wrt the original signalhere. The way it looks to me, is that the non inverting has essentially a 90°phase lead & the inverting cct has a 90° phase lag?

Am I missing an obvious point? (probably!)

Another example, using yesterdays values....

R1 68k
C1 1nF
Frequency 330Hz

we got two results....

Non inverting = 109.307°
Inverting = 70.69°

Are both those results phase lags wrt the original signal presented at the input to the circuit?

Can anyone elaborate here as I'm getting my knickers in a twist?
 
I wrote a MATLAB script (probably full of mistakes) and inputted 68k and 1nF.

In the bottom left plot the value at 234.05 Hz is: 11.421119044682010 degree.

And in the bottom right plot the value at 234.05 Hz is: -168.5788809553180 degree.

The script:
format long;
R1 = 68e3;
C1 = 1e-9;
f = 0:1:1e6;
w = 2*pi*f;
phase = atan( ((2*w)/(R1*C1)) ./ ( (w.^2) - ((1/(R1*C1))^2) ) ) * (180/pi);

% Atan function compensation
phase_mod = phase;
for i=1:1:length(phase)
if ( phase(i) < 0 )
phase_mod(i) = phase(i) + 180;
end
end

phase_non_inverting = 180 - phase_mod;
phase_inverting = - phase_mod;

close all;
subplot(2,2,1);
semilogx(f, phase);
title('Phase directly from atan function');
xlabel('Frequency [Hz]');
ylabel('Phase shift [deg]');
grid on;

subplot(2,2,2);
semilogx(f, phase_mod);
title('Phase "lifted" for lack of better description');
xlabel('Frequency [Hz]');
ylabel('Phase shift [deg]');
grid on;

subplot(2,2,3);
semilogx(f, phase_non_inverting);
title('Phase on output signal non inverting all-pass filter');
xlabel('Frequency [Hz]');
ylabel('Phase shift [deg]');
grid on;

subplot(2,2,4);
semilogx(f, phase_inverting);
title('Phase on output signal inverting all-pass filter');
xlabel('Frequency [Hz]');
ylabel('Phase shift [deg]');
grid on;
 

Attachments

  • Phaseshift.PNG
    Phaseshift.PNG
    55.3 KB · Views: 109
Last edited:
Wow...what a reply! But Oops 😱 , I made a typo in my last post, the values should be

R1 = 68K
C1 = 10nF (not 1nF)

using those valuse the centre frequency should be 234.05Hz 990 deg phase shift)

Would you mind running that one more time, but this time with 10nF? (I don't have MATLAB!)
 
Many thanks...those number tie in with my own spreadsheet - but I'm just not uderstanding the results!

I'll start a new thread as this thread's title might not draw in that many towards getting some dialogue going so I can understand this a little better!
 
Status
Not open for further replies.