# Optimization Problem with an RC BP filter

Tags:
1. Sep 21, 2016

### BiGyElLoWhAt

I am assigned to design a circuit that peaks voltage at 10kHz and is less than half peak voltage at 3k and 30k. Only capacitors and resistors are allowed. The circuit I'm using is attached. I end up with

$I_0 = [\frac{-R_2\omega^2C_1C_2 + [C_1+C_2]R_1R_2\omega^3C_1C_2 - R_1\omega^2[C_1+C_2]^2 - R_2\omega^2C_2[C_1+C_2]}{(R_1R_2\omega^2C_1C_2-R_1\omega[C_1+C_2]-R_2C_2\omega)^2 +1} + \frac{-R_1R_2^2\omega^4C_1^2C_2^2 + R_1R_2\omega^3C_1C_2[C_1+C_2] +R_2^2\omega^3C_1C_2^2 + [C_1+C_2]\omega}{(R_1R_2\omega^2C_1C_2-R_1\omega[C_1+C_2]-R_2C_2\omega)^2 +1}i] V_{in}$
Which I just realized I have I naught and not I2 (running through R2), so I need to fix that.
I'm assuming there are some tricks to picking values to accomplish this? We're staying in the peco-micro range for caps and <1M for resistors, just for accessibility.

If I make a spreadsheet trying to capture all the variance, it's too huge. I'm already out to DZ and only have r1 + w, and r2 + w variance.

I don't think I'll even be able to solve for $\frac{d}{d\omega} \text{Transfer} = 0$
Since the resistors don't seem to change much of the frequency response (I assumed they might have to do with the width of the peak, as in an RLC Q-factor), I should be able to simplify a little, but I think the key will be in my capacitance ratios.
Thanks.

#### Attached Files:

• ###### Circuit.png
File size:
12.6 KB
Views:
112
2. Sep 22, 2016

### andrewkirk

Spreadsheets are lousy for optimisation. You're much better off using a more versatile tool like R, Matlab or Mathematica. They can do in a few lines of code what a spreadsheet might require hundreds of columns and many MB of spreadsheet size to accomplish, and they'll do it more quickly and intuitively too.

It looks like you have at most four variables, so the optimisation should be quite tractable.

Have you performed dimensional analysis on your formula? I'm not that familiar with electrical formulas but it looks to me like the terms in the numerator do not all have the same units, and the same goes for the denominator. If that's right then the formula may not be correct.

3. Sep 22, 2016

### Staff: Mentor

Optimization can mean different things to different people, it depends upon what you are trying to optimize (or maximize or minimize). What do you mean by "optimization" here?

For a 2-stage passive filter it is often that we desire the highest Q, and this is achieved by having the second stage impose least feasible loading on the first RC stage. So you might try and make the impedance of C2 and R2 of the order of 10 or more times the impedance of R1 and C1.

4. Sep 22, 2016

### Aaron Crowl

The first stage is a low-pass filter and the second stage is a high pass filter. How do you think they would behave if they were separate? Hint 1: C1 is going to be larger than C2. Hint 2: C1 is going to behave somewhat like an open until you get close to the high frequency cutoff and C2 is going to behave somewhat like a short when you are well above the low frequency cutoff. Approximations are OK for getting starting values.

5. Sep 22, 2016

### BiGyElLoWhAt

I actually thought of this late last night, but was wondering if it was reasonable to treat it as such. The approximation part was what bothered me slightly. So pick my RC values in my first circuit so that I have it about 100% at 10kHz, and the same with the second? What about the diminishing effects? Do I set 30k = 50%*@10k on my hipass and same with lowpass? My hipass should have negligible effects on low frequencies, and vice versa, so that would be a good approximation, I think.

Last edited: Sep 22, 2016
6. Sep 22, 2016

### BiGyElLoWhAt

I tried using wolfram, and I'm not sure if I entered it correctly, but it didn't "understand my query". They do have the same units. The numerator terms all have ohm^-1 and denominator is unitless (1/wc has units of ohm, so wc is ohm^-1). That's how I caught mistakes on my first 3 attempts at the analysis haha.

When I tried an approximate maximization, by setting the denominator = zero, I got something to the effect of root(abcd + 4iab) with i root(-1) which doesn't seem to make sense to me.

7. Sep 22, 2016

### BiGyElLoWhAt

Perhaps optimization wasn't the best term to use, but I stated that I needed to make it peak at 10kHz and have a q factor such that it was less than 50% voltage at 3k and 30k.

8. Sep 22, 2016

### Staff: Mentor

It is not obvious to me why C1, as you say, is going to be larger than C2. Can you give a hint why this should be so?

9. Sep 22, 2016

### Aaron Crowl

Sure it's reasonable. C1 is part of a low-pass so it's going to have a really high impedance at lower frequencies because C1 dominates the voltage divider until you get to the cut-off frequency. Approximate it as an open circuit and analyze what is left at the turn-on frequency of the second stage (3kHz). We're justified in doing this by the fact that the parallel equivalent of an extremely high impedance in parallel with a low impedance branch will be approx equal to that low impedance branch.

$$lim_{X_{1}→∞}X_{1}||X_{2}=lim_{X_{1}→∞}\frac{X_{1}X_{2}}{X_{1}+X_{2}}=X_{2}$$

The impedance of C1 should not become significantly low until you get near 30kHz. Try it, take C1 out of the circuit and analyze it with only R1,R2, and C2 at 3kHz.

Also consider the limit of this addition $lim_{X_{2}→0}X_{2} + R_{2}=R_{2}$. The value of C2 won't be significant compared to R2 at the high frequency cutoff (30kHz). It could be approximated as a short.

you could say that the low-freq cutoff is a strong function of C2 and the high-freq cutoff is a strong function of C1.

Edit: The first approximation requires that the impedance of C1 is much greater than the impedance of (R2+C2) at 3kHz. Keep that in mind when you select resistance values.

Last edited: Sep 22, 2016
10. Sep 22, 2016

### Svein

11. Sep 22, 2016

### BiGyElLoWhAt

I never realized you can't actually maximize an RC circuit. You can, however, set the values equal to the appropriate ratio and solve for the relationship. So I know that
$\omega = \frac{\sqrt{3}}{R_1C_1}$ gives me Vout~ 1/2 Vin at 30k and that $\omega = \frac{\sqrt{3}}{3R_2C_2}$ for 3k, but when I equate the two to find the frequency that they are both at unity, I get a mess.
$(R_2\omega C_2)^2 = \frac{1 +R_2^2\omega^2C_2^2}{1+R_1^2\omega^2C_1^2}$

12. Sep 22, 2016

### andrewkirk

I make out the first term in the numerator $$R_2\omega^2C_1C_2$$ to have units of $\Omega^3$, and the second term, which is
$$[C_1+C_2]R_1R_2\omega^3C_1C_2$$ to have units of $\Omega^5$.

13. Sep 23, 2016

### BiGyElLoWhAt

R is ohms, wc is per ohm. that term is ohms* ohms^-2
the second is as well. 1/wc = ohm
wc = 1/ohm

14. Sep 23, 2016

### Staff: Mentor

Maybe the word is customize?

15. Sep 23, 2016

### BiGyElLoWhAt

Perhaps, I'm not sure what you would call it, honestly. Optimization was the best I could come up with at the time.

16. Sep 23, 2016

### BiGyElLoWhAt

Their maximum would be approximately when the magnitude of the phase angle of the high pass was equal to that of the low pass, that would give me the value that satisfies $R_1 \omega \C_1 = \frac{1}{R_2\omega C_2} \to \omega^2 = \frac{1}{R_1R_2C_1C_2}$ So then I think I will be able to set up a system of equations relating 2 variables in each. That might be useful if I can pick values. However, if impose another boundary condition, would that be sufficient to solve 5 equations 5 unknowns? Do I simply need another defined point on the graph?

17. Sep 23, 2016

### andrewkirk

As I understand it, you are trying to find values of $C_1,C_2,R_1,R_2$ such that, if we write the real part of the formula above as $F( C_1,C_2,R_1,R_2,\omega)$, then all the following are satisfied:
$$\frac \partial{\partial\omega}F( C_1,C_2,R_1,R_2,2\pi\times 10^4)=0$$
$$\frac {\partial^2}{\partial\omega^2}F( C_1,C_2,R_1,R_2,2\pi\times 10^4)<0$$
$$F( C_1,C_2,R_1,R_2,6\pi\times 10^3)<\frac12 F( C_1,C_2,R_1,R_2,2\pi\times 10^4)$$
$$F( C_1,C_2,R_1,R_2,60\pi\times 10^3)<\frac12 F( C_1,C_2,R_1,R_2,2\pi\times 10^4)$$

Is that correct?

18. Sep 23, 2016

### BiGyElLoWhAt

Yes.
So 4 equations, 4 unknowns. Am I understanding you correctly?
Also, thanks for the help.

19. Sep 23, 2016

### BiGyElLoWhAt

Any recommendations for a system of equation solver? I've exceeded the maximum number of characters in wolfram. I just can't type anymore.

20. Sep 23, 2016

### andrewkirk

Hmmm. I wrote a little R script, shown below, to try the formula out. It sampled each of the two resistances at twenty equidistant points over a range from $100\Omega$ to 1,000,100$\Omega$ and did the same for the two caps over a range from $100pf$ to 1,000,100$pf$ and for each combination of four variables calculated the value of the real part of the formula (output voltage?) for frequencies from 1kHz to 30kHz at intervals of 30Hz and tested that to see whether it had a peak - the alternative being that it is monotonic increasing or decreasing.

The result was that for none of the combinations tested was there a peak. I looked at a few sample curves and they were all monotonic decreasing, which is in line with my naive expectation that output voltage would decrease with frequency.

I could do wider search ranges or finer meshes, but it already takes 22 secs to run and with four variables, any significant widening or increased granularity of the search space could rapidly blow out the run time.

Is there something I'm missing here?

Here's the code
Code (Text):

voltom<-function(omega){
(-R_2*omega^2*C_1*C_2 + (C_1+C_2)*R_1*R_2*omega^3*C_1*C_2 - R_1*omega^2*(C_1+C_2)^2 - R_2*omega^2*C_2*(C_1+C_2)) /
((R_1*R_2*omega^2*C_1*C_2-R_1*omega*(C_1+C_2)-R_2*C_2*omega)^2 +1)
}

haspeak<-function(vec){
!(which.max(vec) %in% c(1,length(vec)))
}

omegalo<-1000
omegarange<-30000
omeganum<-1000
omega<-2*pi*(omegalo+(1:omeganum)*omegarange/omeganum)

num<-20

caplo<-100
caprange<-1000*1000
capnum<-num
C1<-C2<-(caplo+(1:capnum)*caprange/capnum)

resrange<-1000*1000
reslo<-100
resnum<-num
R1<-R2<-(reslo+(1:resnum)*resrange/resnum)

found<-FALSE
i<-1
while ((i <=capnum)&!found){
C_1<-C1[i]
j<-1
while ((j <=capnum)& !found){
C_2<-C2[j]
k<-1
while ((k <=capnum)& !found){
R_2<-R2[k]
l<-1
while ((l <=capnum)& !found){
R_2<-R2[l]
found<- haspeak(voltom(omega))
l<-l+1
}
k<-k+1
}
j<-j+1
}
i<-i+1
}