I'm reading this great book (AVR Programming: Learning to Write Software for Hardware by Elliot Williams) and setting up my arduino atmega328pu, usbasp programmer and using avrdude to program the chip.

The book shows the following setup to power the chip off the computer's USB port via the USBASP programmer. power from usbasp

The author explains that you should use a 100 nF (0.1 µF) across the VCC to ground to smooth the voltage.

How is that value (100 nF (0.1 µF)) calculated or determined? I know 5V is coming off USB port of computer and I'm wondering how that factors into the calculation.

What Does That Do?

Does that basically "short" certain voltages directly to ground -- when voltage spikes?

Part 2 : A Similar But Different Example

There is also a similar set up of a mintduino but the author is using a 9V battery so the voltage is different but in that case the writer/experimenter shows it hooked up like the following*:

mintduino setup

Of course you can also see that this experimenter is setting up the atmega328 to use an external crystal (16 MHz) but he uses two smoothing caps of 22pF and he puts one serially on each pin (XTAL1, XTAL2), each connecting back to ground.

Basic Explanation?

Can someone provide a bit of an explanation of how these are similar or different?

General Formula?

Can someone provide a general formula for calculating the cap values I should use in instances where the voltage is different?

*You can see the entire mintduino article at: https://makezine.com/projects/build-a-mintronics-mintduino/

  • 3
    \$\begingroup\$ Where did the value 100 nF come from for bypass capacitors and....Load capacitors on a crystal \$\endgroup\$ – Andy aka May 25 '18 at 21:12
  • \$\begingroup\$ @Andyaka Ok that is good information. It's somewhat of a known convention that has been worked out over time (first link). I will read the info at the links again more closely. thx \$\endgroup\$ – raddevus May 25 '18 at 21:45
  • 1
    \$\begingroup\$ It's worth mentioning that that 0.1μF is just a recommendation. With power supply smoothing capacitors, it doesn't usually matter what precise value you use, as long as it's large enough. Now, I don't know as much about crystal oscillator capacitors, but those values tend to be important, and using capacitors too different from the value specified changes the oscillation frequency. \$\endgroup\$ – Hearth May 26 '18 at 15:50

The supply bypass capacitor should be low impedance at MHz where the chip introduces or responds to noise. Now at (say) 50MHz, a perfect 100nF (0.1uF) cap has an impedance of \$X_C = \frac{1}{2\pi fC}\$ = 14m\$\Omega\$. Typically the power supply regulator can respond well up to perhaps 250kHz, where Xc = 6\$\Omega\$, so a 50mA spike will cause a drop of less than 0.3V. It would be better to have a larger reservoir capacitor somewhere to take care of these spikes but the 100nF will deal with high frequency spikes from the chip (if the bypass capacitor is further away there is series inductance that will increase the voltage drop). In earlier days 0.01uF was easier to get in disk form and that was the popular size (with a large, perhaps electrolytic or tantalum, capacitor mounted somewhere on the board). Now it's just as easy/cheap to use 0.1uF.

Load capacitors on a crystal are another matter- they are calculated from the load capacitance specified for the crystal (and they have to be acceptable to the chip). If the rules are not followed, the oscillator may be slightly inaccurate. If the capacitors are way too big or too small, the oscillator may not start properly under all conditions.

If the crystal is specified for (say) 18pF load, the load capacitors are 2* Cload - Cstray- Cinput, so perhaps 27 or 33pF.

Connecting the caps as shown from Vcc to GND is not generally done. It might help a bad design to start, but it will could cause unreliable operation and excessive jitter if there is much noise on the power supply.

  • \$\begingroup\$ Great info on the smoothing cap from the first example on the breadboard. Thanks for the additional illumination. \$\endgroup\$ – raddevus Aug 6 '18 at 21:18

I found a definitive answer in the Atmega328p complete data sheet (starting at bottom of page 50) so I thought I'd post it here for future reference.

Low Power Crystal Oscillator

Pins XTAL1 and XTAL2 are input and output, respectively, of an inverting amplifier which can be configured for use as an On-chip Oscillator, as shown in the Figure below. Either a quartz crystal or a ceramic resonator may be used. C1 and C2 should always be equal for both crystals and resonators. The optimal value of the capacitors depends on the crystal or resonator in use, the amount of stray capacitance, and the electromagnetic noise of the environment. Some initial guidelines for choosing capacitors for use with crystals are given in the next Table. For ceramic resonators, the capacitor values given by the manufacturer should be used.

capacitor table


General formula: The arudino can be thought of as a switching load. Why? because millions of transistors can switch on or off all at the same time. The two cases we are most concerned about are the minimum and maximum case when the processor is drawing min and max current.

For example, if we know the arudino draws 0.5mA when it's doing nothing and 30mA max, this would be like having a 6600Ω resistor on all the time (for a minimum current) and a 110Ω resistor when it's drawing max current.

The interesting thing is the cable is the reason why we have to have a power filter capacitor, because it has inductance and the cable can't source all of that current instantly. (if we had a super conducting cable with no loss or inductance to the power supply, we wouldn't need filter caps at all).

Because the cable takes a while to source power, we need to store it locally in a capacitor. In general this can be calculated, but you'd need to know the inductance of the cable, the power supply's source inductance and resistance. The inductor resistor and the load can be modeled as an RLC circuit. The easier thing to do instead of measuring or estimating the cable resistance, is to switch out capacitors and measure the ripple with a volt meter.


simulate this circuit – Schematic created using CircuitLab

The other example is an oscillator circuit:

Basic Explanation? Can someone provide a bit of an explanation of how these are similar or different?

The capacitors are for tuning the resonant point of the clock crystal, they are different. The capacitor values are very low in the pF range and depend on the value of the resonant point of the crystal, they form a resonant circuit with the crystal.

General Formula? Can someone provide a general formula for calculating the cap values I should use in instances where the voltage is different?

There isn't really a formula, there are tables, but the best place is to look in the datasheet of the microprocessor, because the drive circuitry is slightly different between microprocessors.

enter image description here Source: https://www.electronics-tutorials.ws/oscillator/crystal.html


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.