Go Down

Topic: inconsistent readings from analogRead() (Read 23209 times) previous topic - next topic

TonyL

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

robtillaart

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.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

MarkT

No chance of interference on the potentiometer wiring?  Is its wiring shielded?
[ I won't respond to messages, use the forum please ]

wildbill

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.

MarkT

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.
[ I won't respond to messages, use the forum please ]

Docedison

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
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

MarkT

Good engineering practice is read the datasheet rather than use guesswork.
[ I won't respond to messages, use the forum please ]

Docedison

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

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Constantin


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.

Go Up