In this chapter, we are going to learn how to measure the time it takes for a capacitor to charge. Once we learn this, we can use capacitors for timers—both for delaying a signal and for creating an oscillating circuit.
17.1 Time Constants
As we learned in Chapter 16, when a voltage is applied to a capacitor, it will store energy by storing a charge on its plates, the amount of charge being based on the voltage supplied and the capacitance of the capacitor (see Equation 16.1).
The cases we examined in Chapter 16 generally had the battery connected directly to the capacitor. In such cases, the capacitor charges to the source voltage almost immediately. However, if a capacitor charges through a resistor (instead of being directly connected to the battery), then it takes much longer to fill the capacitor to capacity than if it were connected to the battery directly. In fact, it never fully reaches capacity, though it gets close enough that we say that it does.
Having a resistor in series with a capacitor is a configuration known as an RC (resistor-capacitor) circuit . The amount of time it takes a capacitor to charge is based on both the resistance of the resistor and the capacitance of the capacitor. The actual equation for this is kind of complicated, but there is a simple trick that suffices for nearly every situation, known as the RC time constant.
The RC time constant is merely the product of the resistance (in ohms) multiplied by the capacitance (in farads) which will yield the RC time constant in seconds. The RC time constant can be used to determine how long it will take to charge a capacitor to a given level (we will talk about what this level is in a moment). So, for instance, if I have a 100 μF capacitor and a 500 Ω resistor, the RC time constant is 0.0001 ∗ 500 = 0.05 second.
For instance, if I wait for 2 time constants (in this case, 0.05 * 2 = 0.1 second), my capacitor will be charged to 86.5% of the supply voltage. The current flowing through it will be at 13.5% of what current would be flowing if there was just a straight wire instead of a capacitor.
Example 17.13 I have a power supply that is 7 V and a capacitor that is a 100 μF capacitor. I want it to take 9 seconds to charge my capacitor. What size of a resistor do I need to use to do this?
To solve this problem, we need to work backward. Remember, we are considering 5 time constants to be fully charged. Therefore, the time constant we are hoping to achieve is 9/5 = 1.8 seconds. The capacitance is 100 μF, which is 0.0001 F. Since the time constant is merely the product of the capacitance and resistance, we can solve for this as follows:
Therefore, to make it take 9 seconds to charge the capacitor, we need to use an 18 kΩ resistor.
Example 17.14 Suppose a 100 μF capacitor has been charged up to 7 V and then is disconnected from the power supply, but the ground connection remains. We then connect the positive terminal of the capacitor to a 5 kΩ resistor that connects to ground. After 2 seconds, how much voltage is remaining in the capacitor?
To find this out, we first need to find the RC time constant of the circuit.
So the RC time constant is 0.5 second.
So, after 2 seconds, we have performed 4 RC time constants. Looking at Figure 17-1, we have discharged 98.2% of the capacitor’s voltage. This means that the amount of voltage lost should be 0.982 * 7 V = 6.874 V. If we have lost that much voltage, that means we should subtract it, so the remaining voltage is 7 V − 6.874 V = 0.126 V.
So the voltage after 2 seconds will be 0.125 V.
17.2 Constructing a Simple Timer Circuit
Let’s say that we want a circuit that, when turned on, waits for a certain amount of time and then does something. How might we do it?
Think of it this way. We can use capacitor charging to give us a time delay. However, we need something that “notices” when the time delay is finished. In other words, we need a way to trigger something when a certain threshold is crossed.
What happens to the capacitor as it charges? The voltage across its terminals changes. When it is first connected to the circuit, there is zero voltage across its terminals. As it charges, the voltage across the capacitor’s terminals keeps going up until it matches the supply voltage. Therefore, we know when we have hit our target time based on when the voltage is at a certain level. But how will we know when we are at the right voltage? Have we done a circuit so far that detects voltages? What component did we use?
If you remember back in Chapter 11, we used the LM393 to compare voltages. We supplied the LM393 with a reference voltage , and then it triggered when our other voltage went above that voltage. We can do the same thing here.
What we will construct is a circuit that waits for 5 seconds and then turns on an LED. In order to do this, we will need to choose (a) a reference voltage to use, (b) a resistor/capacitor combination that will surpass the reference voltage after a certain amount of time, and (c) an output circuit that lights up the LED.
There are virtually infinite combinations we could choose from for our reference voltage, resistance, and capacitance. In fact, the supply voltage doesn’t matter so much since what we are looking at are percentages of the supply voltage, which will be the same no matter what the actual voltage is.
For this example, we will use a basic 5 V supply and make the reference voltage to be half of the supply voltage. This allows us to use any two equivalent resistors for a voltage divider to get our reference voltage.
Now, since the reference voltage is half of our supply voltage, we will use the table in Figure 17-1 to determine how many time constants that needs to be. The table says that for 50% of voltage, it will take 0.7 time constant (it is actually 50.3%, but we are not being that exact).
So we can use any resistor and capacitor such that the ohms multiplied by the farads equals 7.14. I usually use 100 μF capacitors for larger time periods such as this because they are larger and because being exactly 0.0001 F, it makes it easier to calculate with. Therefore, we can very simply calculate the needed resistor for this capacitor:
Therefore, we need a resistor that is about 71, 400 Ω. We could choose a combination of resistors that hits this exactly, but for our purposes, we only need to get close. In my case, the closest resistor I have is 68,000 Ω (i.e., 68 kΩ). That is close enough (though I could get even closer by adding in a 3 kΩ resistor in series).
Remember, though, from Chapter 11, that the LM393 operates using a pull-up resistor. That is, the comparator doesn’t ever source current. It will sink current (voltage level 0 when the + input is less than the – input) or disconnect (when the + input is greater than the – input). Therefore, R4 is providing a pull-up resistor to supply power to the LED when the LM393 disconnects.
Figure 17-3 shows this circuit laid out on the breadboard. We are using the second voltage comparator of the LM393 just because it was a little easier to show the wiring for it. If you need to see the pinout for the LM393 again, it was back in Figure 11-4.
Notice the prominence of our basic circuits from Chapter 9 on the breadboard. On the top, we have a combination pull-up resistor which is also acting as a current-limiting resistor (as they often do). On the bottom left, we have a voltage divider.
17.3 Resetting Our Timer
The timer is great, except for one thing—how do we turn it off? You might have noticed that, even if you disconnect power to the circuit, when you turn it back on, it doesn’t do any timing anymore! Remember, the capacitor is storing charge. When you turn off the circuit, it is still storing the charge.
Now, you can very simply get rid of the charge by putting a wire between the legs of the capacitor. However, for larger capacitors, you would need to do this with a resistor instead of a wire in order to keep there from being a dangerous spark (the resistor limits the current, which makes the discharge slower). But how do we do this with a circuit?
What we can do is add a button or switch that will do the same thing as putting a wire or resistor across the legs of the capacitor. Figure 17-4 shows how to do this.
Now let’s look at how this circuit works. First of all, we added two components, the switch and the R5 resistor connected to it. To understand what this does, pretend for a minute that the resistor isn’t there. What happens when we push the button? That would create a direct link from the positive side of the capacitor to ground. Since the negative side of the capacitor is also connected to ground, that means that these two points would be directly connected. Thus, they would be at the same voltage. This would be achieved by the charge suddenly rushing from one side to another to balance out.
Also notice R1 and R5. When the button is being pushed, what is happening to them? Think back to our basic resistor circuits. If we have two resistors, with a wire coming out of the middle, what is that? It’s a voltage divider! So not only is R5 being a current-limiting resistor for the button, it is also acting as a voltage divider in concert with R1.
What this means is that the capacitor will only discharge down to the level of voltage division between these resistors. That’s fine, as long as it is low enough. You will find that in electronics, “close enough” often counts. The trick is knowing how close is close enough and how close is still too far.
However, usually we can perform some basic calculations to figure this out. Since R1 is 68 kΩ and R5 is 200 Ω, what is the voltage at the point of division? If we use a 9 V supply, using the formula from Equation 9.1, then we can see that
So, as you can see, when the button is pushed, the final voltage of the capacitor, while not absolutely 0 volt, is pretty darn close.
Also note that, if we wanted, we can reverse the action of this circuit. By swapping our two inputs to the voltage comparator, we can make the circuit be on for 5 seconds and then switch off.
17.4 Review
- 1.
Having a resistor and capacitor in series with each other is known as an RC circuit.
- 2.
In an RC circuit, the amount of time it takes for a capacitor to charge to the supply voltage is based on the capacitance of the capacitor and the resistance of the resistor.
- 3.
The RC time constant is a convenient way to think about how long it takes for a capacitor to charge in RC circuits.
- 4.
The RC time constant is calculated by multiplying the resistance (in ohms) by the capacitance (in farads) with the result being the number of seconds in 1 RC time constant.
- 5.
The table in Figure 17-1 shows how long it takes to charge a capacitor to different percentages of supply voltage as a multiple of RC time constants.
- 6.
The RC time constant chart can also be used to calculate the amount of time it takes for a capacitor to discharge to ground if it is disconnected from its source and connected through a resistor to ground. In this case, Figure 17-1 is used to tell what percentage of the voltage has been discharged.
- 7.
A timer can be constructed by using a comparator and an RC circuit along with a reference voltage provided by a voltage divider. By tweaking the RC circuit, the timing can be changed.
- 8.
After charging a capacitor, a means needs to be provided to discharge it as well, such as a button leading to ground.
- 9.
Such discharge methods need to have resistance to prevent sparks and other failures, but not too much resistance as they can accidentally form voltage dividers with other resistors in the circuit and prevent full discharge.
- 10.
Even as our circuits get more advanced, the basic circuits we found in Chapter 9 are still dominating our circuit designs.
17.5 Apply What You Have Learned
- 1.
If I have an RC circuit with a resistor of 10 Ω and a capacitor of 2 F, what is the RC time constant of this circuit?
- 2.
In the previous question, how many seconds does it take to charge my capacitor to approximately 50% of supply voltage?
- 3.
If I have an RC circuit with a resistor of 30,000 Ω and a capacitor of 0.001 F, what is the RC time constant of this circuit?
- 4.
In the previous question, what percentage of the capacitor’s voltage is charged after 60 seconds?
- 5.
If I have an RC circuit with a resistor of 25 kΩ and a capacitor of 20 μF, what is the RC time constant of this circuit?
- 6.
Give a resistor and capacitor combination that will yield an RC time constant of 0.25 second.
- 7.
Reconfigure the circuit in Figure 17-2 to wait for 3 seconds. Draw the whole circuit.
- 8.
Redraw the previous circuit and circle each basic resistor circuit pattern and label it.