ADC channel getting affected by another?

I am using 2 analog channels on the Arduino Nano.

A0 → LM35
A2 → 220K pot

the pot is connected as usual with 5V and GND at its ends and the center given to A2. What I observe is if the pot is set to 0V then the readings on channel A0 are quite stable, I mean I get stable temperature readings of the LM35. However if I set the pot on anything apart from 0 then the readings on A0 start to dance I mean get a variation of above 10deg C in the temperature readings of the LM35.
Is this a known issue when one channel affects the other.

The code that does the conversion is as under

  // read LM35
  temp = analogRead(tempPin);
  temp = temp * 0.48828125;

  Serial.print("TEMPERATURE = ");
  Serial.print(temp);
  Serial.print("*C ");
  Serial.print("SP = ");
  Serial.print(setPoint);
  Serial.println();
  
  // read pot
  pot = analogRead(potPin);

Change the ADC’s reference to 1.1V INTERNAL – analogReference(INTERNAL). The new formula would be: temp = temp*0.107421875.

There could be some improvement because of good technical reason!

GolamMostafa:
Change the ADC’s reference to 1.1V INTERNAL – analogReference(INTERNAL). The new formula would be: temp = temp*0.107421875.

There could be some improvement because of good technical reason!

That’s a great idea, however I also have a pot wired upto A2 analog input and the Vcc to the pot is 5V. Is that 1.1V reference also available at a pin to power up a pot?

Try putting a dummy read before each real read to give the ADC hold capacitor time to settle after switching ADC channels:

  // read LM35
  int dummy;
  dummy = analogRead(tempPin);
  temp = analogRead(tempPin);
  temp = temp * 0.48828125;

  Serial.print("TEMPERATURE = ");
  Serial.print(temp);
  Serial.print("*C ");
  Serial.print("SP = ");
  Serial.print(setPoint);
  Serial.println();
 
  // read pot
 dummy = analogRead(potPin);
  pot = analogRead(potPin);

The output impedance of any circuit that provides input to the A/D should not exceed 10k ohms. Your 220k pot is just a bit outside the spec.

A 220k pot is fine, as long as you also add a 100n cap from analogue pin to ground.
So the A/D has a solid voltage to sample from (the cap, not the pot).

Reading the pin twice after each other (no delays) could also improve things.
The code will use the more stable second reading.

Not easy to get a constant voltage device (LM35) and a constant ratio device (pot) to both read accurate with the same Aref settings. Dump the LM35, and use a DS18B20.
Leo..

mstanley:
The output impedance of any circuit that provides input to the A/D should not exceed 10k ohms. Your 220k pot is just a bit outside the spec.

Yes even I thought so in the beginning then I found

https://brainy-bits.com/blogs/tutorials/potentiometer-values

and its seems it should be ok

The youtube video does not address crosstalk.
Crosstalk between A/D channels is the reason why the impedance of the source needs to be <=10k.
Leo…

outsider:
Try putting a dummy read before each real read to give the ADC hold capacitor time to settle after switching ADC channels:

  // read LM35

int dummy;
 dummy = analogRead(tempPin);
 temp = analogRead(tempPin);
 temp = temp * 0.48828125;

Serial.print("TEMPERATURE = ");
 Serial.print(temp);
 Serial.print("*C ");
 Serial.print("SP = ");
 Serial.print(setPoint);
 Serial.println();

// read pot
dummy = analogRead(potPin);
 pot = analogRead(potPin);

That's an amazing suggestion!! and that did the trick' I'm getting stable readings on both analog channels. So the root cause of the problem was that the analog channel was not having enough time to settle? right?

Wawa:
The youtube video does not address crosstalk.
Crosstalk between A/D channels is the reason why the impedance of the source needs to be <=10k.
Leo…

Agreed! Thats food for thought!!.. and thanks for your other post as well it definitely helped!!

I just did the same experiment with the same code.
I connected a 500k pot to A2, and turned it to the center position.
(actually a voltage divider with two fixed 270k resistors).

I got an A/D value of 506-507 from A2 when the other three inputs were connected to ground.
And a jumping value of 513-520 when the other ones were connected to 5volt.

The value was a solid 511, both situations, when a 100n cap from A2 to ground was added.
Leo..

Breadboards add significant capacitance to any circuit. That is why the A/D worked when those high-value pots were being tested. So just be careful. If you want to install those pots, or high value resistors, onto a breadboard you will still need to add a capacitor.

Well as I remember, my suggestion came from good 'ol Wawa. :slight_smile: