Phase shift calculation....

Started by Gurner, May 13, 2010, 05:09:36 PM

Previous topic - Next topic

Gurner

Just wondering if anyone can help.

What I seek is a calculator where I can say "I want a 10 degree phase shift at 330Hz" & it tells me what values of capacitor & resistor I need for an allpass filter

just about every calculator I've found up until now only gives you the 90 degree phase shift (centre frequency) for a given resistor & capacitor.....I've seen an underlying formula somewahere but it was well complicated to transpose!

Any ideas links etc?

R.G.

Congratulations. You have exposed the underlying issue with packaged calculators.

Network calculators not only prevent you from ever understanding what they calculate, they make you dependent on having the calculator. This is, by the way, one reason to put such a calculator on line - it drives up the traffic numbers for the web site which hosts it.

The problem is that you never do understand what is being calculated, and when a nonstandard calculation comes along you're out of luck.

My best advice is to go hunt down that underlying formula, and put in the work needed to understand what it does. When you do that, you're not only informed, you're no longer dependent.

Sorry - I don't know of any online calculators where you can put in the desired phase shift and get back the components. Even if such existed, it would probably not have included the underlying issues of impedance scaling, and would certainly not include the issue of what the surrounding circuitry loading does to the calculated phase shift. I wish I could help, but I can't.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

PRR

> gives you the 90 degree phase shift (centre frequency) for a given resistor & capacitor.....

Uhhh.... uhhh... a single R-C never gives 90 deg phase shift. It may reach 89.996 degrees or more.  "Approaches" 90 degree. Never gets there.

Single R-C network "corner frequency" (-3dB) gives 45 degree phase shift.

Multiple R-C, or any L-C network, gives more than 90 deg and would have a "90 deg" point. But that does not seem to be what you want.

> phase shift (centre frequency) for a given resistor & capacitor.....I've seen an underlying formula somewahere

Any filter-worker should "know" the phase curve of the popular filters. I don't; I have books for that. No books? So Google it...... urp! After two hard minutes Googling, I can NOT find a universal phase-shift plot for a one-pole network.

The idiot-assistant can do the math. An R-C, 10nFd 10K, -3dB at 1.58KHz, has 45 deg shift at 1.58KHz and 10 deg at 9.0KHz. This will transpose to any other C, R, and Hz: The 10 deg point is 5.7 times the frequency of the -3dB 45 deg point. And if you need a 13.456 deg shift, squint the curve and know the answer.

  • SUPPORTER

R.G.

There you go with all that understanding stuff, Paul. Why can't we just google harder and find a calculator that does what we need?

:icon_wink:
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Pablo1234

He is talking about the R and C in an all pass filter PRR, not an RC network. I agree with R. G. , learning to transpose the formulas will make developing small circuits super easy. I have a notebook I started in collage 15 years ago with most all the basic circuits and their formulas, I have one whole page of just transposed formulas for the state variable filter. I highly recommend you get the active filter cook book, read it like 20 times and actually do the math with a calculator. If your having problems with the math it means you jumped to far into the book, he really will break down the circuits mathematically. The all pass filter is really a simple circuit to transpose also.

Gurner

#5
Well, my only 'lead' for the formula I need, came from here - http://www.maxim-ic.com/app-notes/index.mvp/id/559

Which has this simple allpass filter circuit within....



The circuit is followed by the following assertion...

"The phase shift this circuit realizes at any given frequency can be found by..."



where w is the frequencies in rad/s, or 2×pi×f, when f is in Hertz.

Now I took one look at that Formula and instantly had to take a week off sick with severe projectile vomiting  ....so, towards getting me back on the wagon & putting some crust back on the family table again, can any egghead help out here with the transposition of formula?

For example ...if I want 3 degree phase shift at 330Hz, & I for arguments sake am using a 100k resistor in that circuit, then how do I jiggle that formula to reveal the value of the cap required to get such a 3 degree phase shift?  (now as it goes, I don't need a 3 degree phase shift - it's just an example, but the underlying formula would be very welcome)


R.G.

Quote from: Gurner on May 14, 2010, 09:05:19 AM
Now I took one look at that Formula and instantly had to take a week off sick with severe projectile vomiting  ....so, towards getting me back on the wagon & putting some crust back on the family table again, can any egghead help out here with the transposition of formula?
I mean this with all good feeling, not as criticism or a put-down. If you're going to do useful design work in electronics, you need to be able to handle that. I hope you were deeply into hyperbole.

Quote
Well, my only 'lead' for the formula I need, came from here - ...
"The phase shift this circuit realizes at any given frequency can be found by..."
where w is the frequencies in rad/s, or 2×pi×f, when f is in Hertz.
I don't need a 3 degree phase shift - it's just an example, but the underlying formula would be very welcome)

OK. First, that *is* the underlying formula. To get the answer you are looking for, you do the following manipulations:
- You replace everywhere "w" is with "2*pi*F"
- tan to the minus 1 power is the same as "arc tan" on your calculator.
- RC is the product of your resistor and capacitor, with R in ohms and C in farads. 1K = 1000, and 0.01uF is 1E-8F.

It's awfully early for algebra here, but I think I'd approach it as:

manipulate the formula into the form
x2w2 -(2w/tan(P(w)))x -1 =0
where x = R*C; w=2*pi*f; P(w) is phase angle- degrees or radians, the tangent is the same number;

Then I'd note that this is a quadratic polynomial of the form
ax2+bx+c = 0 with a replaced with w2, b replaced by -(2w/tan(P(w))), and c replaced by 1;
and get out my quadratic formula, which says that the roots of that equation are

x = (-b +/- SQRT(b2-4*a*c))/(2*a)

After doing all the substitutions, I get:

R*C = ((2*pi*f/tan(phase))-SQRT(16*pi2*f2/(tan(phase))2)-(16*pi2f2))/(8*pi2f2)
and
R*C = ((2*pi*f/tan(phase))+SQRT(16*pi2*f2/(tan(phase))2)-(16*pi2f2))/(8*pi2f2)
If I did all the algebra, parentheses, and translation to something I can type into this forum correctly. That last needs to be checked for reasonability by subbing in the numbers for a case you already know, that being the RC which gives you 90 degrees.

You get two answers out of this mess, and only one of them is a real answer. Negative values for the RC product are impossible in the real world, so this spurious root can be discarded.

Note that the answer is always in "RC". You get R or C by picking one and that sets the other. This is true in all RC circuits. You generally pick the one you have least real control of, that being the C which you can get in fewer values, and force the R to do the more delicate setting.

Having been through that, why would you ever need a precise phase shift at a particular frequency? That's useful in things like I-Q modulation and so on, but in normal effects work it's not terribly useful information. Just curious.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Gurner

#7
Wow RG - you rock (oh, by the way, I was only kidding about being sick - & I'm not a designer, just a hobbyyist trying to grapple with a few issues!)

I'll sit down in a quiet corner later today & try your transposition out!

FWIW,  I'm dabbling with a widget that is very sensitive to signal phase through the circuit, so your formula will be incredibly useful towards helping me kludge something better together.

(I'll likely use 10nf & 10k for your resulting formula, as I happen to know that yields a 90 degree centre frequency of 1.59kHz  ... source = http://sound.westhost.com/articles/active-filters.htm#s75


Gurner

#8
Ok, I've a bit of spare quality time to have a pop at this!

So,  it's it's gonna be on of  these two formulas...

R*C = ((2*pi*f/tan(phase))-SQRT(16*pi2*f2/(tan(phase))2)-(16*pi2f2))/(8*pi2f2)

or

R*C = ((2*pi*f/tan(phase))+SQRT(16*pi2*f2/(tan(phase))2)-(16*pi2f2))/(8*pi2f2)

Nice small catchy formulas eh?!  :icon_eek:

for the purposes of 'tan' in the very first part of the transposed formula ie...


R*C = ((2*pi*f/tan(phase))

should that be entered in degrees or radians (the TAN command in Excel - which is what I intend using - returns radians)

For example, I'm going to use a Capactance value of 10nf & a resistance value of  10k - I know this yields a 90 degree phase shift @1.59Khz . (which I will use to confirm the formula)

TAN(90) in Excel returns -1.9952004122082420252873530763796  

I just need confirmation of what I should be using!


CynicalMan

#9
If those formulae are correct, you couldn't test them out easily because tan(90°) (or tan(pi/2) in radians) is undefined. You need to enter radians for excel, but for pi/2 radians it would return an error.

PRR

> Why can't we just google harder and find a calculator that does what we need?

I was shocked that Google didn't turn-up a universal phase plot in a reasonably diligent search. An awful lot of "common knowledge" is getting left behind.

> He is talking about the R and C in an all pass filter PRR, not an RC network.

That all-pass IS the R-C, plus an op-amp.

It can be understood by understanding the R-C's action, then applying the op-amp action.

Yes, the opamp leverage gives a 180 deg shift between DC and infinity, so there is clearly a 90 shift somewhere.

It happens that I drew the R-C "backward" from how it is used in this all-pass implementation. But clearly the amplitude and phase curves are the same shape, just taken the other way around.

And aren't many practical audio phase shifters built with resistor to ground? Not cap to ground as Maxim's example shows? Reason: ganged variable resistors may be simpler if one end is static, not floating. Mechanical pots or photo-resistors can be either way, but JFETs are much simpler if ganged to-ground.

> learning to transpose the formulas

I do not argue with that. I'm just real bad at it, despite decades of mucking-around.

> make developing small circuits super easy.

There's different ways to be easy. Here's mine.

Well, first: plagiarize! This is not the first phase-shifter ever made. Although Gurner may not wish to exact-copy any previous shifter, "prior art research" is due diligence, a way to ward off major mistakes, and may give insight into issues you have not considered.

Another way: is this a mind-puzzle or a practical build? If you are gonna build it, just build it! With E-Z-change connections for key parts. Run a variable frequency signal in, measure the phase shift with a 'scope (or a couple CMOS gates will give a voltage proportional to phase). (There's an easier way to know the important phase shift without 'scope or fancy detector, but you must understand the circuit or do some differentiation of that messy equation....)

If you must work it out from ignorance:

What phase-shift do we want? What phase-shift matters? 3 deg even 10 deg is "nothing" in audio. There is ONE phase-shift which makes a BIG difference: a 180 degree shift mixed back into the original signal nulls the signal. 170 or 190 deg is near-null. Same if you add any number of 360 deg shifts. (Yes, 360 deg makes a mild boost, but that would not stand out so much if it were not framed by nulls.) 

If you know where your 180 deg shifts are, you can sketch the rest with sufficient accuracy.

So where is 180? In this all-pass, it is at infinite frequency. That's not much use for audio.

IIRC, such all-passes used as musical sweep filters are cascaded to get useful effect. Yes, you can get 180 deg shift with 3 deg shifters but you need 60 stages. IIRC we usually take four stages as a practical compromise between too-simple and too-complex (both in building and, it turns out, in audio effect.) Maybe two, maybe 20.... if we can find a method to estimate what 4 does we can swiftly figure 2 or 13 or whatever.

To get the magic 180 deg with four identical stages we want to know the 45 deg phase shift frequency.

ASS-ume this may be where the R-C has 45 deg shift, at the -3dB corner. Using Maxim's version, C1 is 45 deg lagging. Obviously the voltage across R1 must be 45 deg leading. By opamp action the voltage across left-R must equal voltage across R1. Right-R will be driven to make this so. The difference is then (-45)+(+45) or 90 deg lagging.

This derivation was so simple, we may ass-ume that the opamp doubles the R-C phase shift. So to find the allpass's 180/4= 45 deg shift, we must find the R-C network's 22.5 deg shift.

That's where the Universal Phase Shift Curve is handy. I happened to draw it for 1.6K corner (to be Universal it would be nice to have it at 1Hz). The 22.5 deg shift squints as 4KHz. Therefore the 22.5 deg shift point is 2.5 (or maybe 0.4) times the corner frequency.

There will also be a null at 540 deg, 135 deg per section, 67.5 deg in the RC. This happens at 2.28 corner frequency. The next would be at 360+360+180 deg, 112.5 per RC.... but the RC won't go over 90 deg, so this won't happen.

Now we know that a 4-stage all-pass only gives two nulls, therefore one peak. This is a fairly lame effect. And some plagiarism/research shows that more-than-four stages have been used.

> you couldn't test them out easily because tan(90°) (or tan(pi/2) in radians) is undefined

This is equivalent to saying that a single RC will never give 90 deg phase shift. Or conversely that asking for an RC to give 90 deg is not a good question. Numbers from zero to 89 deg give dandy answers. My calculator easily answers for 89.99 deg, though I don't know if we care.

  • SUPPORTER

TELEFUNKON

Quote from: PRR on May 23, 2010, 02:36:45 AM
That all-pass IS the R-C, plus an op-amp.
It can be understood by understanding the R-C's action, then applying the op-amp action.
Yes, the opamp leverage gives a 180 deg shift between DC and infinity, so there is clearly a 90 shift somewhere.
It happens that I drew the R-C "backward" from how it is used in this all-pass implementation. But clearly the amplitude and phase curves are the same shape, just taken the other way around.

And aren't many practical audio phase shifters built with resistor to ground? Not cap to ground as Maxim's example shows? Reason: ganged variable resistors may be simpler if one end is static, not floating. Mechanical pots or photo-resistors can be either way, but JFETs are much simpler if ganged to-ground.

seriesresistor with cap to ground means lowpass at the noninverting input, seriescap with resistor to ground  means highpass at the input: isn`t the latter more prone to hiss? (differentiator instead of integrator behaviour)

Gurner

Thanks guys.

I'm not making a phase shifter effect - I just need to compensate for signal phase for predetermined  frequencies.

It's not so critical that I need to get down to decimal points(!) but it would be nice to have a useable formula that gives me the approximate 'starting ballpark CR values' need for say 15 degreee phase shift at  380Hz (becuase then I could put in a pot which can sweep  either side  of the chosen phase shift).

I'm sure RG's transposition of the original formula I found is fine, but such is my woeful grasp of trigonometry (& maths) I still don't know whether for the purposes of the formula whether the TAN should be in degrees or radians!

Gurner

So when the phase formula 'going gets tough'    gurner gets  erhm, I mean ......goes.  :icon_redface:

It's a fair cop - in the end I went the kludgers way - ie trial & error & a scope, sig gen & whole heap of resistors/caps - by swapping them in/out I got in the general ballpark for the phase shift I need  :icon_lol:

Thanks all for you input - hopefully, someone better at trig/maths than I can put RG's superb transposition above to good use!