Is the A/D linear?


I own an arduino nano and I have a problem with my A/D converter.

I use external reference which is 3.3V and I’m reading data from an accelerometer. When it is in horizontal position, the x axis gives an output of 1.66V (measured with a voltometer) and that means that I should get a value of 512 from the A/D converter, right? Instead I’m getting 590. I tried out of curiosity to connect ground and 3.3V to the analog pin and I get 0 and 1023 respectively. So upper and lower limits are correct.

Does this mean that the A/D converter is not linear? Is there a way to make it linear? Am I doing sth wrong?

The A/D converter is supposed to be linear. How accurate is your voltmeter, do you think?

Well… I get a correct measurement for 3.3V from a 3.3V regulator and the accelerometer’s data sheet also says that I should get 1.66V if the sensor is horizontal. So I believe is pretty accurate

Actually this sounds like it is probably within the tolerance of your accelerometer.

All such devices have some sort of offset error, however small, and must be calibrated for maximum accuracy.

For example, the Memsic MXA2050A specifies a maximum offset of plus or minus 0.6 g… for a 10g device that means a maximum offset of 6 percent.

78 ‘counts’ out of 1024 implies an offset tolerance of 7.6 percent, so I wouldn’t get too bent out of shape about this unless I paid for greater tolerance, and making very sure the device was really, truly level when measuring the offset.

I agree but I think you missed something in my original post. I said that the sensors gives actually 1.66V as it is supposed to. The problem is that the arduino converts this into 590 instead of 512 as it should for a 3.3V reference. So, I believe the problem is not with the sensor.

ok i found the problem!

I was getting the reference voltage from a 3.3V source but i was connecting it to the AREF pin through a 5K resistor (as suggested in the analogReference page) which of course was decreasing the voltage to 2.95V.

Now i connected it directly to the 3.3 source and it is correct.