RC Filter Analysis

Started by bonaventura, June 13, 2012, 09:56:21 AM

Previous topic - Next topic

bonaventura

i have a spitfire on my breadboard and am thinking about tinkering with the tone circuit. so i went alot of posts and web pages abt RC filters but i cant seem to find how to even begin to analyze a rather complex RC filter.

take for example the blues driver :
www.diystompboxes.com/smfforum/index.php?topic=97256.0

could anyone give an example how would one analyze how the interstage filter and/or tone circuit work?

evidently im not educated in electrical engineering,so if its too complex dont hesitate to tell me, i wont mind  :)

much appreciate yr input.


bonaventura

Quote from: artifus on June 13, 2012, 10:02:05 AM
http://www.duncanamps.com/tsc/

yes i came across that.unfortunately the laptop is busted and my handheld is android so at the mom i cant use that  :icon_frown:

Seljer

Do you know how to do math with complex numbers?

bonaventura

Quote from: Seljer on June 13, 2012, 10:24:56 AM
Do you know how to do math with complex numbers?

rusty but willing learn

WGTP

It would be pretty tuff manually.  I have messed with the Spitfire and suggest you try a 100k trim pot in place of the 100k resistor in the tonestack.  Also, try various size caps above and below the stock ones.  In the end, you going to have to decide which sounds the best to you, even though seeing graphs of it is cool.

A version I like is 3.3n, 22k, 22n.  I has a 10db notch.  5.6n, 22k 15n only has a 3 db notch.  Both around 600Hz.  ;)
Stomping Out Sparks & Flames

sault

Quote from: Seljer on June 13, 2012, 10:24:56 AM
Do you know how to do math with complex numbers?

If you know how to do the math, I'll build a web app. Seriously. I've been wanting to build a web version of the TSC for at least a year, but lack the math to do it right. I've been studying the theory, but it's been slow going - I'm only now starting AC analysis.

Saul t

bonaventura

Quote from: WGTP on June 14, 2012, 01:37:36 PM
It would be pretty tuff manually.  I have messed with the Spitfire and suggest you try a 100k trim pot in place of the 100k resistor in the tonestack.  Also, try various size caps above and below the stock ones.  In the end, you going to have to decide which sounds the best to you, even though seeing graphs of it is cool.

Saw your contribution to the spitty post and have tried your SRPP mods but not the filter sections yet.

I have tried various caps and Rs, so many many times that i eventually found myself losing focus to what i was doing because it was like stabbing in the dark to me. there has got to be a better (read: more intelligent) way to do this.

Quote from: WGTP on June 14, 2012, 01:37:36 PM
A version I like is 3.3n, 22k, 22n.  I has a 10db notch.  5.6n, 22k 15n only has a 3 db notch.  Both around 600Hz.  ;)

i'll try this one too then :D btw how did you come up with the frequency and cut for those values?

WGTP

#8
I use the Duncan Tonestack and also LT Spice.  With the Duncan Tonestack, the Spitfite tone control is like the Big Muff Pie with R2 set to infinity or 100M, effectively removing it from the circuit.  I have messed with it enough to have a general idea what the values will do and how they will sound on the breadboard.  Great fun.  ;)

2n 33k 22n = -14db @ 600Hz
3n 22k 22n = -10db
4n 15k 22n = -7db
5n 13k 22n = -5db
6n 11k 22n = -4db

For deeper notch replace 22n with 47n
For less notch replace 22n with 10n

Stomping Out Sparks & Flames

bonaventura

man,i really need to get the laptop fixed...

artifus


bonaventura

yes it does.

but still,only common configurations are available and not as complex as the ones i mentioned earlier.

they seem very arbitrary to my inexperienced eyes.

Seljer

Alright, let me give this a shot. Huge post ahead and I've got no idea if anyone will benefit from it.

Circuit analysis for AC circuits is basically the same as for DC circuits (that is, circuits with just voltage/current sources and resistors), the same methods apply: series/parallel combinations, nodal anaylsis, and loop analysis.

Just instead of resistance/conductance each component has impedance/admittance which is a complex ratio between the voltage and current over that component.

The impedance of an inductor is Z_L = j * w * L
where j is the imaginary unit (which in math is usually denoted with i but in electronic ciruits j is used so it's not mixed up with current) and w (the small greek letter omega) is angular frequency.

The relation between angular frequency and ordinary frequency is: w = 2*pi*f

The admitattance of a capacitor is Y_C = j*w*C
The impedance of a capacitor is the inverse value of the admittance so Z_C = 1/(j*w*C) = -j/(w*C) . Heres the first example of some imaginary number math happening, if you multiply both the numerator and denomertor with j you get j on the top, and j^2 on the bottom, and j^2 = -1 hence the minus.
Because the frequency is in the denominator, as frequency rises the impedance of the capacitor is lower for higher frequencies.



So looking at that tone control in the circuit you linked. For a simpler circuit, I first took myself the liberty of combining R1 and C1, which are hooked up in parallel, thus for the equivelent value their admittances are summed together (and impedance is the inverse value of admittance).
I was then left with a circuit with two "loops" so I decided the the loop analysis method would probably be quickest, any method would however work....its just thats its a pain to do this by hand.

Around each loop you write out of Kirchoff's voltage law and you get a system of equations to solve. Excuse me for not writing what I'm exactly doing in each step but...its basically just solving the system of equations (combining things and moving them from one side to the other).

Loop 1: V1 =  i1*1/(1/R1+j*w*C1) + (i1-i2)*1/(j*w*C2)
Loop 2: 0 = (i2-i1)*1/(j*w*C2)+i2*(1/(j*w*C3)+R2+1/(j*w*C4))

Vin =  i1*(R1/(1+j*w*C1*R1) - j/(w*C2)) + i2*j/(w*C2)
0 = i1*j/(w*C2) - i2*j/(w*C2) + i2*(-j/(w*C3) + R2 + -j/(w*C4))

Vin =  i1*(R1/(1+j*w*C1*R1) - j/(w*C2)) + i2*j/(w*C2)
- i1*j/(w*C2) =  i2*(R2 - j/(w*C3) + -j/(w*C4) - j/(w*C2))

Vin =  i1*(R1/(1+j*w*C1*R1) - j/(w*C2)) + i2*j/(w*C2)
i1 =  i2*(w*C2)*(j*R2 + 1/(w*C3) + 1/(w*C4) + 1/(w*C2))
i1 =  i2*(j*w*C2*R2 + C2/C3 + C2/C4 + 1)

Vin =  i2*(j*w*C2*R2 + C2/C3 + C2/C4 + 1)*(R1/(1+j*w*C1*R1) - j/(w*C2)) + i2*j/(w*C2)

Vin =  i2*((j*w*C2*R2 + C2/C3 + C2/C4 + 1)*(R1/(1+j*w*C1*R1) - j/(w*C2)) + j/(w*C2))

i2 = Vin/((j*w*C2*R2 + C2/C3 + C2/C4 + 1)*(R1/(1+j*w*C1*R1) - j/(w*C2)) + j/(w*C2))

And since we know current i2, we can write the output voltage as the voltage drop over C4 (and R2 depending on what the tone control is set to).

Vout1 = i2*-j/(w*C4)
Vout2 = i2*(-j/(w*C4)+R2)

Vout1 = Vin/((j*w*C2*R2 + C2/C3 + C2/C4 + 1)*(R1/(1+j*w*C1*R1) - j/(w*C2)) + j/(w*C2))*-j/(w*C4)
Vout2 = Vin/((j*w*C2*R2 + C2/C3 + C2/C4 + 1)*(R1/(1+j*w*C1*R1) - j/(w*C2)) + j/(w*C2))*(-j/(w*C4)+R2)

And from here you can move Vin into the denominator on the left side and get complex ration between the output and input voltages.

F1 = -j/(w*C4)/((j*w*C2*R2 + C2/C3 + C2/C4 + 1)*(R1/(1+j*w*C1*R1) - j/(w*C2)) + j/(w*C2))
F2 = (-j/(w*C4)+R2)/((j*w*C2*R2 + C2/C3 + C2/C4 + 1)*(R1/(1+j*w*C1*R1) - j/(w*C2)) + j/(w*C2))

And from here on I can't be bothered at all to do this by hand, because it's just too complicated, there are ways to identify types of filters and such out of this equation but I presently can't remember them. But basically, the easiest approach is to enter the numbers at each frequency you're interested in and get the end result. The absolute value of this number (sqrt(real component^2 + imaginary component^2)), is the signal amplitude ratio, the argument is the phase shift.

This is why computers are great, you can easily compute it and just graph the thing and see what the hell is going on

So heres some MATLAB code to draw the frequency response of the tone control (also applicable to the open source GNU Octave program :) )

C1 = 10e-9
R1=5.6e3
C2=10e-9
C3 = 82e-9
R2= 10e3
C4 = 18e-9


w= linspace(2*pi*70,2*pi*15e3,100); %frequency goes from 70hz to 15khz

F1 = -j./(w*C4)./((j*w*C2*R2 + C2/C3 + C2/C4 + 1).*(R1./(1+j*w*C1*R1) - j./(w*C2)) + j./(w*C2));
F2 = (-j./(w*C4)+R2)./((j*w*C2*R2 + C2/C3 + C2/C4 + 1).*(R1./(1+j*w*C1*R1) - j./(w*C2)) + j./(w*C2));

%lets draw this thing
grid on
ylabel('Amplitude ration [dBV]')
xlabel('Frequency [Hz]')
semilogx(w/2/pi,20*log10(abs(F1)),w/2/pi,20*log10(abs(F2)))


Heres a nifty online Octave terminal: http://lavica.fesb.hr/octave/octave-on-line_en.php copy and paste it in and see what happens
Or just download the program itself http://octave.sourceforge.net/

And for comparison, heres the same tone control arrangment in LTSpice. The much much easier solution to messing around with these things :D



And another way to approach this is to break it down into sections:
C3 is much larger than everything else and basically functions as a DC decoupling capacitor, it doesn't have much of an influence so you can kind of pretend it's not there. If you make it lower you start losing the low end.

R1, C1 and C2, make a low pass filter, at high frequencies the ratio of C1:C2 overpowers R1 and you get a 50% voltage drop (-6dB), at low frequencies R1 has got a lower impedance than the capacitors thus the signal goes through uniterrupted. The math on this one is simple and you can figure out that the corner frequency of the stage on its own is about 2khz. This filter is basically the top end of the control, the blue line on the graph above.

The output of that filter is fed into another low pass filter, this time a simple first order low pass filter made just out of R2 and C2, the corner frequency is 1/(2*pi*R2*C2) = 880hz. This is more or less the green line on the graph above. With the wiper of the potentiometer moving across R2 you can get any blend of between these two ampilutude responses.

This method works fell enough to get an idea of whats going on, if you want hard numbers though there are issues, when hooking up another filter/impedance to the end of the previous one effects the response of it as well. For example, even in the mathematical analysis above, I didn't take into account the output impedance of the booster stage, and the input impedance of the 100kiloohm volume control (but assuming the output impedance of the previous is low enough and input impedance of the next stage is high enough this isn't so much of a problem).

bonaventura

wow,it IS long,thanks a bunch for the walkthru tips and software links.

pls allow some time for me to digest the math and try to apply the concept to the interstage filter.

one question,the second low pass,isnt it should be R2-C4 i/o R2-C2?

matlab is cool  :icon_mrgreen:. my final assignment was to develop an image processing software for a production line.the languange was easy enough to understand,i even put an easter egg somewhere.

ElectricDruid

Another +1 for using LTspice for stuff like this. I don't know how to do all the analysis, but I can build it in LTSpice and do the sim to see what the frequency response looks like. For tone controls, you can put variables in for the pot resistance and get it to plot several curves at various positions.

HTH,
Tom

defaced

Dumb question.  I absolutely sucked at this in college, so I am just trying to splice some broken wires together. 

Isn't the immigrant number math only necessary if you care about phase? Can't the rest be done by understanding the order of the filter (which gives you the shape of the curve) and figuring out the center point of the filter? 
-Mike

sault

Quote
Isn't the immigrant number math only necessary if you care about phase? Can't the rest be done by understanding the order of the filter (which gives you the shape of the curve) and figuring out the center point of the filter?

It's all important, because every time you see a capacitor or inductor the "slope" becomes more complex and can change. Phase is one part of the math, sure, but your overall impedance is affected by each cap and inductor in the circuit.

A good example : the FMV seems simple on one hand (three caps, a resistor, and three pots? sure!) but every pot affects the frequency response not just of itself, but the other two as well.  http://amps.zugster.net/articles/tone-stacks#FMV

Another example is using a gyrator. It simulates an inductor using an active filter with capacitors, but the math is not very straightforward - changing one value changes everything else. I actually wrote a bandpass gyrator calculator (that's been badly in need of prettier code) here : http://awasteofsalt.com/gyrator. Its a little primitive, but it shows you how the frequency response of a bandpass gyrator changes when you tweak with the four different components.

So yeah. For complex circuits, complex math is required to plot out the frequency response.

defaced

Thanks for the explanation.  I figured that was the answer.  
-Mike