The definition of a bypass capacitor can be found in the dictionary of electronics.
Bypass capacitor: A capacitor employed to conduct an alternating current around a component or group of components. Often the AC is removed from an AC/DC mixture, the DC being free to pass through the bypassed component.
In practice, most digital circuits such as microcontroller circuits are designed as direct current (DC) circuits. It turns out that variations in the voltages of these circuits can cause problems. If the voltages swing too much, the circuit may operate incorrectly. For most practical purposes, a voltage that fluctuates is considered an AC component. The function of the bypass capacitor is to dampen the AC, or the noise. Another term used for the bypass capacitor is a filter cap.
n the chart on the left, you can see the what happens to a noisy voltage when a by-pass capacitor is installed. Notice that the differences in voltage are pretty small (between 5 and 10 millivolts). This graph represents a small range of 4.95 volts to 5.05 volts. Random electrical noise causes the voltage to fluctuate, as you can see in graph. This is often called 'noise' or 'ripple'. The blue line, represents the voltage of a circuit that doesn't have a bypass. The pink line is a circuit that has a bypass. Ripple voltages are present in almost any DC circuit. You can see even with the bypass, the voltage does fluctuate, even though it is to a smaller degree. The key function of the bypass capacitor is to reduce the amount of ripple in a circuit. Too much ripple is bad, and can lead to failure of the circuit. Ripple is often random, but sometimes other components in the circuit can cause this noise to occur. For example, a relay or motor switching can often times cause a sudden fluctuation in the voltage. Much like disturbing the water level in a pond. The more current the other component uses, the bigger the ripple effect.
A fair question to ask is why does this small fluctuation matter? Gee, isn't the voltage close enough? The answer depends on the type of circuit you are designing. If you are just running a motor connected to a battery, or perhaps an LED, then chances are the ripple doesn't matter much to you. However, if you are using digital logic gates, things get slightly more complex, and this ripple can cause problems in the circuit.
Lets consider for just a moment what the effect of the ripple voltage is. Basic electrical theory tells us that a voltage is a difference in potential. It tells us that a current will flow across this difference in potential. We know that the larger the voltage, the larger the current. We also know the direction of the voltage determines the direction of the current.
Consider the graphs on the right. The top graph shows a pair of ripple voltages that I enlarged to make them easier to see. Just like the previous graph, the blue line represents the circuit without the bypass cap, and the other line is with the bypass cap. By looking along the bottom axis of the graph, you can see that starting at point 2 that the voltage is increasing. By looking in the Ripple Current chart, point 2 shows that the current is a relatively large magnitude in one direction. In contrast, point 5 shows the voltage and current going the other direction.
Notice the difference between the values with and without the bypass cap. By dampening the ripple voltage, the bypass cap also dampens the ripple current. I would like to point out that the Ripple Voltage chart and the Ripple Current charts clearly show an alternating current. You can see how the voltage swings, and how the current changes directions. Even though this is is a DC circuit, the ripple is causing an AC component. The bypass capacitor is helping to reduce this AC component.
The ripple current acts like an eddie or backflow in the circuit. As the fluctuating voltages and currents propogate through the circuit, differences in voltages and currents can occur that cause the circuit to fail. For example, assume that a AND gate is holding its state because the semiconductors that make up the gate are in a stable state. Transistors work by currents flowing one direction through the gate. If the current stops flowing, the transistor shuts down. If a ripple current comes through where the current momentarily flows the wrong direction, the gate will shutdown, and you will see a change it its output. This can cause a cascading failure, because one gate may be connected to many other gates.
To summarize, the bypass capacitor is used to dampen the AC component of your DC circuits. By installing bypass capacitors, your DC circuit will not be as susceptable to ripple currents and voltages.
Using Bypass capacitors
Many schematics that you find published in magazines and books leave the bypass capacitors out. They assume you know to put them in. Other times you will find a little row of capacitors (caps) stuck off in the corner of the schematic with no apparent function. These are usually the bypass (or filter) caps. If you pickup almost any digital circuit, you will find a bypass capacitor on it.
The most simple incarnation of the bypass capacitor is a cap connected directly to the power source and to ground, as shown in the diagram to the left. This simple connection will allow the AC component of VCC to pass through to ground. The cap acts like a reserve of current. The charged capacitor helps to fill in any 'dips' in the voltage VCC by releasing its charge when the voltage drops. The size of the capacitor determines how big of a 'dip' it can fill. The larger the capacitor, the larger the 'dip' it can handle. A common size to use is a .1uF capacitor. You will also see .01uF as a common value. The precise value of a bypass cap isn't very important.
So, how many bypass capacitors do you really need? A good rule of thumb I like to use is each IC on my board gets its own bypass capacitor. In fact, I try to place the bypass cap so it is directly connected to the Vcc and Gnd pins. This is probably overkill, but it has always served me well in the past, so I will recommend it to you. It turns out you can even by DIP sockets that have the bypass caps built in. I suppose once you reach more than a few capacitors per square inch, you might be able to let up a bit!
Another great place for a bypass cap is on power connectors. Anytime you have a power line heading off to another board or long wire, I would recommend putting in a bypass cap. Any long length of wire is going to act like a little antenna. It will pick up electrical noise from any magnetic field. I always put a bypass cap on both ends of such lengths of wire.
The frequency of the ripple can have a role in choosing the capacitor value. Rule of thumb is the higher the frequency, the smaller the bypass capacitor you need. If you have very high frequency components in your circuit, you might consider a pair of capacitors in parallel. One with a large value, one with a small value. If you have very complex ripple, you may need to add several bypass capacitors. Each cap is targeting a slightly different frequency. You may even need to add a larger electrolytic cap in case the amplitude of the lower frequencys is too great. For example, the circuit on the right is using three different capacitor values in parallel. Each will respond better to different frequencies. The 4.7uF cap (C4) is used to catch larger voltage dips which are at relatively low frequencies. The cap C2 should be able to handle the midrange frequencies, and C3 will handle the higher frequencies. The frequency response of the capacitors is determined by their internal resistance and inductance.
Bypass capacitors help filter the electrical noise out of your circuits. They do this by removing the alternating currents caused by ripple voltage. Most digital circuits have at least a couple of bypass capacitors. A good rule of thumb is to add one bypass capacitor for every integrated circuit on your board. A good default value for a bypass cap is 0.1uF. Higher frequencies require lower valued capacitors.