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.
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:
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.