0
\$\begingroup\$

I wrote up some code in MATLAB that's supposed to simulate the frequency response of a third order passive low pass Butterworth filter with a cutoff at 10kHz. The curve seems to match the results I got from my LTspice simulation, but the cutoff is off by a power of ten I think, with the 3dB point at around 1kHz.

Are there any suggestions on how to correct this? I've tried multiple different transfer functions, and I get the same result, so I think the issue may be with my input data and not the equation.

Attempt #1

f = 1:1:60000;
x = 2.*pi.*f;
R = 10000;
C = 1./(x.*0.000000003183);
L1 = 0.1592.*x;
L2 = 0.1592.*x;
num = R.*C;
denom = (C.*L1)+(L2.*L1)+(R.*L1)+(L2.*C)+(R.*C);
tran = num./denom;
semilogx(f,tran);
grid on;

Attempt #2

f = 1:1:60000;
x = 2.*pi.*f; %x is little s
wc = 2*pi*10000;
S = x./wc;
pt1 = S + 1;
pt2 = (S.^2) + S + 1;
tran = 1./(pt1.*pt2);
semilogx(f,tran);
grid on;

Attempt #3

f = 1:1:60000;
x = 2.*pi.*f;
wc = 2*pi*10000;
S = x./wc;
tran = 1./((S.^3)+(2.*(S.^2))+(2.*S)+1);
semilogx(f,tran);
grid on;

Edit 1: I probably should have mentioned that there's an input resistance for this filter, which might reduce the resonance that some people mentioned was occurring with my design. I was told that the aforementioned component could be removed from my MATLAB transfer function calculation with minimal impacts on the end result, and the script I wrote that included the resistor seems to have proved that assumption, as it still has the identical incorrect cutoff that the other simulations have. I've included the schematic and resulting response that I'm trying to graph out, if anyone has any advice on how to approach this properly, please let me know.

enter image description here

Edit 2: Looks like I got it working, I guess I was just too lazy to try and get the imaginary values set up in MATLAB, my bad. Thanks everyone!

\$\endgroup\$
2
  • \$\begingroup\$ I don't know Matlab either, but where are the complex numbers? \$\endgroup\$
    – Mattman944
    Dec 8, 2023 at 8:39
  • \$\begingroup\$ Tim, thanks for the added edit and the source resistance. That does make all the difference. It's now a Butterworth output starting from DC at about -6 dB, of course. \$\endgroup\$ Dec 9, 2023 at 0:33

2 Answers 2

2
\$\begingroup\$

Attempt #2 will work if you do the math properly. You need to use complex numbers.

\$ s = j\omega \$

I don't use Matlab. Excel is clumsy for this purpose, but it works.

enter image description here

With formulas shown: enter image description here

\$\endgroup\$
0
\$\begingroup\$

Thanks for the added notes. Without that added resistor, I was stuck. But including it makes all the difference.

Just by way of the short note I took to include your new changes (using freely available SymPy):

l1,l2,c1,r1,r2=symbols('l1,l2,c1,r1,r2',real=True,positive=True)
e1=Eq(v1*s*c1+v1/(s*l2+r2)+v1/s/l1,vin/(s*l2+r2)+vout/s/l1)
e2=Eq(vout/s/l1+vout/r1,v1/s/l1)
tr=solve([e1,e2],[v1,vout])[vout]/vin # 3rd order composed of 1st and 2nd order parts
rt=list(roots(fraction(tr)[1].subs({l1:.1592,l2:.1592,c1:3.1831e-9,r1:10e3,r2:10e3}),s))
dn=expand((s-rt[1])*(s-rt[2]))
-rt[0]
62814.0703517588                   # 1st order part: omega_0
tf2(1/dn)
{omega: 62822.9498509615,          # 2nd order part: omega_1
 zeta: 0.499929329176489}          # 2nd order part: zeta

So this is a Butterworth. (Very close to ideal.) The first order is at \$f_{_0}\approx 9.997\:\text{kHz}\$ and the second order is at \$f_{_1}\approx 9.999\:\text{kHz}\$. And rounded you have \$\zeta=0.500\$, which is exactly the right value. Really doesn't get better. (But then you were using some unusually precise inductors and capacitors, too.)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.