Optimization Problem with an RC BP filter

In summary, the engineer is trying to optimize a circuit for peak voltage at 10kHz and less than half peak voltage at 3k and 30k. They are limited to capacitors and resistors, and the circuit they are using is attached. They end up with a summary of the circuit and its limitations.
  • #1
BiGyElLoWhAt
Gold Member
1,622
131
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.
 

Attachments

  • Circuit.png
    Circuit.png
    8.2 KB · Views: 451
Engineering news on Phys.org
  • #2
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.
 
  • Like
Likes BiGyElLoWhAt
  • #3
BiGyElLoWhAt said:
I am assigned to design a circuit that peaks voltage at 10kHz and is less than half peak voltage at 3k and 30k.
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.
 
  • Like
Likes BiGyElLoWhAt
  • #4
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.
 
  • Like
Likes BvU and BiGyElLoWhAt
  • #5
Aaron Crowl said:
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.
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:
  • #6
andrewkirk said:
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.

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
NascentOxygen said:
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.
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
Aaron Crowl said:
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.
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
BiGyElLoWhAt said:
I actually thought of this late last night, but was wondering if it was reasonable to treat it as such.

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:
  • Like
Likes BiGyElLoWhAt
  • #11
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
BiGyElLoWhAt said:
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).
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
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
BiGyElLoWhAt said:
Perhaps optimization wasn't the best term to use,
Maybe the word is customize?
 
  • Like
Likes BiGyElLoWhAt
  • #15
Perhaps, I'm not sure what you would call it, honestly. Optimization was the best I could come up with at the time.
 
  • #16
As far as approximations go, how about this:
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
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?
 
  • Like
Likes BiGyElLoWhAt
  • #18
Yes.
So 4 equations, 4 unknowns. Am I understanding you correctly?
Also, thanks for the help.
 
  • #19
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
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:
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

#capacitances expressed in picofarads (10^-12)
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
}
 
  • Like
Likes BiGyElLoWhAt
  • #21
Well, you loop through r2 twice and never r1. I doubt that would make much of a difference, though. Maybe, but I doubt it.
However, upon further inspection, it seems as though my function IS approximately proportional to 1/w... Which would imply it does decrease with omega. Let me go through and check my algebra.
I'm also not quite sure exactly what your haspeak is doing. I would guess it's checking for the peak, but this is the first time I've heard of R.
 
  • #22
BiGyElLoWhAt said:
Well, you loop through r2 twice and never r1.
Oops! That's pretty good to pick that up in a language you don't use. As you might imagine that was a case of copying code and then failing to change it everywhere that it needed to be changed.

I fixed that - so the nested loops are now:
Code:
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_1<-R1[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
}
I then re-ran it and - sad face - it still doesn't find any cases where there is a peak.

My function haspeak tests whether the vector 'vec' given as argument has a peak.
Code:
!(which.max(vec) %in% c(1,length(vec)))
The function which.max returns the index of the maximum vector element. The exclamation mark is a negation operator, and c(1,length(vec)) is an ordered pair of numbers of which the first is 1 (index of the first element in the vec) and the second is the index of the last element in the vec.

So the function returns TRUE iff the maximum occurs at a position other than the first or last place in the vector.
 
  • #23
Just consider the network as two voltage dividers that are divide-by-two. That should give you a broad peak around 9.5 to 10kHz. Tweak values as needed.

Make Xc1 equal R1 at the low frequency,
and Make Xc2 equal R2 at the high frequency.
Xc2 and R2 should be 10 times Xc1 and R1.
 
  • Like
Likes BiGyElLoWhAt
  • #24
Ok, so I found a few things:
I had 4 (!) sign errors throughout. 1 ends up essentially disappearing when you multiply by the complex conjugate, 1*1 = -1*-1.
The other 3 we a result of my forgetting to multiply i*i.

However the biggest thing, I think, Is that this is the equation for the total current, and not the current through the second branch. I said that in OP, but it didn't even occur to me until just now upon reevaluating my algebra. Double sad face.

If you'd be willing to run a new equation through your code, I will (I'll have to regardless) go through and get I2 and then V_2, and the n post back.
 
  • #25
Is this a homework problem? Where did you get that huge expression in post #1? Did you derive it yourself? Shouldn't it be Vout/Vin rather than Io/Vin?

This circuit you're using has only 2 capacitors, so it's a second order network. Its transfer function can't have ω raised to the 4th power.

Using the circuit you have (2nd order) you won't be able to get a half amplitude output at 3 kHz and 30 kHz. Using R1 = 1000Ω, C1 = .0165 μF, R2 = R1*20 and C2 = C1/20, here's the response you get:

PBP1.png


You'll notice that the amplitude is not less than 1/2 the peak at 3 kHz and 30 kHz. You won't be able to do better than that with two resistors and two capacitors.

Can you think of something relatively easy to do that would give you a faster cutoff rate?
 
  • #26
BiGyElLoWhAt said:
If you'd be willing to run a new equation through your code
Sure I can do that. It sounds like there may be a much easier way, based on @The Electrician's post so I think it's best to work on that first. My knowledge of RC circuits isn't enough to understand where that curve comes from, but if you end up with a complex expression that needs optimising, I can easily plug that into the code and re-run.
 
  • #27
Well, my transfer is 2nd order before I multiply by the complex conjugate. Then it becomes O(2)xO(2)= O(4)
 
  • #28
Try plugging in the values for R1, R2, C1, C2 I gave and see what you get.

Is this homework? If not, what is your overall goal?
 
  • #29
Also, with capacitors and resistors only, I'm not sure what you mean by something else, unless you mean more stages.
 
  • #30
It's "homework". I have to design it then build it but I'm not exactly sure what it's for other than exercise. I think the professor called it mini project or something. Do you mean plug them into the equation I got?
 
  • #31
Yes; plug them into your equation.

Actually, it might be helpful if you describe how you got that expression.

Do you know how to express impedances of capacitors using the Laplace "s" variable?

Did your professor tell you that you needed to use some sort of optimization procedure?

Here's the important hint; the "something else" is to cascade two circuits like you are using now. In other words, use 4 resistors and 4 capacitors.
 
  • Like
Likes donpacino
  • #32
It looks like you are taking a very analytical and overly complicated approach to solving this problem. Using optimization and variance is overkill for this type of problem. your making it hard on yourself. The architecture of the circuit is what really sets the gain values. solving this comes down to solving 2 equations.

just a hint. When doing frequency analysis it will often help to use the s operator from laplace. if you recall s=jw.

when analyzing the circuit, the transfer function is found seen below

Vo/Vin = [SC_2R_2 ] / [ S^2C_2^2R_2_2+S(2C_2R_2+C1R1)+1 ]

Now let's get to the best way of solving. do you recall what poles and zeros are? very simply a pole will cause the gain to decrease 10 dB per decade as frequency increase. a zero will cause the gain to increase 10 dB per decade as frequency increases.

this is a bandpass circuit given your requirements. There is one zero, so C2 and R2 will set your zero. This zero will control the rising part of the circuit. remember that it is a zero at the origin. because we don't have a voltage requirement for 3khz (other than half of 10 khz) the value of c2 and r2 don't actually matter (relative to the zero that is).

you need a 2x magnitude difference between the 3k and 10k points (about 6 dB). the same goes for 10k to 30k.

if you look at the poles we have a second order response (2 poles). We want to put these 2 poles at 10 khz to ensure the voltage peaks there. so the poles will be at

10+xj and 10-xj. with x being some number. normally this value matters, but in our case it doesn't matter at all

our pole equation is S^2C_2^2R_2_2+S(2C_2R_2+C1R1)+1. let's use the quadratic equation to solve for S=10
A=C_2^2R_2_2
B=2C_2R_2+C1R1
C=1

then, use the quadratic equation to solve for 10. You case use optimization methods, but remember you have 4 unknowns and less equations (2). This means you can simply set the values of the components to static values. I would set the capacitors to 10uf. This is a very common value. If you need to increase or decrease the capacitance. Keep in mind capacitors are usually harder to find specific values than resistors, so typically set the caps and vary the resistors. Then solve for the 2 resistors values (I'll let you figure that out).

let me know if you don't understand poles and zeros, and I can go into more detail. also keep in mind what the electrician said about the feasibility of this circuit. what i put down is just to get you started down an easier path to solve the problem
 
  • #33
wait. what is your actual assignment. Were you given that circuit, or were you given the task the meet the requirements, and you chose that circuit?

There are better topologys to solve this problem. Like the electrician stated you need to figure out what order filter you need.
 
  • #34
I chose this circuit to meet the requirements. So add in more stages to smooth the required points?
donpacino said:
Vo/Vin = [SC_2R_2 ] / [ S^2C_2^2R_2_2+S(2C_2R_2+C1R1)+1 ]
I don't see how you got this. Even so, you have a complex denominator, and I've never seen it left that way. Shouldn't you multiply by [s^2 C_2^2R_2^2 + 1 - s(2C_2R_2 +c_1R1)] / [s^2 C_2^2R_2^2 + 1 - s(2C_2R_2 +c_1R1)] to make the denominator real?

It's a fairly independent project, so we were given the requirements and left to choose a circuit ourselves.

As for how I arrived at the transfer function I have:
##I_0 =\frac{V_{in}}{R_1 + \frac{1}{\frac{1}{z_1}+\frac{1}{z_2 + R_2}}}## and algebra.
The step before subbing in z's you end up with
##\frac{V_{in}(z_1 +z_2 + R_2)}{R_1(z_1+z_2+R_2)+z_1(z_2+R_2)}##
I've seen S used, but I always just end up subbing in z_1 = 1/iwc_1 once I get to an appropriate form to do so.
 
  • #35
Your image in post #1 of the circuit you're analyzing doesn't show Io, so I can't comment about the correctness of your expression:

##I_0 =\frac{V_{in}}{R_1 + \frac{1}{\frac{1}{z_1}+\frac{1}{z_2 + R_2}}}##

Is Io the current in R2? If it is, then your expression is incorrect.

If you will show the step by step procedure you used to get it I can help you find your error.

Once you have a correct transfer function, how will you verify that it meets your problem requirements? I suppose you would evaluate the transfer function at 3 kHz, 10 kHz and 30 kHz. Do you know how to produce a plot of the transfer function vs. frequency?
 

Similar threads

Replies
2
Views
1K
Replies
1
Views
686
  • Introductory Physics Homework Help
Replies
4
Views
218
  • Introductory Physics Homework Help
Replies
1
Views
271
  • Electrical Engineering
Replies
2
Views
1K
Replies
8
Views
2K
  • Electrical Engineering
Replies
3
Views
826
  • Engineering and Comp Sci Homework Help
Replies
6
Views
910
  • Introductory Physics Homework Help
Replies
8
Views
278
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
Back
Top