Why a loop of analogRead() produces a certain voltage ain pins ?

Hi, I have a problem when trying to read the analog values at an analog pin (namely A0) using a loop of analogRead(). As I observed on my Oscilloscope , there is some voltage produced at the analog pin every time I use analogRead() for reading the value.
And the amount of voltage increases as the number of repetition increases.

Does any body know why? And how to prevent it ?

Thankss

Does any body know why? And how to prevent it ?

This is because the internal multiplexer is being connected to the input of the sample and hold circuit.
If you actually put a real impedance on this pin instead of letting it float it would not have any effect.
Take your measurements with a 10K resistor connected from the input to ground.
This is not a fault, it is the way it works and you will not see this using a real input.

Hi every one, first of all I apologize for my bad English, :blush:

I have a similar problem:

I'm trying to read 3 analog channels I'm using the basic following sketch:

void setup() {
  Serial.begin(9600); 

}

void loop() {
  analogReadResolution(12);
  Serial.print(analogRead(A0));
   Serial.print("            "); 
  Serial.print(analogRead(A1)); 
   Serial.print("            ");
  Serial.println(analogRead(A2)); 
  delay(100);
}

but If I connect A0 to v 3.3 (through a resistance) and A1 and A2 to the GND

the serial print return 4095 4095 4095 instead of 4095 0 0 (or something similar):
always seems to repeat the value of A0 for A1 and A2.

the same sketch works on Arduino uno using 8-bit channels, but I need 12-bit!!

Is it a problem of my board? or I'm doing something wrong?

Thanks!

the same sketch works on Arduino uno using 8-bit channels,

So what board is this on?

If you are using a Due, then check this link
http://forum.arduino.cc/index.php?topic=242867

The board is Arduino DUE, I'm looking at the link but the solution is not easy :cold_sweat:

What is not easy about reading a channel twice?

It is easy to do, but it doesn't work :~

fadeluca:
the serial print return 4095 4095 4095 instead of 4095 0 0 (or something similar):
always seems to repeat the value of A0 for A1 and A2.

Previous versions had bugs like this - which version of the Arduino software
are you using?

Previous versions had bugs like this - which version of the Arduino software
are you using?

The arduino 1.5.5 Beta.

I'll try with 1.5.7

problem solved ... all the fault of the old 1.5.5 software! (now it works with 3 channels) :slight_smile:

Its beta software - you read the release notes and keep upto date with fixed versions!

Hi, I'm using Arduino Due and software 1.5.7 . Every time I read the analog voltage at an analog pin in a loop ( just at one Analog Pin, no witching between the analog pins), it produces an internal voltage (observed on oscilloscope) although I had connected the analog pin with a real impedance. This cause errors for my reading voltages.

Can someone help me to overcome this problem ?

Can someone help me to overcome this problem ?

Well only by lowering the impedance. These are the shots I got.
With the first one I had a 10K from the analogue input to ground, and the second I had a 220R to ground.
It has not eliminated it but it is considerably reduced.

Thats probably fine, you are adding extra capacitance with the scope probe,
the converter should be allowing enough tracking time if its set up correctly
and should perform fine.

Are you using x10 probe BTW? Its never good to load a circuit with x1 when
x10 is available.

Are you using x10 probe BTW?

Please.
What do you take me for?

Thanks alot Grumpy_Mike.

That's exactly what I'm looking for. Thanks again

I thought the analogue read speed had changed since I first mentioned it so I went back to 1.5.3 and ran the test again. There is the same pulse but there is also a secondary pules. Again terminated by 10K and then 220R.
Notice the 220R pulses are smaller with the older software. So there is definitely something going on with the software that is affecting this.