Electrical – 2nd order Sallen-Key Bandpass filter design in Matlab

active-filterfilterMATLAB

I'm trying to design a Sallen-Key BPF within Matlab. With the documentation found on ti: http://www.ti.com/lit/ml/sloa088/sloa088.pdf, I studied and understood the basic.
enter image description here

As for the design: The center frequency of my BPF is 40kHz. Q-factor and gain at center frequency must be 1. So in matlab I've made:

Fm = 40000;
R1 = 10000
R2 = 10000
C = 10*10^-9

R = 1/(2*pi*Fm*C);

G = 1+(R2/R1);
Q = 1/(3-G);
Am = G/(3-G);

w = 2*pi*Fm;

B=[G*R*C*w 0 ]
A=[(R^2)*(C^2)*(w^2) R*C*w*(3-G) 1]
sys=tf(B,A)

bode(sys,opts);

The issue is that my resulting bodeplot is indeed showing a BPF behaviour, but not at the desired frequency. Furthermore.

Can someone explain this to me?
Thanks in advance

Best Answer

Your formulas do not take into account that the impedance of a capacitor is complex !

What you use is:

$$Zc(f) = 1 / 2 \pi f$$

but what you should use is:

$$Zc(s) = 1 / s$$

where $$s = 2 \pi f j $$ where j makes it imaginary remember: $$j^2 = -1$$

Have a look at this page on Wikipedia where they show how to determine the transfer function in the s domain.