Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Filters, Low Pass and Others

Status
Not open for further replies.

MrAl

Well-Known Member
Most Helpful Member
Hello,


I am starting this thread on behalf of another member who is currently studying these topics.

We will start with a simple low pass filter using an op amp and possibly move on to other more complicated circuits. We'll be doing a full analysis finding the response and other interesting things about filters including cut off frequency.


The first LOW PASS filter is this one:


Code:
The circuit is a low pass filter:


               +---------R2--------------+
               |                         |
               +---------C2--------------+
               |               |\        |
               |               | \       |
               |               |  \      |
Vin o----R1----+---------------|-  \     |
                               |    +----+-----o Vout
                            +--|+  /     
                            |  |  /      
                            |  | /       
                            |  |/        
                            |
                            |
                            |
                            |
GND o-----------------------+------------------o GND



We can generalize the circuit by naming the feedback network impedance Z2 and input network impedance Z1:

Code:
Generalized with impedance networks Z1 and Z2:

               +--------Z2---------------+
               |               |\        |
               |               | \       |
               |               |  \      |
Vin o----Z1----+---------------|-  \     |
                               |    +----+----o Vout
                            +--|+  /     
                            |  |  /      
                            |  | /       
                            |  |/        
                            |    
                            |            
                            |            
                            |            
    o-----------------------+-----------------o

where

Z1 is the input resistor R1, and
Z2 is the parallel combination of the impedance of C2 and the the impedance of R2.

The impedance of R2 is simply R2, and the impedance of C2 is:
zC2=1/(j*w*C2)

where

w is the angular frequency equal to 2*pi*f, and
j is the imaginary operator where j^2=-1.

And also since if we multiply the top and bottom of zC2 by j we get:
zC2=j/(j*j*w*C2)

which simplifies to:
zC2=-j/(w*C2)


To put any two impedances in parallel, we use:
Zp=Za*Zb/(Za+Zb)

In this case we want to compute Z2 so we use Za=R2 and Zb=zC2, so we have:
Zp=R2*zC2/(R2+zC2)

which comes out to:
Zp=R2*(-j/(w*C2))/(R2-j/(w*C2))

So now we know what Z2 is:
Z2=Zp=-(R2*j/(w*C2))/(R2-j/(w*C2))


Now because the non inverting terminal is connected to ground we can solve the circuit
quite easily knowing Z1 and Z2, but instead lets be a bit more general and use
superposition.

Since we know the input is Vin and the output is Vout, lets first short Vin and solve for
the voltage at the inverting terminal:
vn1=Vout*Z1/(Z1+Z2)

and again with Vout shorted and Vin not shorted solve for the voltage at the inverting terminal:
vn2=Vin*Z2/(Z1+Z2)

and now the total voltage at the inverting terminal vn is:
vn=vn1+vn2
or
vn=Vout*Z1/(Z1+Z2)+Vin*Z2/(Z1+Z2)

and since this is connected to the inverting terminal it gets subtracted from zero and amplified
by the internal gain of the op amp we'll call Aol, so we have implicitly:
Vout=(0-vn)*Aol=Aol*(-(Vin*Z2)/(Z2+Z1)-(Vout*Z1)/(Z2+Z1))

Now we solve for Vout explicitly:
Vout=Aol*(-(Vin*Z2)/(Z2+Z1)-(Vout*Z1)/(Z2+Z1))
Vout=-(Aol*Vin*Z2)/(Z2+Z1)-(Aol*Vout*Z1)/(Z2+Z1)
Vout+(Aol*Vout*Z1)/(Z2+Z1)=-(Aol*Vin*Z2)/(Z2+Z1)
Vout*(Z2+Aol*Z1+Z1)/(Z2+Z1)=-(Aol*Vin*Z2)/(Z2+Z1)
Vout*(Z2+Aol*Z1+Z1)=-(Aol*Vin*Z2)
Vout=-(Aol*Vin*Z2)/(Z2+Aol*Z1+Z1)

and since Aol is considered very high, we take the limit as Aol goes to infinity and get:
Vout=-Vin*Z2/Z1

and the amplitude is:
|Vout|=-|Vin|*sqrt(RZ2^2+IZ2^2)/sqrt(RZ1^2+IZ1^2)

where
RZ2 is the real part of Z2, and IZ2 is the imag part of Z2, and
RZ1 is the real part of Z1, and IZ1 is the imag part of Z1.

This means we only have to know the real and imaginary parts of Z1 and Z2 to get the
amplitude response, and notice that if we divide both sides by Vin we get:
|Vout/Vin|=-|Z2|/|Z1|=-sqrt(RZ2^2+IZ2^2)/sqrt(RZ1^2+IZ1^2)

So it turns out that the amplitude transfer function is just the negative of the feedback network impedance
amplitude divided by the input network impedance amplitude.

Since we know what Z1 and Z2 are:
Z1=R1
Z2=-(R2*j/(w*C2))/(R2-j/(w*C2))

all we have left to do is divide Z2 by Z1 and then multiply by -1.

It helps here to simplify Z2 a little...

multiply top and bottom by w*C2:
-R2*j/(w*C2*R2-j)

multiply top and bottom by the conjugate of the bottom (which is w*C2*R2+j):
-R2*j*(w*C2*R2+j)/((w*C2*R2-j)*(w*C2*R2+j))

and simplify the top and the bottom separately:
(-w*C2*R2^2*j-R2*j^2)/(w*C2*R2)^2-j^2)

and since j^2=-1 we simplify more:
(-w*C2*R2^2*j+R2)/(w*C2*R2)^2+1)

so we have Z2 simplified now:
Z2=(-w*C2*R2^2*j+R2)/(w*C2*R2)^2+1)

and now we divide by R1 and get:
Z2/Z1=((-w*C2*R2^2*j+R2)/(w*C2*R2)^2+1))/R1
Z2/Z1=(-w*C2*R2^2*j+R2)/(R1*(w*C2*R2)^2+R1)

and multiply by -1 and get:
-Z2/Z1=(w*C2*R2^2*j-R2)/(R1*(w*C2*R2)^2+R1)

and then noting that the numerator is:
N=(w*C2*R2^2*j-R2)

and the denominator is:
D=(w*C2*R1*R2)^2+R1

we have:
|Vout|=-|Vin|*sqrt(RN^2+IN^2)/sqrt(RD^2+ID^2)

where RN is the real part of the numerator and IN is the imaginary part of the numerator and
RD is the real part of the denominator and ID is the imaginary part of the denominator.

So separating the real and imag parts in the numerator we get:
RN=-R2
IN=w*C2*R2^2

and in the denominator we have:
RD=R1*(w*C2*R2)^2+R1
IN=0

so the final response is:
|Vout|=sqrt((-R2)^2+(w*C2*R2^2)^2)/(R1*(w*C2*R2)^2)+R1)

noting that the square of the square root of RD^2+0^2 is just RD, and that comes out to:
|Vout|=sqrt(w^2*C2^2*R2^4+R2^2)/(R1*(w^2*C2^2*R2^2+1))

or:
|Vout|=(sqrt(w^2*C2^2*R2^2+1)*(R2))/(R1*(w^2*C2^2*R2^2+1))

which simplifies to:
|Vout|=R2/(R1*sqrt(w^2*C2^2*R2^2+1))

and that is the output response.

To summarize, the response because the non inverting terminal is connected to ground is:

|Vout/Vin|=-|Z2|/|Z1|=-sqrt(RZ2^2+IZ2^2)/sqrt(RZ1^2+IZ1^2)

where
RZ1 is real part of Z1,
IZ1 is imag part of Z1,
RZ2 is real part of Z2,
IZ2 is imag part of Z2.


I highly recommend following this throughout rather than skipping to the end and using the formula
because other more complex circuit will require a little more work. Here we assumed that the
non inverting terminal was connected to ground but that's certainly not always the case. When the
non inverting terminal is not connected to ground we have to do a more full analysis.
 
Last edited:
Why do you use so much math for such a simple filter?
The only arithmatic you need is 1 divided by (2 x pi x R x C) which is its cutoff frequency.
Since it has only one RC then it is very simple with poor performance.
Because it is very simple then it is a lousy filter.
Its frequency response drops at -6dB (half the level which is not much drop) per octave.
 
Why do you use so much math for such a simple filter?
The only arithmatic you need is 1 divided by (2 x pi x R x C) which is its cutoff frequency.
Since it has only one RC then it is very simple with poor performance.
Because it is very simple then it is a lousy filter.
Its frequency response drops at -6dB (half the level which is not much drop) per octave.

Hello there audioguru,


Well, part of the lesson here is not to rely on ready made formulas when analyzing a circuit, at least not yet in his studies. By dishing out the formula it's like trying to teach an elementary student math by handing him a calculator and they dont get the idea how this came about. A question that comes up is when we are able to use that formula and when not. The answer is in the details of the circuit analysis which beckons the math behind it. Only then will the student be prepared for any circuit not just a few simple ones. We could also refer to another website with ready made calculators which will calculate the cutoff frequency, mid band gain, poles, etc., etc., but that wont teach us how to proceed with the more complicated circuit that cant easily be found on the web.
 
Thanks a lot MrAl,
As you said, in order to understand the function and application of a formula, we need to understand how it was created. This also helps us decide when we can use it and when we need something more or less complex. I am new to these things and I really appreciated your implementation of the internal gain of the op amp into the formulas as I had not really been sure how it was generally used. Also seeing just formula when you do not know how to use it is not very helpful, but with your walk-through it all makes more sense now. Thanks again.
 
Hi Jacob,

You're welcome :)

And once you get to know how to work the general case you will find those shortcuts handy. But another caution is sometimes web sites dont show the correct formula either so it's good to know how to double check their formulas before you go and use them for something. I've found many mistakes on the web in the past even with authors how know a real lot about circuits and have much experience. Typo's play a big part of this unfortunately. All it takes is one bad resistor name like R3 instead of R4 and the whole formula is moot.

One thing i meant to ask you that i never got around to was what kind of math background you already have. Such as algebra, trig, matrix math, calculus, etc. I know you already had complex math :)

Next we can do the cutoff frequency, and then later maybe apply all this to a much more complicated circuit.
 
Last edited:
Hi MrAl

The math background: I am familiar with algebra, one of my favorites also trigonometric functions as well as Euclid, sine rule and cos rule, etc, I had matrices as well, but mostly just to make simultaneous equations easier, I also had differentiation and integration. Next week I start with numerical analysis. ATM I am at uni- first year studying computer science. And like you said, I also know complex numbers to certain point.
 
Hi again,

Ok that sounds good. Matrixes come in handy for these circuits sometimes when we have to use nodal analysis. Trig is God's mathematical gift to mankind :)
 
Hi MrAl

I am struggling a bit with a phase plot of the low pass filter described above. My transfer function is Vo = -15/ sqrt(w^2 * 2.25 * 10^-8 +1). I know that my cut-off frequency is 1064Hz. How do I make the phase plot? I read that when the sign is negative, phase offset is 180° but I am not sure what that "phase offset" means. I had a look at threads with bode plots, but that didn't help.
Thanks in advance
 
Hi again,

There is also a general approach to finding the phase of the circuit that relies on the real parts and imaginary parts again.

The phase shift in radians is:
Theta=atan2(I,R)

where I is the imaginary part of the whole expression for Vout (which means a little work to isolate the real and imag parts is required) and R is the real part of the whole expression. But luckily there is a somewhat simpler method too knowing the real and imag parts of the numerator and denominator again which is the same as we knew for obtaining the transfer function:
Theta=atan2(IN,RN)-atan2(ID,RD)

where
IN is the imag part in the numerator,
RN is the real part in the numerator,
ID is the imag part in the denominator,
RD is the real part in the denominator.

So once we know those four parts we can find both the amplitude and the phase shift without too much extra work.

Oh and yes, a minus sign can indicate a 180 degree phase shift. So if we have two responses (random responses for illustration):
Vout1=1/(2*w^2+3*w+1)
and
Vout2=-1/(2*w^2+3*w+1)

then Vout2 is phase shifted from Vout1 by 180 degrees.


BTW the atan2(y,x) function is the two argument atan function. It requires two arguments and returns an angle in radians. The thing to remember is that the first argument is the ordinate and the second argument is the abscissa. This is in reverse to how most functions work. For example, we usually specify a point as (x,y) but this is the opposite where we have the 'y' come first. Doing it backwards will usually result in the wrong answer.
If you've never seen atan2(y,x) before it would pay to check out the wikipedia article on that function. It resolves into atan() or a constant or atan() plus or minus a constant depending on what the y and x values actually are, except for the combination atan2(0,0) which is undefined.
 
Last edited:
just want to check, should this phase plot start at -90° and end in -180°? I used formula (theta with different frequency inputs) and put different frequencies to it in Excel and made a graph out of it. The first value turned out to be 90°, but as it is inverting, I shifted it by 180°. Did I do it the right way? Thanks
 
Hi again,

It looks like the phase plot should start out at 180 degrees and then decrease, but what values are you using now for R1, R2, and C2? I'll go over it to make sure with your values, but interestingly i think with any reasonable choice of R's and C i think we start at 180 degrees. This is intuitive too because at zero frequency the cap is an open circuit so we just have the output amplitude of Vout=-Vin*R2/R1 which is always 180 degrees (this is the DC response or very near zero frequency response). So for a frequency of 0.001Hz we'll see a phase shift of 180 degrees.

Oh yeah i meant to mention that a good way to check your results is with a circuit simulator. These are free tools available for download with no strings attached and are invaluable for checking your work. If you calculate 90 degrees and you get 180 degrees in the simulation, you know right away that something is wrong somewhere...either correct your work or correct your simulation and dont quit until both are equal.
A lot of people like LT Spice and because we can share it's files here just like any other files we could do simulations to back up our work.
Everybody calls it LT Spice, but i think the official name is SwitcherCad III now. It's not hard to learn and it is completely free and comes with a ton of circuit models.
 
Hi,
R1= 1k, R2=15k, C2 = 10nF
I any case I have LT Spice installed in my laptop, but I haven't tried filters there yet. I might have made a mistake somewhere. I got Theta = =ATAN2(0.00015* 2*PI *f, 1)*180/PI()-180.
 
Hello again,

Something doesnt look right. If you dont get pi (which is pi*180/pi=180 degrees) then something is still wrong. Did you remember to make Z2/Z1 negative?

Here's what i get for the transfer function:
-R2/(j*w*R1*R2*C2+R1))

and so we have:
RN=-R2
IN=0
RD=R1
ID=w*R1*R2*C2

so we get as phase shift:
Theta=atan2(0,-R2)-atan2(w*R1*R2*C2,R1)

where we can note that the first part of this always equals pi when R2 is a positive valued resistor, so we have:
Theta=pi-atan2(w*R1*R2*C2,R1)

and the second part evaluates to atan(w*R2*C2) so we get:
Theta=pi-atan(w*R2*C2)

and with w=0 we would get:
Theta=pi
 
Hi MrAl,
Stupid me... I put "15" instead of "-15" for the first atan2, so I got 0 for that one instead of PI (Also for some reason I got -PI/2 in Excel for ATAN(0,-15), so I just rewroted that to PI :D. At least I know now to be careful not to do again :-D.
Thanks a lot.I doubt I would noticed that even if I checked again :D.
 
Last edited:
Hi jacob and MrAl,

only now I had the chance to read this thread.
May I add some comments?

I appreciate the aim of MrAl using a circuit analysis which is based really on basics (Kirchhoff laws and finite opamp gain).
However, what you are doing if the circuit is somewhat (just somewhat!) more complicated?
Do you intend to start again from zero using Kirchhoffs law? I am afraid, this could be a rather frustrating task (solving a set of 4,5 or 6 equations)

For my opinion, it is a better way - and much, much more easy - for all similar circuit arrangements (with a feedback loop) to start with Black`s famous formula that is applicable to all feedback circuits:

Vout/Vin=Hf*Ao/1+Hr*Ao

with Hf=Forward transfer function (setting Vout=0) and Hr=Return transfer function (setting Vin=0).

Present example (1st order lowpass): Hf=R2||sC2/(R1+R2||sC2) and Hr=R1/(R1+R2||sC2) .

Comments from all sides are welcome.
W.

Remarks:

1.) This calculation method can be uesed also for circuits with negative AND positive feedback (e.g. active filter circuits).
2.) For my opinion, using calculations based on FINITE opamp gain Ao makes sense only if this parameter Ao is kept until the end of the calculation (final gain expression).
In this case, its influence on this expression can be seen and evaluated. In case Ao is considered to be very large (infinite) it is much more simple to use this simplification from the beginning (instead somewhere in the middle of the calculation); such a simplification results in less and simpler formulas.
 
Last edited:
Hi Winterstone

Nice trick, I never see this method. But what about non inverting amplifier? How can we apply this method?
 

Attachments

  • aa.PNG
    aa.PNG
    15.7 KB · Views: 294
Hi Jony - I wouldn`t consider this method as a "trick".
Rather, it is a method which is based on a simple feedback model.
The principle is to split the whole calculation in two resp. three steps, which are combined at the end using Black`s feedback formula.

Your Example (R3 has no influence on gain if the input signal is an ideal voltage source):

* Hf=Vd/Vin=1 with Vd=(V+) - (V-).
For Vout=0 we have V-=0 and V+=Vin. Thus Vd/Vin=V+/Vin=1

* Hr=Vd/Vout (with Vin=0).
Thus, Hr=R2/(R2+R1||sC1)

* Result for Ao=infinite (known from each textbook):

H(s)=Hf/Hr=1/Hr=1+(R1||sC1)/R2.

* For Ao finite use the formula
H(s)=Hf/(1/Ao + Hr)

Correction::
Thanks to "The electrician".
Please replace all expression "sC" by "1/sC".
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top