I am having a problem with a nonlinear output on my Arduino Mega2560. See the attached picture for a graph of the output vs. input. At around 3.3V, the output of the ADC plateaus to about 687. Here are a few things that I have checked:- The AREF is set to 5V using the:

analogReference(DEFAULT) command, and probing the AREF pin confirms this (it's at 5V).- I've tried using different analog inputs with varying results - one of them plateaus at a higher voltage.- I've tried using a new Arduino Mega board.

Has anyone else had similar issues with the ADC? If you have a suggestion for me, that would be great.

Without knowing the circuit you're using to drive the pin nor the way you are measuring the voltage it's impossible to say anything useful. Do you use 3.3V for any part of the circuit, it looks suspiciously like something is limiting the voltage to the pins. Full code is useful too.

robtillart: uncommenting that line yields the same results. The voltage on the AREF pin also remains the same.

MarkT: The input to the analog reference comes from an op amp, in voltage follower mode. (I'm just using it as a buffer). I've checked the voltage into the analog input while varying in the input voltage, and everything is linear there. The original graph I posted actually has the voltage into the analog input in the x-axis. All of my logic is 5V, however I would have to agree with you that something is suspicious with the 3.3V - nothing is ringing a bell for me.

Below is the code. I'm going to break it into two sections to make it easier to understand. This first part contains all of the configuration of the Arduino. Note there are a few lines "pinMode(AXX, INPUT);" which are commented out. I've tried with and without them with no success.

Sounds like we need to know a lot more about the circuit - several opamps, not clear what values are getting to AREF, we don't really know what you were plotting against what and you haven't posted the code that prints out the analogRead() values - you have several unexplained constants in the code that might mean you are not printing out the straight output from analogRead() ??

In general it pays to post the whole code and the circuit, rather than describe them in words, saves a lot of guesswork and questioning. The problem may not be where you think it is, thats often the nature of problems...

I apologize for not posting sooner. Last week I discovered the mistake lies on my end - I was getting a nonlinear output from the Arduino when I had my op-amp plugged into it because the op-amp was not powered :~. I was tricked into thinking it was working since it would provide a nice linear output for the low end of the scale. The op amp is part of a larger power management board that I am working on, and I just forgot that I did not populate the jumper which would connect the 5V Arduino supply to the 5V rail of my power management board.

Thanks for replying to my post! It helps a lot just to say some things out loud to figure out a problem.