Why does ADC noise increase when I add a cap?

Hi All

I wrote a little sketch to characteize the ADC on my Nano 3.1 and got lots of data similar to:

  adcsra=11000111    dT1=112  min=529  avg=532  max=534  var=2  bins=[24 35 65 66* 47 19 ]
  adcsra=11000110    dT1=59   min=529  avg=532  max=535  var=2  bins=[15 35 68 71* 42 24 1 ]
  adcsra=11000101    dT1=32   min=527  avg=532  max=536  var=2  bins=[1 1 18 35 81 59* 28 30 2 1 ]

256 samples read as fast as possible with a shorter integration time each cycle. "bins" is a pseudo histogram.

Overall pretty cool. Not much hit from a 32 usec integration time vs 112 usec.

This is all on a solderless breadboard with long wires etc. so I added a 1 uF cap between the IO pin and ground and got:

  adcsra=11000111    dT1=112  min=521  avg=532  max=543  var=75  bins=[1 31 44 30 13 5 0 0 0 0 0 0* 1 1 0 1 1 4 17 41 38 20 8 ]
  adcsra=11000110    dT1=59   min=521  avg=532  max=543  var=75  bins=[7 22 46 36 14 4 1 0 0 0 0 0* 0 0 0 0 1 4 15 44 37 23 2 ]
  adcsra=11000101    dT1=32   min=521  avg=532  max=544  var=76  bins=[14 21 40 40 9 1 0 0 0 0 0 0* 0 1 1 1 1 3 14 57 26 24 2 1 ]

Yuch!

What happened?

Thanks
Doug

What do you have connected to the pin that you are measuring?

The ADC pin (PC7) is connected to a 10k pot twixt Vcc and ground. I'm not using any noise cancelling/reducing, just a plain read.

It takes about 40mS to charge the cap thru 5k so there will be a lag as you turn the control or after power on. Even a variation of 5 seems kind high to me, so I'm not all that impressed with the first set of results before the cap.

Hi afremont

The analysis runs in a continuous loop (as opposed to the other kind :slight_smile: and cap-in / cap-out give the same (different) results, so I don't think it's that kind of time/charging thing.

I'm curious why the bi-modalism, too. That must be a clue, right? :smiley:

Like I said, your first set of samples seem kind of noisy to me. The oscilloscope is the only way to really find out what's going on.

I'm more concerned about your second lot of samples. That looks seriously dodgy.
Are the high and low samples alternating ?

I'm not sure what effect you are trying to achieve with the 1 uF cap. That's rather large.

I put some caps on the input of my ADC to help with the current when the analog source had a high impedance
( and also a very low rate of change ), and I was using 2 nF and 10 nF.

What is your arduino powered from? What reference are you using?

Do you have anything else connected to Arduino ground? If so, you may get better results if you use one of the Arduino ground pins to connect the ground side of the capacitor and the ground end of the pot, and the other ground pins for connecting everything else that needs to be connected to ground.

Hi! Sorry for the lag. I'm getting over a lousy cold and the things put off thereby.

The Nano is powered by the USB and the pot by the +5V (really about 4.5V) supply on the Nano. The cap goes directly from PC7 to Gnd. Well, the columns(?) on the breadboard, of course. (The cappot was originally powered by the +5V buss powered by the nano +5V but even when I de-powered the breadboard and ran a wire directly to the pot, the noise remained.)

ADC ref is Vcc. I can see the full 0-1027 range from 0V-Vcc.

The 1 uF cap size was to see what would happen. I'm still rather NEWB! to the whole bypass cap thing. Also it seemed about the right choice for the 100kHz - 10MHz regime I expected for the noise.

My scope (C. Zeitnitz's cool soundcard oszilliscope Soundcard Scope) doesn't show anything that I can interpret. I mostly use it as a logic analyzer/timing checker.

Thanks for the interest. I'll get back to something more systematic in a day or two.
Doug

Oh well. It looks like I've got more problems than a perplexing cap.

My multi-meter shows 35 mV DC & ~0 AC between USB ground and soundcard line-in ground with both cables un-attached (plugged into the PC of course). When I plug in the USB cable to the Nano and leave the audio cable unplugged it shows 75 mV DC and 15 mV AC. In both cases the audio ground is lower than USB ground.

15 mV AC (approx rms) works out to about +/- 4 LSBs p-p which is what I often see. So hmmmm.

I'll have to chase down these problems first then see what the cap does.

Thanks
Doug

So, it's easy. ADC is measuring the ratio between its reference and the signal. When you have just the pot, the noise from the power line is in both signal and reference, so it is effectively cancelled out. But when you connect a cap across a pot, you filter away the noise from your signal while still having the noise in reference, so you get noisy results.

Try changing the reference to internal bandgap one. Or power your arduino from a low-noise external power supply (usb port of a computer isn't low noise).