inconsistent readings from analogRead()

Greetings Everyone,

I have a project in which I’m using the Mega 2560 in combination with the motor shield to position two linear actuators based on some calculations. This is for a solar tracker where azimuth and elevation calculations are done at 5 second intervals. Right now I’m just working on the azimuth portion. My actuator has a feedback mechanism consisting of a 10kohm potentiometer. I’m using the 5V from the Mega as the reference voltage across the potentiometer and I have the wiper of it connected to analog input A0.

I’ve noticed that I get inconsistent readings when performing an analogRead() of the pot even though the actuator is at the same position-i.e., fully retracted so that the wiper voltage should be close to the reference, usually about 4.81V. The last time I attempted to do this the voltage reading from the analog input was 2.82V when fully retracted. I disconnected the pot from the analog input and measured its voltage at 4.81V. My question is why is this happening? I would expect this to be a high impedance input when configured as such so am confused as to why it should be dropping so much voltage. I’m also using the analogRead() to monitor the reference voltage across the pot and this stays very near to 5V.

Thank you in advance for any insights or thoughts you could offer on this.

Tony

Bad contacts?

2.82V is somewhere in the middle which could indicate a floating line...

Furthermore as you know approx what value to expect, you can adapt your code to ignore outliers, e.g. do a resample. But that would be a workaround.

No chance of interference on the potentiometer wiring? Is its wiring shielded?

Are you using analogRead for anything else? As the analog pins share a single A2D, rapid use of it can cause the previous read to impact the next. A common workaround in this situation is to read twice on each input, ignoring the first.

That precaution is only needed if the source impedance is greater than 10k, its due to the pre-charge time of the ADC sample/hold capacitor.

Good engineering practice would require a voltage follower to eliminate any loading by the A/D input and NO re-use of the 'critical ?' A/D input. IMHO

Doc

Good engineering practice is read the datasheet rather than use guesswork.

I did customer service for about 15 years and the most used comment was RTFM... Read That Fine Manual...

Doc

MarkT:
Good engineering practice is read the datasheet rather than use guesswork.

Though to be fair, some datasheets are easier to parse than others. I'm still scratching my head over the TI ADC I'm using re: differential vs. unipolar mode, the datasheet made the differences between those modes a lot harder to understand than was necessary, IMO.