Saturday, May 9, 2009

Electricity for Synth-DIYers: Capacitors

The next electrical component we're going to talk about is the capacitor. A capacitor is basically a storage device for electric charge. It's somewhat similar to a battery, although the analogy only goes so far: a battery stores electrical energy by converting it to and from chemical energy. A capacitor does not do that; it simply collects and stores charge.

A capacitor consists of two metal plates, each attached to a conductor, and separated by some type of insulator which is referred to as the dielectric. When the two plates of a capacitor are connected to the two poles of a battery or some other source of DC current, current flows in. At this point we have to talk about electrons, since they are the charge-carrying particles at the atomic level. Recall that the charge of the electron is negative, and that the flow of electrons in a circuit is in the opposite direction of "conventional current" (that is, conventional current flows from positive to negative, but electrons actually flow from negative to positive).



So electrons flow from the negative pole of the battery into one plate of the capacitor. They can't flow over to the other side of the capacitor because of the insulating dielectric. The dielectric won't permit a flow of current through it, but it will allow electrons to collect on its surface. The electrons on the negative side of the capacitor develop an electric field, which repels like charges in the same way that a magnet pole repels the like pole of another magnet. So what happens is that as electrons build up on one side of the dielectric, the electric field shoves electrons off the opposite side to the other plate and then out of the capacitor. That side of the capacitor then develops a positive electric field (absence of electrons). This process causes a voltage to develop between the two sides of the capacitor. This voltage opposes the voltage of the battery, which causes the flow of current into the capacitor to slow down. Eventually the voltage across the capacitor equals the battery voltage, at which point the flow of current into the capacitor stops. The system is now in a stasis condition. No matter how much longer you let the circuit sit there, nothing else is going to happen

Now, remove the battery from the circuit. What we have left is a charged capacitor -- essentially, another battery (although it holds a lot less energy, unless it's a really huge capacitor). If you then have a switch that you can use to collect the two sides of the capacitor together, the electrons will flow back out of the negative (excess electrons) side, through the circuit, and back around to the positive (deficient in electrons) side. As this occurs, the voltage across the capacitor drops. Eventually, the number of electrons on each side equals out; at this point the voltage across the capacitor is zero, and the current stops.

Controlling the Charge and Discharge Time

With a typical capacitor, if there is nothing external to restrict the current flow, the charging and discharging processes will both happen extremely fast. Putting a resistor in series with the cap slows down the charge and discharge rate, which leads to one of the main uses for capacitors in DC circuits: timing. This is commonly referred to as an RC circuit. Here is an RC circuit used to implement a crude form of AR envelope generator:


When the pushbutton switch (the symbol to the right of the battery) is pressed, the top half closes and the bottom half opens.  The battery is connected to the capacitor through the resistor, and the battery charges the capacitor.  As it does so, the voltage at the output goes up gradually.  Releasing the button opens the top half and closes the bottom half.  This disconnects the battery, and it completes a circuit from one side of the capacitor to the other, through the resistor.  The capacitor discharges through the resistor, and the voltage at the output gradually goes to zero.  A variable resistor or potentiometer could be used to vary the charge and discharge rate.  

The amount of time it takes for the capacitor to reach a given level of charge, at a given supply voltage, is determined by the capacitance of the capacitor and the resistance of the resistor; this is called the time constant. For a given resistance, the charge/discharge time is very repeatable, and the voltage to which the capacitor is charged will also be very repeatable provided that the supply voltage is stable. By convention, the time constant is given as the amount of time it takes to charge the capacitor to about 63% of its full capacity, which also means that the voltage across it will be 63% of the supply voltage. The calculation is simple:

time = RC

where R is the resistance in ohms, and C is the capacitance in farads (which we'll discuss further down).  It should be noted that the charge rate is not linear; as the capacitor charges, the opposing voltage begins to push back against the inflow of current, and the charging rate slows down.  As a rule of thumb, it takes 5x the time constant for the capacitor to reach full charge.

Capacitors and Alternating Currents

So far, we've talked about capacitors and direct currents. How does a capacitor behave with an alternating current? Well, let's think about it, based on what we've discussed so far. The distinguising characteristic of an alternating current is that it switches back and forth from current flow in one direction to current flow in the other, and hence the voltage switches between positive and negative. If we place a capacitor between the two poles of an AC source, and assume that we start with the positive-going half, then the capacitor behaves as described previously: it charges until its voltage equals the source voltage, and then current stops. However, when the AC switches direction, it is no longer opposing the capacitor voltage; rather, it is reinforcing it. So the capacitor first discharges, and then charges in the opposite direction. Again, its voltage eventually equals the source voltage, at which point the current stops until the AC changes direction again.

But what if we use a high enough AC frequency that the cap doesn't have time to fully charge before the direction reverses? We find that the AC current never fully stops, except for the actual moments when the AC waveform itself is crossing through zero volts, on the way to the other side. In fact, if the AC frequency is high enough, we find that the current flows in and out of the cap the same as it would if that part of the circuit were bypassed with a wire. It looks like the AC current is going through the capacitor! We know it actually isn't; the electrons can't pass through the dielectric. But the alternating flows in and out behave exactly the same as if they did.

And the higher the frequency of the AC current, the less impedence the capacitor poses to it. Impedence is just a fancy word for resistance in the AC context. The capacitor is behaving like a frequency-dependent resistor -- which is exactly what a filter is. The cap is a simple high-pass filter; it blocks low frequencies (and DC, which has a frequency of zero), and lets high freqencies pass. Nearly all filters used in synthesizers are based on the frequency-dependent behavior of the capacitor. Note that a simple capacitor is a long way from a practical VCF, but it's still the basis of one.

If the capacitor is placed in series with the circuit, it acts as a high-pass filter:


If the capacitor is connected between the circuit and ground (e.g., the negative side of the battery), then it "shorts out" the high frequencies. The low frequencies that can't pass through the capacitor go past it as if the capacitor wasn't there. So, in this configuration, the capacitor acts as a low-pass filter.

When using a capacitor as a filter, it would be nice to know what the cutoff frequency is. The problem with the circuits as shown above is that the exact cutoff frequency is highly sensitive to the small resistances in the wiring of the circuit, the internal resistance of the capacitor (no capacitor has absolutely zero internal resistance), and so forth. We solve the problem by putting a resistor into the circuit. Even a relatively low-value resistor of, say, 500 ohms, will probably be much greater than the parasitic resistances in the circuit, and it will overwhelm their effects. By doing this, we can now use the time constant that we discussed above to calculate the cutoff frequency. Remembering that the time constant is equal to R * C, we have:

Fc = 1 / (2 * pi * R * C)

where R is the resistance in ohms, C is the capacitance in farads, Fc is the cutoff frequency in Hertz (cycles per second), and pi is the familar circle ratio constant, roughly equal to 3.1416. (If you spend time looking at filter formulas and calculations, you will see the constant pi pop up frequently. There are mathematical reasons for this that are too complex to go into here.) Note that RC filters are single-pole filters, with a cutoff slope of 6 dB/octave. Most filters used in synth circuits are either two-pole or four-pole types.

However, there are two important applications for capacitors where we often don't care exactly where the cutoff frequency is: DC blocking and power supply bypassing. All capacitors have the property that, if you have a mixed signal with both DC and AC components, the capacitor can separate the DC from the AC. One place where we often want to do this is in the inputs and outputs of various audio circuits. For example, at the input of an audio amplifer, we would like to be able to remove any DC present in the signal. Amplifying the DC serves no purpose; you can't hear it, and large DC offsets in the output can damage the amp or the speakers. Running the input signal through a suitably large-value (a few millifarads) capacitor will block the DC while allowing all of the AC components in the audio frequency range to pass through. On the other hand, in almost any electronic device there are certain circuit components, such as certain ICs, which are connected to the power supply and vary hugely from moment to moment in how much current they draw from the supply. When they do that, they introduce noise into the power supply. This noise can be picked up by other circuit components, and can introduce noise or extraneous signals into the circuit's output, or even cause the circuit to malfunction. Bypass capacitors are frequently placed on a circuit board to take care of this problem. A capacitor, connected between the power supply and the ground (and usually placed near the power pin of the noise-creating IC) will shunt the noise components to ground and get them out of the DC supply.


Capacitors in Series and Parallel

If you remember the discussion of resistors in series and in parallel from that post, you might recall that when two resistors are in series, their values simply add; when resistors are in parallel, they follow the "reciprocal sums" rule. Interestingly, capacitors behave in exactly the opposite way; caps in parallel add, while caps in series follow the reciprocal-sums rule. So if we have three caps C1, C2, and C3:

In parallel: C total = C1 + C2 + C3

In series: C total = 1 / (1/C1 + 1/C2 + 1/C3)

Types of Capacitors

Capacitors may use different types of contstruction and different dielectric materials, which effects the secondary characteristics of the capacitor, such as working voltage and the physical size of the capacitor.  Often the choice of dielectric is a tradeoff between those two factors.  for example, a capacitor that uses air as a dielectric can tolerate high voltages, but a large-value air cap will be physically huge.  A "better" dielectric can accommodate a higher charge density and make a smaller cap, but these dielectrics often cannot tolerate high working voltages.  The types you are most likely to see in electronics are:

  • Ceramic. These use a disc of ceramic as the dielectric. They are fairly stable, tolerate physical abuse, can take high voltages, and are inexpensive. You will see a lot of these used as bypass caps. Main disadvantage: because the dielectric constant of the ceramic isn't very large, they can't be made in high capacitance values; they'd be too large.

A batch of ceramic capacitors, of various values.

  • Metal-film: polypropylene, polystryene, polycarbonate. These are made of a sandwich of the dielectric material, which is a plastic film, with the plates consisting of either thin foil layers or a metal layer vapor-deposited on the dielectric. The whole thing is wound up in a roll, like paper towels, which makes for large-value capacitors that are very small. Polystyrene types are the most temperature-stable, but they don't take high voltages and are hard to find for some reason nowdays. Use these for applications where the exact capacitance value is critical, such as timing and VCO circuits. Polycarbonate is supposed to be second-best in stability, and it takes higher voltages.

A metal-film "box" capacitor, installed in an MOTM module.

  • Aluminum electrolytic. These offer high capacitance value in a given space. They use a paste or gel electrolyte that "forms" the dielectric when a voltage is applied to the capacitor. Most types are polar; they can only take charge in one direction. They appear mostly in power supplies, and in places in circuits where a very high capacitance value is needed and the exact value isn't critical. They lose capacitance value over time, declining to as little as 10% of the original value after 5-10 years. The electrolyte can overheat and leak, or burst the case, if the capacitor is used in the design improperly or if a circuit malfunction apples current to it outside of its design specs, or if the ambient temperature gets too hot. There are "bipolar" types which appear mostly in amplifier circuits as DC-blocking capacitors, and in loudspeaker crossover circuits.


Electrolytic capacitors. The gray ones are polarized; note the back stripe and the shorter leads which indicate the negative terminal. The black one is bipolar.




A large electrolytic that was used as a filter in an amplifier power supply. The gray stripe, just visible at the right, indicates the negative terminal.  Also note that the cap is marked with its maximum working temperature; these types are often used in applications where they get hot.
  • Tantalum. These offer the absolute highest capacitance value in a given space. They have tighter tolerances than the aluminum electrolytic types, and are less sensitive to environmental conditions. They cannot take high voltages, but the main reason they aren't used much in synth DIY is that they are polar, more expensive than electrolytics, and they have a rather distressing tendency to explode if a reverse voltage is accidentally applied.

  • Paper and mica. These aren't used much any more, but you will run across them in antique electronics. The paper types use an oil-soaked paper as the dielectric. They weren't very good. The mica types (mica is a mineral, a sort of natural glass) were very good, but ceramic types have similar specs these days, and mica is expensive. Few paper caps are in production any more; some mica types still are, but there is no compelling reason to use them in synth circuits.

Units of Measurement

The cpaacitance of capacitors is rated in farads, abbreviated F. As it turns out, because of the way the unit is defined, one farad is a huge amount of capacitance. Unless you work in power distribution, you're unlikely to ever come across a capacitor that large. Capacitors used in electronics are usually rated in microfarads (1/1,000,000 of a farad, abbreviated uF), nanofarads (abbreviated nF, 1000 nF = 1 uF), or even picofarads (abbreviated pF, often pronounced "puff", 1000 pF = 1 nF). North American usage tends to avoid nanofarads; caps in that range are usually expressed as a fraction of a microfarad or as thousands of picofarads. Europeans are more sensible and simply use nanofarads when called for. In most synth circuits, you will see caps ranging rrom a few pF up to about 100 uF. Power supplies will use larger ones for filtering, up into the tens of thousands of uF. Note: many mathematical formulas involving capacitors, including the ones in this post, require the capacitance to be stated in farads, not any of the smaller units. It can all be hard to keep track of.

How Capacitors are Specified

The capacitance value is specified in some sub-unit of farads, as described above.  Unfortunately, unlike the case for resistors, there is no really standard way of marking values on capacitors.  Some caps do use a RETMA-like color coding, but most are marked in text.  One system often used on smaller-value (and physically smaller) caps is a three-digit code, where the first two digits are the first two digits of the value in picofarads, and the last digit is a number of zeros to add to the first two digits.  So, for example, a cap marked "102" would be 1000 pF, or 1 nF.  Electrolytics, particularly larger ones, are usually marked with the actual value.  

There is far more variation in capacitor tolerance values then for resistors.  Most ceramic and film types are sold at 10% tolerance; 1% or better are available but are expensive.  Tolerance is often not marked; you have to look at the packaging to know.  Most electrolytics have terrible tolerance specs; +100%, -50% is not uncommon.  (Also keep in mind that electrolytics usually lose value as they age.  These are good reasons to use some other type in applications where the exact value is important.)

Secondary characteristics that are important in capacitors include whether or not the capacitor is polarized, the working peak voltage, the temperature coefficient (how the capacitance varies with temperature), the tolerance, and the equivalent series resistance or ESR. As we have discussed, most electrolytic and tantalum types are polarized; they can be charged in only one direction, and will be damaged if voltage is applied in the opposite direction (dramatically, in the case of tantalums).  The negative lead is usually indicated by a stripe on the body of the cap, or the lead being shorter, or both.

Working voltage is a function of the dielectric and the capacitor's construction. Some types of dielectric have better ability to withstand high voltage than others do. If an excessive voltage is applied to the capacitor, the dielectric breaks down, and then the capacitor shorts out or does something worse, such as burst or catch fire. When considering voltage ratings, you need to consider the peak voltage that the capacitor will be exposed to, and then allow some margin. Rule of thumb is to specify the cap for at least double the expected peak operating voltage. This is frequently fudged down to 50% or less when specifying large electrolytics, due to physical size and cost.

Most types of capacitors vary with temperature. For electrolytics in particular, this can be considerable, to the extent that manufacturers don't always publish data on it. For other types, there are usually several types or grades of variation with temperature. The Electronics Industries Association has a complicated system for designating these. Just know that if you are buying ceramic caps for an application that requires the least available variation with temperature, look for a type designated "NPO or C0G".

Equivalent series resistance, or ESR, can be caused by both resistance and inductance within the capacitor. ESR becomes a factor in circuits where the cap is expected to handle either large currents or high frequencies (1 MHz or above). In synths, you will usually not run into these situations except when dealing with power supplies. In a power-supply filtering application, it pays to get low-ESR types, since these will not get as hot and therefore will last longer. If you are working with digital circuits having high-frequency clock signals, say for a CPU, you may have to think about capacitor inductance, which causes higher ESR at high frequencies. The easiest way to avoid this problem is to stick to ceramic types whenever possible in high-frequency circuits; ceramics nearly always have very low inductance. (In power-supply filtering and decoupling applications, it is often recommended to use two caps in parallel: a film or electrolytic type to handle the higher currents and lower frequencies, and a ceramic to bypass the high frequencies.)  ESR may vary by frequency, and electrolytics often have high ESR at higher frequencies.  For that reason, it is not uncommon to find, in bypass applications, an electrolytic and a ceramic in parallel.  The electrolytic bypasses the lower frequencies, and the ceramic handles the higher frequencies where the electrolytic's ESR is too high.

Summary

Capacitors are fundamental to today's electronics.  It is important to understand them, since they in effect open the door to AC circuits and signal processing the treats different frequencies differently.  


No comments: