Computing stuff tied to the physical world

Messy signals

In Hardware on Dec 16, 2011 at 00:01

Digital circuits work with 0’s and 1’s, right?

Well, yes, but that doesn’t mean the analog voltages and currents are necessarily very “clean”. To fabricate a somewhat extreme example, I connected a JeeNode without regulator and without 10 µF capacitor to a 3x AA battery pack, and made it run this simple loop:

Screen Shot 2011 12 01 at 17 07 09

Sleep for 3 seconds, then send an SPI command to the RFM12B wireless module. Note that the RFM12B is not set to receive or transmit mode – the ATmega just sends it 2 bytes over SPI.

Let’s look at the variation in voltage and the current consumption (this shows the benefit of an MSO, BTW):


The ATmega wakes up, sends four 16-bit commands over SPI (the compressed timeline is a bit misleading) and powers off again. The whole process takes less than 200 µs. The four SPI transfers are: wake up the RFM12B, send it the 0xFE00 soft reset, and then two more to send the RFM12B back to sleep. You can even see the ≈ 0.6 mA baseline increase while the RFM12B is awake and idling. The SPI bus runs at 1 MHz in this example i.s.o. 2 MHz, because the ATmega is running off its 8 MHz internal RC oscillator, but the sketch was compiled for 16 MHz.

The current spikes are not so important. It’s normal for switching signals to consume relatively much energy (that’s why turning off the clock saves so much power). The problem here, is that these current fluctuations have such a large impact on the supply voltage – one of the spikes causes the supply to briefly drop more than 0.25V!

This is why “decoupling” capacitors are used around digital chips, even a lowly ATmega consuming just a few milliamps (it’s running at 8 MHz here, BTW). There is a 0.1 µF cap on the JeeNode board, but it’s not enough.

Here’s the same circuit, with both signals in close up:


Nasty stuff. I’m not 100% convinced that the real waveforms look exactly like this (the scope and probe might be distorting it a bit), but there’s no question that each SPI pin change has a substantial impact on the supply rail.

Here’s the same, with a 0.1 µF capacitor added near the battery pack:


And with a 470 µF electrolytic cap (both showing just the scope’s measurement results):


Note that the 0.1 µF cap has much more effect, relatively, than the 470 µF one. It’s better for HF noise reduction.

Does it matter? Yes, probably. Although all these setups work fine, the variation in voltage is fairly large, and could cause problems when operating at lower voltage levels, nearer the specified limits. Also, such currents might generate a fair bit of Electromagnetic Interference (EMI).

By adding more capacitors very near to the power consumers, i.e. the ATmega and RFM12B, this can be reduced. Such decoupling capacitors will act like little charge buffers, helping the supply cope with such sudden changes.

There’s much more to it than that (there always is). At switching frequencies of 1 MHz and above, the impedance of a wire starts to matter a lot. In fact, it’s amazing that digital circuits work at all – even without any HF design!

I’ll investigate further, but for now just remember: when in doubt, add caps … everywhere.

  1. << I’m not 100% convinced that the real waveforms look exactly like this>>

    The 20Mhz ‘scope filter was active? ;-)

    • Not in the 2nd screenshot (see the “BW” tag in the first one). I did set the input filter to 50 MHz (don’t remember why). The probes are good, BTW – even the 70 MHz model comes with 250 MHz probes.

      I’ll redo this measurement when the 200 MHz scope comes in.

  2. becareful, when you works with radio transmitter and scope, sometimes you can see HF reradiation in your scope probe…

    A jeenode is too small for being impacted by HF rules design (no data bus with high speed signal, no vidoe/audio signals, …), but you can have some problems with USB and Ethernet shield! You may . Have to check signals impedance. Your antenna stripline may also be impacted but it’s too short on a jeenode to be influent.

    You are starting to touch some HF rules design ;-) Another fun 10,000 hours (or not…) ;-)

  3. And beware of through the hole caps. If you look at the leads’ impedances, you soon discover that 100nF through the hole ceramic capacitor can have self resonant frequency close to 1 Mhz or lower!

    Which means.. if you operate at higher speed, it is actually making things worse (acting as a an inductor instead). SMD is much better here, closer to the IC, shorter connections…

  4. Good point – always worth a read of the spec sheet and look for the “insertion loss” graph. With careful selection, 10Mhz or better is not hard to find in thru hole packaging; a lower capacitance value to get a higher cutoff frequency works.

    SMD multilayer can be effective into the Ghz region – see them liberally sprinkled around your favourite INTEL/AMD power hungry CPU chip.

Comments are closed.