Your integrated circuits are not ideal switches that go merrily high or low without causing disturbances in the force when doing so. Sadly that’s just not the case. That does give me an opportunity though, to show you what a bypass capacitor (also referred to as a decoupling capacitor) is and why you need them.
Integrated circuits require a clean power supply to function at peak performance, and any ripple in that power can have a detrimental effect on its capabilities. As the semiconductors in your digital circuits switch merrily back and forth, they can create voltage spikes, upwards of 2 volts peak-to-peak in some cases I’ve measured. That’s noisy. If your circuit has anything with a coil in it, or on it, or even something with a coil near by, you’ll also get noise. Just turn on an oscilloscope without connecting your probe tips to anything and it will measure stray voltages. All of this is noise, and it will really play hell with sensitive circuitry. Bring some chips out of shutdown mode into active mode and they’ll suck the power down right off the rail, causing it to droop through your entire circuit. What do you do then?
The effects of noise on your circuit vary from chip to chip. For example, if you have a chip connected to a crystal, you’re requiring very precise and incredibly fast oscillations to govern the internal timing of the IC. If you start pumping varying voltage into the component through it’s power pin, you run the risk of clock jitter, where the sampling edge of your clock signal is pulled or pushed forward by a few nanoseconds, resulting in inaccurate serial communications.
In the timing diagram above, the data line is trying to communicate the value 0x17, but jitter on the clock has modified the rising edge, clocking in invalid levels.
Another example is the havoc noise can cause with opamps, where any fluctuation on your power rail, will be amplified through to the output signal. You need to make sure that any junk on the rail doesn’t find it’s way through into your amplified signal. Think of it like a flaw on a photocopy. If you keep making photocopies of the photocopies of the photocopies of the flawed original, eventually you destroy what it was you started out with.
Why Add A Capacitor
A capacitor stores electrical energy. When you place it between a voltage source and ground, it charges up at some rate determine by the amount of resistance it’s pulling the electricity through, and the capacitors value. Once it’s full of electrons though, in a direct current circuit, it turns into Mr. Creosote and not even a wafer thin volt will pass through. The capacitor in this case is demonstrating high impedance… it’s impeding the flow of current. It doesn’t matter what size of capacitor we’re talking about, once it’s full, it’s full.
However, when you send an alternating current to the capacitor, it is rapidly charging AND discharging the capacitor and the degree to which it impedes the current flow isn’t constant as it is in a DC circuit. This means that you allow some amount of the fluctuations to flow through the capacitor, reducing their influence on near by components.
This is, in fact, a grossly oversimplified description of signal filtering. In effect though, you’re using a capacitor to filter out the frequencies on the power line you don’t want affecting your chip.
Correctly Sizing and Placing the Bypass Capacitor
Well, there’s bad news and good news.
The bad news is, that if you want to calculate the precise value of bypass cap that you’ll want to use, you’ll need to know a lot about the frequencies your circuit will be generating, the amount of capacitance your board has in general (you’ve got layers of copper separated by fiberglass… it’s basically a giant capacitor in and of itself), and the math behind the reactance and impedance of your capacitor. I’m not saying it’s impossible by any length, just that it would take a bit of research for you to get to the bottom of it.
Firstly, if you’re building a circuit with such wide ranging or nutty frequencies, chances are, you’re not on this page suddenly trying to figure out what sort of bypass cap you need. You’ve already engineering enough stuff that your experience is beyond the scope of this article.
Secondly, if you’re branching past the level of basic circuits and getting into some more advanced components, the manufacturer probably has an example schematic in the datasheet and tells you what value of bypass cap to use. Reason #381 to read those things carefully.
Finally, in most circuits that a hobbyist / maker will build, the frequencies you’re trying to bypass are pretty commonly understood. You’ll be able to get away with using .1µF ceramic capacitors like pixie dust at all the chips on your board.
Placement of the capacitor should be as close as you can possibly get it to the power supply pin of your chip, with as short a trace as possible on the other end of the capacitor to ground.
For a breadboard or through hole board bypass capacitor, make sure you trim the leads on your capacitor as short as you possibly can, and, again, keep it as close to the power pin of your chip as possible, and get it to ground fast.
Finally, in the event of that “power drooping” effect, where components are sucking your power down at start up, you can place a nice fat electrolytic directly across the power rails, preferably as close to the power supply as you can get it so that it can provide a buffer of electrons in that situation. Again, if you need to get specific about the value, then chance are, you already know how to get specific about the value, but a good rule of thumb is a 10µF electrolytic (make sure you orient it correctly because electrolytic capacitors are always polarized components!)
Power Supply Decoupling in Practice
To demonstrate the difference between having the chip connected directly to the power rail and having it decoupled, I’ve taken a simple SN74HC04N IC, a chip with six NOT gates, and hooked each of the inverter inputs up to a 50Hz signal generated by an Arduino. My oscilloscope is measuring the voltage level at Pin 14 of the chip, VCC.
50Hz Clock Signal
// A simple sketch to create a 50Hz square wave clock signal on Digital Pin 2
pinMode(clockPin,OUTPUT);// sets the clock pin as an output
digitalWrite(clockPin,HIGH);// take clock signal HIGH
delay(10);// wait for 10ms
digitalWrite(clockPin,LOW);// take clock signal LOW
delay(10);// wait for 10ms
1. Input Overview
With all the gates happily switching away, I checked the power input pin for the chip, and discovered the plot on the left. It doesn’t look like much at all, really. Since “noise” is really a voltage oscillation, in other words an A/C signal, I’ve “A/C Coupled” the scope, meaning that any oscillations in the signal will move around the middle axis. What I am noticing though, is that I have the trigger level set to 1.3V, and in the upper left hand corner it’s telling me “T’d” — that it’s been triggered, even if I don’t necessarily see it. Time to go deeper…
2. Noise Detail
Tada! There it is. A fat voltage spike nearly 3V peak-to-peak! Remember when we were creating the edge triggered clock signal? We’re in exactly the same time scale now, and oscillating back and forth at levels that qualify as digital high and low inputs. To eliminate this, we need to put a teeny 0.1µF capacitor right at the power pin of the chip, one end connected to your Vcc pin, the other end of the capacitor connected to ground. In fact, I even trimmed the leads of the cap down so that it’s nestled right against the board. This is the funky world of analog electronics now, and things like 3/4″ of extra leg on your components make a difference.
3. Decoupling Capacitor in Place
Whack the decoupling cap in there and look at that. The ripple is entirely gone. I wish I could provide a video of what it looks like on the scope when you put it into the live circuit, because it really does look like magic… one second you’ve got this thing that looks like the Red Bull Rampage course, and then in an instant it transforms into something you could water ski on.