Author Topic: Explanation for decoupling capacitors.  (Read 2553 times)

0 Members and 1 Guest are viewing this topic.

Offline ghani256Topic starter

  • Contributor
  • Posts: 15
  • Country: pk
Explanation for decoupling capacitors.
« on: September 04, 2017, 03:43:24 am »
For the longest time I have been instructed to put on 100nF decoupling capacitors between the VCC and GND pins whenever I lay out a board involving an MCU. I could not find the exact reason as to why they are needed. However, after some research online I did find a few reasons for their use. Below I explain the main reason, as I understand it, why decoupling capacitors are needed. I would like some feedback and would also like to know if this explaination is satisfactory or not.

Consider a pin of an MCU which has a single LED connected to it through a resistor. Lets say that the pin toggles from low to high, that is it turns the LED on. Now with the LED on, it will draw current which the MCU will have to provide. In return, the MCU draws more current (i.e power) from the power supply i.e. its VCC and GND pins. However, a sudden current draw by the power pins causes a voltage drop across the resistance of the power traces. Since the power supply is slow as compared to the microcontroller, it senses the drop in voltage after a little time and then changes the voltage back to its constant value again ( since it is to behave as a constant voltage source). That is where the decoupling capacitors come in. Whenever the MCU draws in a current pulse, the capacitor makes sure that the voltage across the power pins remain essentially constant till the power supply voltage stabilizes again.

That is all I have understood. Now I do not know how to calculate the exact value of the decoupling capacitor but have been told that 100nF or any value in that neighbourhood is pretty safe to use.

I am waiting for your comments.
 

Offline stmdude

  • Frequent Contributor
  • **
  • Posts: 479
  • Country: se
Re: Explanation for decoupling capacitors.
« Reply #1 on: September 04, 2017, 06:15:00 am »
@evb149 Nicely explained. I have nothing to add. :)

Dave actually did a whole video on this subject, and covers all these points.


As for anecdotes, I can tell you that sh*t gets unstable real quick if you design a PCB with an MCU and don't do decoupling "because you have a really nice powersupply". Yea, that was my very first PCB. ;)
 

Offline cellularmitosis

  • Supporter
  • ****
  • Posts: 1112
  • Country: us
Re: Explanation for decoupling capacitors.
« Reply #2 on: September 04, 2017, 07:17:07 am »
(Disclaimer: I'm just a hobbyist)

Practically, I think the reason for specifying 100nf (as opposed to some other value), was that it was the largest value ceramic cap available back in the day.  The 100nf ceramic cap was a "perfect storm" of being cheap, robust / long lasting, high performance, and enough capacitance to do the job.

Nowadays, you can easily find larger value ceramic caps, but 100nf works well enough so it sticks with us.
LTZs: KX FX MX CX PX Frank A9 QX
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22435
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Explanation for decoupling capacitors.
« Reply #3 on: September 04, 2017, 07:55:22 am »
The stray inductance of the power supply traces is far more significant than their resistance, but that is generally the right idea, yes (substitute "resistance" with the more general "impedance").

The problem is also that, the microcontroller is able to deliver that voltage and current in a couple of nanoseconds.

This launches a wave down the driven pin, and the supply pins.  The wave carries voltage and current with it, causing the pin voltages to change.

Later in time, the waves reflect off things, and return to the pins.  If the wave comes back in phase, the returned voltage opposes the initial change, and voltage bounces back up to nominal.  If the wave comes back out of phase, or gets mostly absorbed (as we prefer for signal traces), the pin voltage swings all the way, and a nominal current flows (including zero current).

Bypass capacitors have a low impedance, so the wave reflects off in phase.  This is good for power supply traces.

Resistors tend to absorb waves, and open circuits reflect waves out of phase.  This is good for signal traces, where we don't want ringing.

Now, "a few nanoseconds" is 10s of cm at the speed of light, so it takes quite a long trace to not have immediate reflections.  This is good, because a transmission line doesn't have very low impedance, that is, it allows the supply voltage to drop too much.  (Typical PCB traces are around 100 ohms, meaning, as long as the wave is still going down the trace, the ratio of V/I for that wavefront is 100 ohms.  This is easier to see with a spool of coax cable and a very modest oscilloscope, and not so easy to see with short traces on a PCB!)

So what actually happens is, while the wave is being launched (during those few nanoseconds), it immediately comes back (fractions of a nanosecond, for most PCB trace lengths)), reflecting off whatever terminates that trace length.  It's less like a wave of water rushing down a canal, and more like filling a bucket.  The bucket still starts filling from one side, and there's some sloshing, but overall it mostly fills up evenly.

So the waves coming off an MCU aren't really fast enough to cause problems with most PCB trace lengths, which is good: that means the trace impedance will never be ~100 ohms, but always closer to the impedance at lower frequencies, or at DC.

What to take away from this?
- The longer a trace is, to any pin, the more troublesome it can be.  Keep supply traces short, and place bypass capacitors often.  (Alternately, don't use traces: use a 4-layer board with inner GND and VCC planes.  You need very few bypass caps on such a design!)
- Signal traces have to be modestly long (10s of cm) to have signal quality problems.  If you encounter this problem, add a resistor, preferably near the driving source.  47 ohms is enough for starters, but you can always go higher if you can tolerate a slower risetime, and don't need to draw much DC through the pin.  (What about LEDs?  Place the current-limiting resistor near the MCU, of course!)
- Trace impedance is in the ballpark of 100 ohms.  This isn't very useful directly, if the traces are short -- but we can approximate a transmission line as an inductor or capacitor when things are going relatively slowly around them.  And whenever you have capacitors and inductors, you have time constants, resonant frequencies, and yes, you still have impedances.
- Equivalent inductance of a trace is proportional to length.  What could be simpler?  It's around 4 nH/cm.
- Anywhere you have inductors and capacitors (like the power supply network -- a chain of traces and bypass caps!), you have a characteristic impedance, Z = sqrt(L/C).  To avoid resonances, add resistance to the circuit, of a similar value.  Now, you can't simply short-circuit a supply with, say, four ohms, at every end point -- that would be ridiculous!  But you can "cap couple" it in, by using a larger capacitor, with that resistance as ESR.  This dampens the network and you get really solid power to all your devices!
- For most things, the required impedance is not very low.  MCUs in light duty, op-amps, stuff like that, may be fine with impedances in the 10s of ohms.  With harmonics up to a few hundred MHz, you can afford several cm of trace length!
- Heavier duty things need lower impedances.  MCUs doing a lot of switching, on a lot of pins, need a bypass near each supply pin.  Bus drivers, gate drivers and switching power supplies need even lower impedances (often, under an ohm).  (Beefy loads (high power CPUs, FPGAs, etc.) need even lower impedances, and can operate at stupendous frequencies (GHz!), but don't worry, you don't have to go /quite/ that high on your PCB design: they actually put onboard bypass caps on those chips, because there's simply no way you could deal with it at the board level.  You still need a low impedance on the board, but only out to 100s of MHz, not GHz.)

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: cellularmitosis


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf