Transfer function of RC circuit and phase shift

recently I have been learning about oscillators and I need a little help with that. I am kind of a guy that likes deriving things and it helps me understand how the circuit itself behaves. The thing is, when we talk about oscillators, I want to connect RC circuit in my feedback loop of my oscillator. But at first, I want to calculate the transfer function itself and plot it so I can have better insight of what's going on. I am going to guide you through all my steps I've done so far.

So at first, I have three RC low-pass filters connected together. You can see them on the picture below (taken from LTSpice).

From the picture above I have derived the transfer function (using the voltage divider theorem) that looks like the picture below.

What I did next was to continue ,,unboxing" the equation to this form below:

Now according to the Black's theorem that states the relationship between feedback loop and actual amplifying stage of the circuit, we can make assumption that alpha times beta must be equal to one (0j is basically shown there to make sure the phase is 0 degrees).

Now back to our RC feedback circuit - my goal is to achieve 180 degrees and find the frequency at which this happens. I want to have 180 degrees phase shift because the signal is then passed into the inverting input of operational amplifier which adds another 180 degrees to signal, making it 0 degrees in phase.

I proceeded in calculating the transfer function where I split it into two parts - real and imaginary. According to what I know, we can easily find an angle using tangens. (I know the picture below looks scary but stay with me a moment, please).

Next I realized at which frequency do we have 180 degrees phase shift on the output? I tried to figure it out using tangens, as I mentioned before (we know that angle is imaginary part divided by real part).

The above equation shows at which frequency this phase shift should happen. But it's incorrect and I don't know why. Don't judge me, I was just trying to take different approach and learn something in the process. When I set my resistors and capacitors to R = 100 Ohms, C = 10uF, I calculated the frequency of around 275,80 Hz. I put it inside LTSpice and this is what I got from AC analysis:

If anyone know what's wrong, please let me know. Any sensible answers are accepted.

• Your transfer function is incorrect because you haven't taken account of loading effects of the next RC filter on the previous. Apr 20, 2023 at 21:25
• tom, I've already discussed the situation here. Though the question was for the high-pass version, I made my answer general enough so that it covers your situation, too. Apr 20, 2023 at 22:10
• tom, These phase shift oscillators appear to be a common thread at EESE. I get almost 400 hits searching for "phase shift RC". This settles down when searching for "phase shift RC transfer 29" (I added the 29 because I know something.) When I do all of that, I get this link, which does cover things similarly to what I wrote here. So there are at least a couple of appropriate answers here, already. Does @Andy 's comment plus those details suffice? Or is there something remaining? Apr 20, 2023 at 23:08
• But tom, your mistake begins at the outset of your question -- in the very first transfer function expression where you apply the cube of a single RC. That's the point of failure. So none of the rest follows. Apr 20, 2023 at 23:10

The transfer function you derived assumes that each RC stage does not load the previous one. It would be correct if you buffered each stage, like this:

simulate this circuit – Schematic created using CircuitLab

This overcomes the problem that each RC stage "loads" the previous one. I won't do a complete analysis, but consider the following 2-stage RC filter:

simulate this circuit

In isolation, R1 and C1 form a potential divider where the signal $$\v_A\$$ at A would indeed be

$$v_A = v_{IN}\frac{Z_{C1}}{R_1+Z_{C1}}$$

Unfortunately though, node A is not isolated, and the series pair of R2 & C2 are effectively in parallel with C1. That means the actual impedance $$\Z_{AG}\$$ between A and G is:

$$Z_{AG} = Z_{C1}\parallel (Z_{C2}+R_2)$$

The signal at A becomes:

$$v_A = v_{IN}\frac{Z_{AG}}{R_1+Z_{AG}}$$

With a third RC pair loading B as well, complexity is even further compounded, with $$\Z_{AG}\$$ changing yet again, becoming a function of all four impedances following it!

In the first circuit, with the op-amp followers effectively isolating each stage from the next, then you can say $$\Z_{AG} = Z_{C1}\$$.

If ever you found yourself wondering why second and higher order filters are usually constructed using op-amps, well, this is one reason why.

• I'll look into it once I get home. But I see what you are trying to say here. And it all makes sense. Apr 21, 2023 at 5:54

If you want to determine this transfer function seamlessly, the best is to resort to the fast analytical circuits techniques or FACTs. A tutorial introduction is proposed in my APEC 2016 seminar. The principle is to look at the time constants of the circuit in different conditions, when the excitation ($$\V_{in}\$$) is reduced to 0 V or replaced by a short circuit in the schematic. Then, you "look" at the resistance offered by each of the energy-storing elements (the capacitors in this example) when the rest of the elements are placed in their dc or high-frequency state. Look at the below sketch:

First, you look at the transfer function $$\H_0\$$ for $$\s=0\$$: open all the caps and find that $$\H_0=1\$$. Then, determine by inspection - meaning, just observe the schematic - the resistance offered by each capacitor's connecting terminals when the other caps are set to their dc state (infinite impedance or removed from the circuit).

Now reduce the excitation to 0 V and replace the source by a wire in the schematic. For $$\C_1\$$, the resistance you "see" is the series connection of $$\R_1\$$ and $$\R_2\$$ so the first time constant is $$\\tau_1=C_1(R_1+R_2)\$$. For $$\\tau_2\$$, the resistance is $$\R_2\$$ then $$\\tau_2=C_2R_2\$$. And for $$\\tau_3\$$, the resistance is $$\R_1+R_2+R_0\$$ then $$\\tau_3=C_0(R_1+R_2+R_0)\$$. Adding these time constants forms the first denominator coefficient $$\b_1=\tau_1+\tau_2+\tau_3\$$. 1 mn to obtain this result without a calculation, just inspection.

For the second term, $$\b_2\$$, we will look at $$\\tau_{12}\$$, $$\\tau_{13}\$$ and $$\\tau_{23}\$$. This notation simply means that for $$\\tau_{12}\$$, you "look" at the resistance driving $$\C_2\$$ while $$\C_1\$$ is set in its high-frequency state (a short circuit). For instance, looking at the above sketch, you see that $$\\tau_{12}=C_2(R_1||R_2)\$$. Continue and form $$\b_2=\tau_1\tau_{12}+\tau_1\tau_{13}+\tau_2\tau_{23}\$$.

For the final term, $$\b_3\$$, determine $$\\tau_{123}\$$: look at the resistance from $$\C_0\$$ terminals while $$\C_1\$$ and $$\C_2\$$ are set in their high-frequency state (a short circuit). Then, assemble $$\b_3=\tau_1\tau_{12}\tau_{123}\$$. This is it, you have your denominator $$\D(s)=1+sb_1+s^2b_2+s^3b_3\$$ and the transfer function is immediate and equal to

$$\H(s)=H_0\frac{1}{1+sb_1+s^2b_2+s^3b_3}\$$.

with:

$$\b_1=R_1C_1+R_2(C_1+C_2)+C_0(R_1+R_2+R_0)\$$ $$\b_2=C_1(R_1+R_2)(C_2(R_1||R_2)+R_0C_0)+R_2C_2C_0(R_1+R_0)\$$ $$\b_3=C_1C_2C_0R_1R_2R_0\$$

If all resistors and capacitor share a common value, as in your schematic, the final result is given below:

The ac response appears below and you can see that both brute-force transfer function and the one I obtained by inspection are rigorously equivalent in magnitude and phase:

As you can see with the FACTs, I did not write a single line of algebra and chopped the original schematic in a series of small sketches individually observed. You can now expand the expression I derived by replacing $$\s\$$ by $$\j\omega\$$ and determine the value of $$\\omega\$$ for which the imaginary part cancels.

• Readers are advised to skip/ignore this answer at their own peril only. Fast Analytical Techniques are not taught nearly often enough, in spite of being necessary not to get mired in complexity where such complexity is superfluous. It's still baffling to me. From what I can tell, VK is an avid advocate for those techniques, and that's IMHO for a very good reason: not being practiced in their use is a real handicap. Apr 23, 2023 at 17:02

I almost can't think of much to add. However, I will use the information available in both those above in the following way (using freely available Sympy and Sage):

def G(n,z):
if n < 1 : return H(n,z)
return H(n,z)*G(n-1,z)
def H(n,z):
if n < 1:return 1
return 1/(2+z-H(n-1,z))
R,C,omega = symbols('R,C,omega',real=True)     ' Variables are real-domain.
ZC = 1/(s*C)                                   ' Impedance of C.
Z1 = R / ZC                                    ' RC stage ratio (ZC/R for CR stage.)
tf1 = simplify(ratsimp( G( 3, Z1 ) ))          ' Compute the transfer function.
tf1                                            ' Display the transfer function.
1/(C**3*R**3*s**3 + 5*C**2*R**2*s**2 + 6*C*R*s + 1)


Since this must provide $$\180^\circ\$$ of phase shift (the inverter providing the remaining $$\180^\circ\$$), the imaginary portion goes $$\\to0\$$. So:

im1 = im(fraction(tf1)[1].subs(s,I*omega))     ' Extract denominator & sub s=j*omega
im1
-C**3*R**3*omega**3 + 6*C*R*omega
solve( Eq(im1,0), omega )[0]
sqrt(6)/(C*R)


So if $$\\tau=R\,C\$$ then $$\\omega=\frac{\sqrt{6}}{\tau}\$$ or $$\f=\frac{\sqrt{6}}{2\pi\,R\,C}\$$.

Were this a series of 3 CR stages then:

Z2 = ZC / R
tf2 = simplify(ratsimp( G( 3, Z2 ) ))
re2 = re(fraction(tf2)[1].subs(s,I*omega))
solve( Eq(re2,0), omega )[0]
sqrt(6)/(6*C*R)


I used the real part in this case because the numerator of tf2 had $$\s^3\$$ in it, which is imaginary when $$\s=j\,\omega\$$. So in this case $$\f=\frac1{2\pi\sqrt{6}\,R\,C}\$$.

I thought I'd add some predictions based upon the above analysis tools for the RC case (not the CR.)

First, here's a table:

\begin{align*} N&&\text{Required Gain}&&\text{Scaling Factor}=\omega\tau\\\\ 3&&29&&\sqrt{6}\approx 2.449\\\\ 4&&\frac{901}{49}\approx 18.4&&\frac17\sqrt{70}\approx 1.195\\\\ 5&&217\sqrt{181}-2904\approx 15.4&&\sqrt{14-\sqrt{181}}\approx 0.739\\ \end{align*}

From:

for i in range(3,6):
s_tf = simplify(ratsimp(G(i,Z1)))
s_omega = solve(Eq(im(fraction(s_tf)[1].subs(s,I*omega)),0),omega)[0]
s_K = 1/abs(simplify(G(i,Z1)).subs(s,I*s_omega))
(i, s_tf, s_K, s_omega)

(3,
1/(C**3*R**3*s**3 + 5*C**2*R**2*s**2 + 6*C*R*s + 1),
29,
sqrt(6)/(C*R))
(4,
1/(C**4*R**4*s**4 + 7*C**3*R**3*s**3 + 15*C**2*R**2*s**2 + 10*C*R*s + 1),
901/49,
sqrt(70)/(7*C*R))
(5,
1/(C**5*R**5*s**5 + 9*C**4*R**4*s**4 + 28*C**3*R**3*s**3 + 35*C**2*R**2*s**2 + 15*C*R*s + 1),
-2904 + 217*sqrt(181),
sqrt(14 - sqrt(181))/(C*R))


The required gain declines when adding more stages. One might first imagine the opposite, guessing that more stages should cause more attenuation. But as the frequency also declines, the impedance of the frequency-dependent capacitors increase and therefore each of them attenuates less. So the net impact is to require less gain, not more, as $$\N\$$ increases.

Now use $$\R=10\:\text{k}\Omega\$$ and $$\C=100\:\text{nF}\$$. This suggests a basic frequency of $$\f_{_0}=\frac1{2\pi\,R\,C}\approx 159.155\:\text{Hz}\$$. But the above scaling factors must be applied to that figure. So:

• $$\N=3\$$: Expect $$\f=2.449\cdot 159.155\:\text{Hz}\approx 398.77\:\text{Hz}\$$
• $$\N=4\$$: Expect $$\f=1.195\cdot 159.155\:\text{Hz}\approx 190.19\:\text{Hz}\$$
• $$\N=5\$$: Expect $$\f=0.739\cdot 159.155\:\text{Hz}\approx 117.62\:\text{Hz}\$$

Setting things up with at least the required gain (a little more just to be sure) provides the following schematic and results:

(Feel free to expand the image by clicking on it.)

I buffered the output of the phase shift section so as not to load it down. And I provided two different gain stages. One to drive the input of the phase shift section with at least the required gain. The other to provide some gain (for visibility reasons) for the buffered output. (Yeah. More opamps. But it's just a simulator. So they are free.)

LTspice says that with $$\N=3\$$ $$\f=389.29\:\text{Hz}\$$, with $$\N=4\$$ $$\f=190.12\:\text{Hz}\$$, and with $$\N=5\$$ $$\f=117.20\:\text{Hz}\$$. (My measurement technique was approximate, using its cursors.) These are all quite consistent with theoretical prediction.

Note that the Cadence link on 'RC Phase Shift Oscillator Design for Sine Wave Generation' uses an incorrect calculation for the frequency, except in the case of $$\N=3\$$ where they do get it right.

(Note also that you could clearly just buffer each stage in order to remove its load. Then the equation develops more as you suggested.)

Fibonacci relationship

The factors in the characteristic equation for the RC sequence of $$\N\$$ stages follows, as one might expect, some kind of relationship to Pascal's triangle and Fibonacci. And it does:

This can be used to solve for $$\\omega\$$ and for the gain. I won't write more about that except to offer a Python function that produces the array of constants:

def J(n):
result = []
for j in range(n+1):
result.append(binomial(2*n-j,j))
return result
for i in range(9):(i,J(i),sum(J(i)))
(0, [1], 1)
(1, [1, 1], 2)
(2, [1, 3, 1], 5)
(3, [1, 5, 6, 1], 13)
(4, [1, 7, 15, 10, 1], 34)
(5, [1, 9, 28, 35, 15, 1], 89)
(6, [1, 11, 45, 84, 70, 21, 1], 233)
(7, [1, 13, 66, 165, 210, 126, 28, 1], 610)
(8, [1, 15, 91, 286, 495, 462, 210, 36, 1], 1597)


There's a slightly interesting link here from mathexchange, too.

Well, we are trying to analyze the following circuit:

simulate this circuit – Schematic created using CircuitLab

When we use and apply KCL, we can write the following set of equations:

\begin{cases} \begin{alignat*}{1} \text{I}_1&=\text{I}_2+\text{I}_3\\ \\ \text{I}_3&=\text{I}_4+\text{I}_5\\ \\ 0&=\text{I}_0+\text{I}_4+\text{I}_5\\ \\ \text{I}_2&=\text{I}_0+\text{I}_1 \end{alignat*} \end{cases}\tag1

When we use and apply Ohm's law, we can write the following set of equations:

\begin{cases} \begin{alignat*}{1} \text{I}_1&=\frac{\text{V}_\text{i}-\text{V}_1}{\text{R}_1}\\ \\ \text{I}_2&=\frac{\text{V}_1}{\text{R}_2}\\ \\ \text{I}_3&=\frac{\text{V}_1-\text{V}_2}{\text{R}_3}\\ \\ \text{I}_4&=\frac{\text{V}_2}{\text{R}_4}\\ \\ \text{I}_5&=\frac{\text{V}_2-\text{V}_3}{\text{R}_5}\\ \\ \text{I}_5&=\frac{\text{V}_3}{\text{R}_6} \end{alignat*} \end{cases}\tag2

Substitute $$\(2)\$$ into $$\(1)\$$, in order to get:

\begin{cases} \begin{alignat*}{1} \frac{\text{V}_\text{i}-\text{V}_1}{\text{R}_1}&=\frac{\text{V}_1}{\text{R}_2}+\frac{\text{V}_1-\text{V}_2}{\text{R}_3}\\ \\ \frac{\text{V}_1-\text{V}_2}{\text{R}_3}&=\frac{\text{V}_2}{\text{R}_4}+\frac{\text{V}_2-\text{V}_3}{\text{R}_5}\\ \\ 0&=\text{I}_0+\frac{\text{V}_2}{\text{R}_4}+\frac{\text{V}_2-\text{V}_3}{\text{R}_5}\\ \\ \frac{\text{V}_1-\text{V}_2}{\text{R}_3}&=\frac{\text{V}_2}{\text{R}_4}+\frac{\text{V}_3}{\text{R}_6}\\ \\ 0&=\text{I}_0+\frac{\text{V}_2}{\text{R}_4}+\frac{\text{V}_3}{\text{R}_6}\\ \\ \frac{\text{V}_1}{\text{R}_2}&=\text{I}_0+\frac{\text{V}_\text{i}-\text{V}_1}{\text{R}_1} \end{alignat*} \end{cases}\tag3

Now, applying this to your circuit we need to use (from now on I use the lower case letters for the function in the 'complex' s-domain where I used Laplace transform):

• $$\text{R}_2=\frac{1}{\text{sC}_1}\tag4$$
• $$\text{R}_4=\frac{1}{\text{sC}_2}\tag5$$
• $$\text{R}_5=\frac{1}{\text{sC}_3}\tag6$$

Now, using the fact that $$\\text{R}:=\text{R}_1=\text{R}_2=\text{R}_3\$$ and $$\\text{C}:=\text{C}_1=\text{C}_2=\text{C}_3\$$ we can simplify the tranfer function in order to get:

$$\mathscr{H}\left(\text{s}\right):=\frac{\text{v}_3\left(\text{s}\right)}{\text{v}_\text{i}\left(\text{s}\right)}=\frac{1}{\left(\text{CRs}\right)^3+5\left(\text{CRs}\right)^2+6\text{CRs}+1}\tag7$$

So, for the absolute value, we get:

$$$$\begin{split} \left|\space\underline{\mathscr{H}}\left(\text{j}\omega\right)\right|&=\left|\frac{1}{\left(\text{CR}\text{j}\omega\right)^3+5\left(\text{CR}\text{j}\omega\right)^2+6\text{CR}\text{j}\omega+1}\right|\\ \\ &=\frac{\left|1\right|}{\left|1-5\left(\text{CR}\omega\right)^2+\text{CR}\omega\left(6-\left(\text{CR}\omega\right)^2\right)\text{j}\right|}\\ \\ &=\frac{1}{\sqrt{\left(1-5\left(\text{CR}\omega\right)^2\right)^2+\left(\text{CR}\omega\left(6-\left(\text{CR}\omega\right)^2\right)\right)^2}} \end{split}\tag8$$$$

And for the argument we get:

$$$$\begin{split} \arg\left(\underline{\mathscr{H}}\left(\text{j}\omega\right)\right)&=\arg\left(\frac{1}{\left(\text{CR}\text{j}\omega\right)^3+5\left(\text{CR}\text{j}\omega\right)^2+6\text{CR}\text{j}\omega+1}\right)\\ \\ &=\arg\left(1\right)-\arg\left(\left(\text{CR}\text{j}\omega\right)^3+5\left(\text{CR}\text{j}\omega\right)^2+6\text{CR}\text{j}\omega+1\right)\\ \\ &=0-\arg\left(1-5\left(\text{CR}\omega\right)^2+\text{CR}\omega\left(6-\left(\text{CR}\omega\right)^2\right)\text{j}\right)\\ \\ &=-\arg\left(\underbrace{1-5\left(\text{CR}\omega\right)^2}_{:=\space\Re}+\underbrace{\text{CR}\omega\left(6-\left(\text{CR}\omega\right)^2\right)}_{:=\space\Im}\text{j}\right)\\ \\ &=-\begin{cases} 0&\space\Re=0\space\wedge\space\Im=0\\ \\ \frac{\pi}{2}&\space\Re=0\space\wedge\space\Im>0\\ \\ \pi&\space\Re<0\space\wedge\space\Im=0\\ \\ \frac{3\pi}{2}&\space\Re=0\space\wedge\space\Im<0\\ \\ \arctan\left(\frac{\Im}{\Re}\right)&\space\Re>0\space\wedge\space\Im>0\\ \\ \frac{\pi}{2}+\arctan\left(\frac{\left|\Re\right|}{\Im}\right)&\space\Re<0\space\wedge\space\Im>0\\ \\ \pi+\arctan\left(\frac{\left|\Im\right|}{\left|\Re\right|}\right)&\space\Re<0\space\wedge\space\Im<0\\ \\ \frac{3\pi}{2}+\arctan\left(\frac{\Re}{\left|\Im\right|}\right)&\space\Re>0\space\wedge\space\Im<0 \end{cases}\\ \\ &=-\begin{cases} \frac{\pi}{2}&\space\omega=\frac{1}{\text{CR}\sqrt{5}}\\ \\ \pi&\space\omega=\frac{\sqrt{6}}{\text{CR}}\\ \\ \arctan\left(\frac{\Im}{\Re}\right)&\space0<\omega<\frac{1}{\text{CR}\sqrt{5}}\\ \\ \frac{\pi}{2}+\arctan\left(\frac{\left|\Re\right|}{\Im}\right)&\space\frac{1}{\text{CR}\sqrt{5}}<\omega<\frac{\sqrt{6}}{\text{CR}}\\ \\ \pi+\arctan\left(\frac{\left|\Im\right|}{\left|\Re\right|}\right)&\space\omega>\frac{\sqrt{6}}{\text{CR}} \end{cases}\\ \end{split}\tag9$$$$

I used the following mathematica-code to solve this question:

In[1]:=Clear["Global*"];
R1 = R;
R3 = R;
R5 = R;
R2 = 1/(s*C1);
R4 = 1/(s*C2);
R6 = 1/(s*C3);
C1 = c;
C2 = c;
C3 = c;
FullSimplify[(V3 /.
Solve[{I1 == I2 + I3, I3 == I4 + I5, 0 == I0 + I4 + I5,
I2 == I0 + I1, I1 == (Vi - V1)/R1, I2 == V1/R2,
I3 == (V1 - V2)/R3, I4 == V2/R4, I5 == (V2 - V3)/R5,
I5 == V3/R6}, {I0, I1, I2, I3, I4, I5, V1, V2, V3}][[1]])/Vi]

Out[1]=1/(1 + c R s (2 + c R s) (3 + c R s))
`
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 87, "wp-katex-eq": 0, "align": 0, "equation": 2, "x-ck12": 0, "texerror": 0}