Go Down

Topic: Noise on analog input when using an ethernet shield & external power (Read 2433 times) previous topic - next topic

dps29

Hi folks,

I wonder if anyone has seen this before and has ideas on how to fix or troubleshoot?

I have a set up with an ethernet shield (this one: http://www.oomlout.co.uk/ethernet-shield-for-arduino-updated-p-188.html) and a TMP36 temperature sensor.  I'm trying to report the temperature remotely over ethernet.  I'm using the A5 analog input having read elsewhere that the A0 and A1 inputs have pullup resistors attached in the ethernet shield.

When powered from USB on my laptop, everything works as expected - I see pretty stable temperature values from second to second.

However, when powered from an external 9V adaptor [this one: http://www.oomlout.co.uk/wall-power-adapter-9v-600-ma-p-236.html], the analog input becomes extremely noisy when read with analogRead on the arduino.

I've tried a few debugging steps, here's what I found:

I have metered the Vcc and signal levels with a multimeter in both scenarios and they are both very stable, including under load when I make an HTTP request to the device.  I also tried printing out a value read 500ms in the past in case the act of serving an HTTP request introduced the noise, but this shows just as much noise in the externally powered setup.

Has anyone seen this before or able to suggest the next step in debugging?

MarkT

A multimeter won't show you the noise from the power supply.  Its a switch-mode supply so its bound to be noisy.  I'd try adding a 5V regulator with lots of decoupling (0.1uF ceramic, 10.0uF ceramic and 2200uF electrolytic say) on its output and put that between the PSU and Arduino and see if that improves matters.

A quick test would be to just add more decoupling from Vcc to Gnd, and also from Vin to Gnd - an external regulator might be overkill.

Are you sure its not just the ethernet shield that's the problem though?  You aren't clear whether its also present in the USB-powered setup.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

dps29

Thanks for the advice, Mark.  The ethernet shield is present in the USB setup so hopefully we can reject that as the source of the problem.

I'll add some decoupling between Vcc and GND and the signal and GND right now to see what difference it makes.  I should have mentioned that the Arduino board I'm using is an UNO.  I guess you're saying that the on-board regulator still leaves a very noisy 5V with a switch-mode supply!

dps29

I added a 220uF electrolyic [all I had to hand] from Vcc to GND near the TMP35 and that has significantly improved matters, so looks like this is exactly the right answer - thanks!  Will add more when I manage to strip some caps off another project.

(you can see the values its reporting at http://dsarduinolab.appspot.com/?q=ds0_temp if you're interested :-) )

MarkT

Another simple tweak that might help is to add a ferrite toroid on the +ve wire from the psu - you might find one of these on an old USB cable.  You can wrap the wire through it several turns to increase its low-pass-filtering effect.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

dps29

Thanks for the tip!  The power supply DC cable had a ferrite core on it already (near the plug), but I've added another.  Hard to say if it's made a significant difference, I'll produce some graphs once I have a bit more data.

MarkT

No, not on the whole cable, just on the positive supply wire.  That common-mode suppressor won't stop differential noise.  An RF choke would also do if you have one lying about (less likely?).
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Magician

I my project, when I try to read 64 measurements analog inputs on an(0),
some data were lost. Dont know why.
But what I'm saying , direct access to ADC solve a problem.:
ADCSRA = 0x87;
  // turn on adc, freq = 1/128 , 125 kHz. 
  ADMUX = 0x60;
  //Bit 5 - ADLAR: ADC Left Adjust Result
  ADCSRA |= (1<<ADSC);
  //   while((ADCSRA&(1<<ADIF)) == 0); //Discard first conversion result.
  while(!(ADCSRA & 0x10));

  for(i=0; i<N; i++ ) {
    ADCSRA |= (1<<ADSC);
    //   while((ADCSRA&(1<<ADIF)) == 0);
    while(!(ADCSRA & 0x10));

    x = ADCL;
    x += (ADCH << 8)
  } 

There is book , that would be helpful in you project:
"C Programming for microcontrollers", by Joe Pardue.

Go Up