- Jan 9, 2006
3.2 Capacitor Circuits
In Chapter 1, we covered the physics and the mathematics behind capacitors for the most part. In a nutshell, they are two metal plates separated by an insulator (air, paper, etc.). Capacitors are measured as farads C, and the governing equations for capacitance is
Equation 3.1: Capacitance
- I = C*dv/dt
This formula states that the current I, measured in amps, flowing in a capacitor is equal to the capacitance C measured in farads times the rate change of voltage measured in volts per second. Figure 3.19 shows the schematic symbols used for capacitors and the current direction convention (+ to – is positive). Notice that some capacitors are polarized, others are bipolar or monolithic. Typically, polarized capacitors have much larger values than monolithic or bipolar types. Examples of polarized capacitors are
- Electrolytics—Usually very bulky, very large values for capacitance. Cheap, high leakage, poor temperature stability. Used mostly for power supply filtering and de-coupling. Low frequency applications.
- Tantalums—High values, more stable, low impedance, reasonable stability. Used for de-coupling and low to medium frequency applications. Very expensive.
There are also non-polarized or bipolar capacitors, the most common of which are ceramic or multilayer ceramic. These capacitors have good stability, are very high frequency, and have low leakage. They are good for de-coupling and general-purpose medium-to-high-speed capacitors.
Figure 3.19 Symbols/current conventions for charging and discharging along with modeling equations.
In most cases the capacitors you will use in any design will range from picofarads to microfarads. I have never seen a capacitor larger than 200,000 microfarads, which is really 200 millifarads! That capacitor was about as big as a loaf of bread, so a 1 farad capacitor would be very large indeed.
In general, I suggest using electrolytics in the "dirty" parts of your design like in the power supply input and filtering. Also, if you are AC coupling one circuit to another (you will learn about this shortly), electrolytics will do; however, in audio circuits they may not "sound" very good. That is, they have frequency-dependent effects that may not be desirable. Tantalums are good where low lead impedance and low internal ESR (equivalent series resistance) is needed and low leakage. Lastly, I suggest using the ceramics everywhere they will work: de-coupling, and in your general circuits. The only problem is they tend to come in small values and have high variance in their tolerance, but you can get 1–5% tolerance ceramics for more money.
Capacitors are used a number of ways in electronic circuits. In analog circuits, they have many uses and are the basis of many circuits, but in digital circuits they have uses as well, in power de-coupling and interfacing to the real world, for example. But, at the end of the day a capacitor is an energy storage device—period. You charge the capacitor by applying a voltage, and it stores the charge and then later can generate a voltage. The charging and discharging is exponential, which you will see in a moment. Let’s take a look at the capacitor models again and see some examples of how to use them.
3.2.1 Capacitor Models
Internally a capacitor really has more than just capacitance; there is also a series resistance associated with the capacitor (ESR—equivalent series resistance) as well as lead inductance and leakage. All are so small that in most cases you can forget about them unless it’s a high-precision design (voltage regulators for example have very specific needs for the capacitors, so beware). Considering this we can model a capacitor as a perfect model in most cases and just talk about the capacitance. So let’s see what a capacitor does in real circuits. First, starting with the capacitor equation
- I = C*dv/dt
This states that the current is the time derivative of the voltage. Another interesting result is if we integrate this function (those who don’t know calculus, just try to follow; the results are all that matter).
- I = C*dv/dt
Dividing by C, and multiplying both sides by dt
- I/C * dt = dv
And now assuming that the circuit is operating for 0 to time t, we get
In other words, the voltage on a capacitor is the integral or sum of the current over the time divided by the capacitance, an interesting side note. Astute readers will realize that based on these results, capacitors (and their cousins inductors) can be used for analog computing and the computation of derivatives and integrals!
Referring to Figure 3.19, we have the most simplistic capacitor model: There is a current Ic that is flowing in the circuit that is charging the capacitor based on the governing capacitor equation. What actually happens is interesting. At some point the capacitor will fully charge to the voltage across it V; when this happens the current Ic will be 0 by definition. Then the capacitor is fully charged and no current will flow. Once the capacitor is charged then it is free to discharge (through a load); let’s see that. There is an interesting side effect of this charging process, and that is that capacitors only pass AC, not DC currents. That is, the DC current must be changing for there to be a current flow. This is apparent from the governing equation:
- I = C*dv/dt
Figure 3.20 Capacitors block DC.
The right side is 0 if the change in voltage per unit time is 0. But, the interpretation of this is more subtle. The interpretation is that we can use capacitors to block DC and pass AC. Figure 3.20 depicts this wonderful side effect. So using a capacitor we can strip away the DC component of a signal and simply obtain the change or AC component. For example, say you had an audio signal that was 5–6V as shown in Figure 3.20a, but your amplifier likes signals that vary from 0–1V. You could use an AC coupling capacitor to strip the DC component and only pass that AC; this would result in a signal from 0–1V only (the AC component) as shown in Figure 3.20b. This configuration of a capacitor is actually a "filter," and care needs to be taken in selecting the value of the capacitor since it’s true that all capacitors will block DC, but the value of the capacitor along with the resistance or impedance of the circuit will also dictate the impedance of the AC component, so for frequencies we want to pass, we need to make sure the value C of the circuit is selected correctly to take this into consideration. However, the rule of thumb for audio applications is that a 1–10μF capacitor is going to pass the audio frequencies from 20Hz–20KHz just fine, while blocking the DC.
Referring to Figure 3.19c, we see the discharge of the capacitor. In this case, notice that the current Ic changes direction from the charging case. This makes sense since the capacitor is sourcing the current from the previous charge. The capacitor will continue to discharge until the charge on its plates are depleted; at this point the voltage V will be zero as well as the current Ic=0.
3.2.2 Capacitors in Series and Parallel
Before moving on to RC circuits and putting everything together, let’s take a momentary detour to see how to add capacitors in series and parallel. The results below come directly from the definition of capacitance Q=CV, and the governing equation, I=C*dv/dt.
184.108.40.206 Capacitors in Parallel
Parallel capacitors as shown in Figure 3.21 are added similarly to resistors in series; that is, the equivalent capacitance of a number of capacitors in series is the sum of their individual capacitance:
- Ceq = C1 + C2 + ... + Cn
Figure 3.21 Capacitors in parallel.
This makes sense considering that you are simply making a large capacitor by putting them in parallel.
220.127.116.11 Capacitors in Series
Capacitance in series is a little more complex to derive, but the results are the same as resistors in parallel (big surprise):
- 1/Ceq = 1/C1 + 1/C2 + ... + 1/Cn
Which for two capacitors in series as shown in Figure 3.22 simplifies to
- Ceq = (C1*C2) / (C1+C2)
Figure 3.22 Capacitors in series.
Now, you should have a picture of what happens during charging and discharging, along with how to compute series and parallel capacitor arrays. Let’s build a more formal circuit with some components and model the system, so we can at least see how to create some basic capacitor circuits.
3.2.3 RC Circuits
RC circuits simply refer to any circuit that has resistive and capacitive elements. Since we know how to find both the equivalent resistance of resistors in a network and the equivalent capacitance of capacitors in a network, we can focus on a simplified model of an RC circuit as shown in Figure 3.23. We want to analyze this circuit and answer some basic questions:
Figure 3.23 RC circuit model for charging and discharging.
- How does the RC circuit charge?
- How does the RC circuit discharge?
- How do RC circuits respond to different frequencies?
The general RC circuit shown in Figure 3.23 is usually used to model the "natural response" of the circuit; that is, what the circuit does during charging (switch in position 1) and what the circuit does in discharging (switch in position 2). Based on this data, we can come up with a lot of interesting uses for this very simple circuit.
18.104.22.168 RC Charging Analysis
Let’s begin with the charging of the RC circuit. Referring to Figure 3.23b, the circuit looks like this when the switch is closed to position 1. Assuming the capacitor is at 0 charge at the moment before closure, we can write a simple equation that describes the circuit. The circuit is driven with a voltage source Vi; this creates a current through resistor R that charges C. The current Ic must be the same through the resistor as well as the capacitor, so we can write
- Ic = C*dv/dt
- Ic = (Vi – V) / R
Therefore the modeling equation
- C*dv/dt = (Vi – V)/R
This is a first order differential equation, which has the solution
- V = Vi + A*e-t/r*c
The solution for V states that the voltage V is the input voltage Vi plus some constant A multiplied by the exponential term. Assuming that t goes to infinity, we can easily see that the voltage ends up at Vi, which makes sense: The capacitor will eventually charge to the source voltage. But, the math indicates it follows an exponential charging curve, which we will see in a moment, but there’s still the matter of the constant A, which we need to find based on initial conditions. Right at the moment of closure of the switch, that is t=0- (0- means an infinitesimal amount of time before 0, and similarly 0+ means an infinitesimal amount of time after 0), the capacitor had 0 charge on it; therefore, 0V. Hence, we can write this (recalling that any base to the power 0 is 1, i.e. x0 = 1):
- 0V = Vi + A*e-0/r*c = Vi + A*e0 = Vi + A*1
- 0V = Vi + A, A = -Vi
Plugging in our value for A, we have the final model:
- V = Vi – Vi*e-t/r*c
- V = Vi*(1 – e-t/r*c)
This is a very interesting result; it says that the voltage charges to Vi eventually. The formula also states that the rate of this charging is exponential, with the exponential rate controlled by the product R*C. This result is fundamental to RC circuits. With that in mind, let’s plot this response; Figure 3.24 shows the charging of the circuit. As you can see at t=R*C the circuit charges to 63% of the voltage Vi; if you follow this math a little further you come to the result that mathematically at infinity, the circuit charges to 100%, but in practical terms "infinity" is 5 RC time constants, so if you want to know how long an RC circuit will charge, basically t=5*RC is the answer for all intents and purposes.
Figure 3.24a RC charging curve.
As an interesting example, later in this section, we will see how to use the charging model to create a "power-on-reset" circuit needed at the start up of many microprocessors and microcontrollers.
22.214.171.124 RC Discharging Analysis
All right, next let’s discharge the capacitor with the same circuit, but with the switch in position 2. Referring to Figure 3.23a, we assume the capacitor is fully charged, then when we place the switch in position 2, this results in the equivalent circuit shown in Figure 3.23c. What happens now is the capacitor wants to discharge through the resistor R. This discharging will again follow an exponential curve (since we know now that differentials will be involved); with that in mind let’s bang out the details.
Using the passive sign convention (current flowing in the direction of a voltage drop is positive), performing KVL around the loop, we get
- I=-C*dv/dt = V/R
The solution to this is an exponential of the form
- V = A*e-t/r*c
Plugging in V=Vi at t=0, we get the value of the constant for the final result of
- V = Vi*e-t/r*c
Figure 3.24b RC discharging curve.
Which should make sense. And for fun, let’s graph this result as shown in Figure 3.24b. As you can see, it’s similar to the graph for the charging, but inverted. Also, at t=RC the system has discharged to 37% of its initial charge; this is easy to see using the discharge formula:
- V = Vi*e-r*c/r*c = Vi*e-1 = Vi*(0.367)
That is, V = 36% of Vi at t=RC.
Now that you have charging and discharging under you belt, let’s see some very useful circuits we can construct with these results.
3.2.4 Low Pass Filters
The previous RC circuit we analyzed was actually a low pass filter. This means that the circuit tends to pass low frequency signals and send to ground high frequency signals. Referring to Figure 3.25a, we see a real-world example of a low pass filter feeding a port (a chip pin or another block of the system). The input voltage is a crisp 1/0 or (+5/0V) clock or whatever, but the interesting thing is the "response" from the RC filter as shown in Figure 3.25b. See how the filter in the lower part of the graph charges in response to the step impulse, then see how it discharges when the step input goes to 0V? This is how the real world looks. Moreover, this is how you must model your chip inputs at high speed, since each input has a bit of capacitance to ground and the signal paths themselves have finite resistance.
Figure 3.25 Low pass RC filter.
If we forget about the "time domain" that we have been working in for a moment and talk about the "frequency domain," then we can be more specific about frequency related effects of the low pass filter. All the frequency domain means is that we discuss signals in terms of their frequency rather than their time varying descriptions; in filter analysis this is much more productive. If we let the frequency of the signal be f, then the gain of the low pass filter or the ratio of the output to the input is
- Low Pass Gain
- Vout/Vin = 1/[1+(2**f)2*R2*C2]1/2
- Vout/Vin = 1/[1+(f3dB)2*R2*C2]1/2
- where f3dB = 1/2**R*C
Let’s plot this gain to get an idea of the response of a single RC low-pass filter. Figure 3.26 shows the plot with frequency on the X-axis and gain Vout/Vin on the Y-axis. Additionally, the X-axis is logarithmic (powers of 10) and marked off using a constant term called the "3dB" point. The 3dB point is the frequency at which the filter starts to work appreciably. Appreciably means that the gain is about 70% roughly or .707, so when the filter kicks in we like to call this the 3dB point and use it as a reference. In this case, considering this, it’s easy to understand the frequency/gain graph in Figure 3.26. At f = 0, the gain of the system is 1.0; as we increase the frequency in powers of 10 times the frequency of the 3dB mark, we see the filter start working. For example, at f3dB the gain is .707 (so the frequencies at f=1/2**R*C will be impeded and only .707 will get through), but at 10*f3dB the gain is nearly down to 0.1 and the filter is really starting to filter the signal, and at 100*f3dB there is nothing getting through.
Figure 3.26 Low pass RC filter response curve.
So that’s all there is to the low-pass filter! For example, say you wanted to filter a signal at 10KHz: You want to pass 10KHz, but start filtering after that. We simply use 10KHz as the f3dB point and make an RC filter. Based on the equation f3dB = 2**R*C, and assuming we have lots of 1K resistors lying around, we get
- 10KHz = 1/2**1K*C
- C = 1/2**1K*10Khz = .0159μF
So, we might use a 0.01μF capacitor since it’s a common value; of course this will shift the f3dB point slighty, but probably not enough to make a difference to us. As a last note, realize that the filtering of single RC stage occurs at -20dB per decade. If you want a "brick wall" that falls off faster you must cascade stages of RC filters; each stage will give you another -20dB of fall off. However, in our case when designing embedded systems and video game consoles, a single stage low-pass filter is about as complicated as it gets.
3.2.5 High pass Filters
High pass filters are nearly identical to low pass filters except they pass high frequencies rather than low. And amazingly all you do is swap the R and C in a low pass filter and now you have a high pass filter, as shown in Figure 3.27. The math is left as an exercise; the results for high-pass gain are
- Vout/Vin = R /[ R2 + 1/((2**f)2*C2)]1/2
Or another form is
- Vout/Vin = 2**f*R*C /[ 1 + 1/((2**f)2)]1/2
Figure 3.27 High pass RC filter.
Again, the f3dB point is equal to 1/2**R*C, and instead of this being where the filter starts blocking the frequencies appreciably, this is where the high pass filters start passing them, thus the frequency versus gain graph looks like Figure 3.28.
3.2.6 POR—Power On Reset Circuits
When you power on your embedded system, most microprocessors and microcontrollers have a reset line that must be pulled low or high for a good amount of time (a few milliseconds at least); this is shown in Figure 3.29. Once the system is powered up and the voltage supplies are stable (+5V, +3.3V, etc.), the system needs to issue a reset to the processor and peripherals. These reset circuits are traditionally called power-on-reset or POR circuits. In most cases, you can do this with a simple capacitor and resistor along with a reset switch. As an example, assume that we have a processor (and system) that requires an active low (0V) reset signal; we need to design a circuit that generates a low (0V) for a few milliseconds, but then changes to +5V at some point. Let’s also assume that the reset must exist for 3.5ms, so let’s round to 5ms to be safe, and we want to give the user the ability to manually reset the system with a push button. Figure 3.30 shows the design for such a system.
Figure 3.28 High pass RC filter response curve.
Figure 3.29 Powering up with reset.
126.96.36.199 POR Analysis
Assuming the system is unpowered and the reset button is not depressed, let’s apply power to the system at t=0. When we do this, the VCC line goes to +5V and the RC circuit starts charging. However, at this point, the voltage at node A is 0V approximately, so the processor is being fed the required 0V reset signal. As the RC circuit charges the capacitor C, the voltage at the node will continue to rise, until the voltage across C is equal to the supply voltage of VCC = 5V (t=5*RC approximately). However, there is a detail to consider: In digital systems, TTL systems detect a "1" at 2.4V roughly, CMOS at 3.5V approximately (more on this later). So the bottom line is that for a TTL system, the reset line will hit 2.4V before it hits 5V and thus the system will no longer be in reset, so we want to use a target voltage of maybe 2.5V as the "out of reset" voltage to shoot for in our timing calculations. Given that, we know that the amount of time for a capacitor to charge in an RC circuit is part of the charging equation:
Figure 3.30 Basic POR design.
- V = Vi*(1 – e-t/r*c)
Where Vi is the voltage source, 5V in this case, so let’s set V=2.5V, and solve for RC with a t=5ms (the reset time desired):
- 2.5V = 5.0V*(1 – e-5.0ms/r*c)
Dividing thru by 5.0V, and subtracting 1.0 from both sides
- -0.5 = -e-5.0ms/r*c
Taking the natural log of both sides
- ln 0.5 = ln e-5.0ms/r*c
- -0.693 = -5.0ms/RC
Solving for RC
- RC = 7.2x10-6
Now, we have two unknowns and only one equation, so we have freedom to pick one as we wish. Let’s select a common value for C, and see what result we get for R. What about .1μF for C:
- R = 7.2x10-6 / 1μF = 72Ω
Since 72 ohms is hard to find, a value of 100 ohms will work, and the only effect will be a slightly longer reset, which is fine.
Figure 3.31 Final POR design.
The final reset circuit is shown in Figure 3.31. The only thing left to discuss is the manual reset button. When this is depressed what happens? If the capacitor is charged then it will immediately discharge through the 100 switch branch resistor to ground (this will take about 5ms as well), then the reset line will have a 0V on it until the user releases the reset button. When he does so, the circuit will recharge in 5ms and take the machine out of reset once again. So the resistor in the reset switch branch is needed to give the capacitor a discharge path with resistance; without it, the instantaneous current generated from the capacitor would be huge. Also, last note, what about the tolerance and voltage rating of the capacitor in our reset circuit? First, the tolerance isn’t that important; if we get the worst capacitor possibly it will range ±20%; this will mean ±1ms more or less reset time, which should be fine since we over designed the spec to 5ms to make sure. Lastly, the largest voltage on the capacitor should be 5V, so if we pick a nice 15–25V capacitor our design should have a very long lifespan.
3.2.7 Bypass and Power Feed Capacitors
The next use of capacitors is more related to the digital realm. When you have a digital system, it’s potentially switching millions to billions of times a second. This switching action causes "noise" and glitches on the data lines as well as the power lines. What we don’t want are power lines that have noise on them feeding our processors, memory, and "glue" chips, so a common practice is to attach "bypass" capacitors to all chip packages to pass high frequency noise to ground, or otherwise block it from the power feeding a chip. Figure 3.32 shows this design. Here we see a generic integrated circuit IC with 14 pins (this is a DIP, dual in-line package), and typically power is on pins 14 (VCC = +5) and 7 (GND), or the corner pins in other words. In any case, assuming we have the power lines connected to the +5V system power supply, everything is good, but what happens if some high frequency noise comes down the power lines? Well, it goes right into the chip disturbing your computations. But, could we somehow filter this out? Easy! Let’s use a high pass to ground filter; this turns out to be just a capacitor placed in parallel across the power contacts of the IC (as close as possible) as shown in Figure 3.32. The trick here is to make the impedance of the capacitor to high frequencies less than the IC itself, so the noise would rather travel through the capacitor to ground than the IC itself.
Figure 3.32 Adding a bypass capacitor to a IC.
Also, as you design faster and faster boards, the technique of bypassing individual chips no longer works as well, and you must distribute your bypass caps all over the board in a matrix as shown in Figure 3.33. The values start to not even matter since the lead inductance starts to dominate and thus your goal is simply to put a lot of bypass caps on your board, equally spaced. However, for all our designs, just use a 0.01μF–0.1μF for each IC and you will be fine. Additionally, for large ICs that have busses, add a 1.0–10.0μF tantalum cap for power feeding. Why this is needed can be explained with an example: Say you have an IC that is controlling a 32-bit bus. That bus changes state from digital 0 to 1 or vice versa; this generates a huge current which will have to be fed or sunk by the power supply rails. However, those rails go all the way back to the power distribution network and the power supply. That’s a long way for the current to travel with a lot of resistance, so what happens is that you get a huge voltage drop over your power lines and the voltage on your IC actually changes!
Figure 3.33 Bypass capacitors distributed in a matrix.
This whole process can be understood by realizing that the ground the IC sees translates up to maybe a few hundred millivolts—.2V or something—this can cause problems, but by having a fat cap to feed the IC when this happens with very short leads, it’s like having a power supply right on chip that can handle short bursts of power. Thus your ground voltage won’t jump, so on all processors, memory, and large bus buffering chips, place a 1.0–10.0μF tantalum (low lead impedance) and your design will be very clean.