AREF pin and analogReference() function

The Mega has 16 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and analogReference() function.

Happy New Years to everyone,

I have a question about the ADC in the Arduino Mega but I assume this also would apply to the other versions as well. According to the quoted text, the Mega has a 10 bits resolution meaning: at a reference voltage, that would yield .0049 voltage per unit. So if I change the reference voltage, does this also change the precision? Example: AREF = 3 volts, would the divisions or precision now be .0029.

Example: AREF = 3 volts, would the divisions or precision now be .0029.

Yes.

Thank you.

Yes. But that changes the scale, not the resolution. The resolution remains 10 bits = 2^10 = 1024 steps regardless of the scale or reference.

Bad terminology on my behalf. ;)

Let me explain my reasoning here. I have an analog gyro that I want to connect to the Mega. I measured the voltage output from the gyro and it measures high=2.9 and low=2.3 volts. So I want the greatest number of steps (1024) within that range.

The only way to get 1024 steps for that voltage range is to use an op-amp to scale up the voltage, with an offset to drop the 2.3 to 0.

An analog reference voltage of 3.0 will divide the 0 to 3 range into 1024 steps, but what do you do with the 900+ steps up to 2.3 that you will never see?

The only way to get 1024 steps for that voltage range is to use an op-amp to scale up the voltage, with an offset to drop the 2.3 to 0.

An analog reference voltage of 3.0 will divide the 0 to 3 range into 1024 steps, but what do you do with the 900+ steps up to 2.3 that you will never see?

Good Point, I am off to Radio Shack to purchase an opamp. Any suggestions as to which one would do the job?

Would it be possible to simply use two resistors in series to create a voltage divider?

You might use three signal diodes in series to drop the input voltage low value from 2.3v to ~.2v. Then use a pot as a voltage divider from the board 5v to generate a reference voltage of ~.6v. Not the total range, but something to try to see if the results are closer to what is desired.

Thank you, I will do some experimenting around.

I think, this is what I am looking for: LM339 Quad Comparator

http://www.national.com/mpf/LM/LM339.html#Overview

No. You aren't looking for a comparator. You are looking for an op-amp. They are cousins, but not identical twins. Comparators are made for comparing (e.g. essentially digital 1/0, TRUE/FALSE, HIGH/LOW output). Op-amps are made for amplifying.

LOL, OH!!!

Thank you.

Ok, I have it right now, I believe: LM324 Quad Op Amp

For future references, here is a great article on scaling voltages:

http://electrotap.com/blog/495

I have an analog gyro that I want to connect to the Mega. I measured the voltage output from the gyro and it measures high=2.9 and low=2.3 volts.

Just curious but which gyro are you using? Those voltage ranges don't sound right for full range on an analog gyro.

LM324 is an old-school quad op-amp. You typically need a bi-polar power supply

The LM324 is an old-school single-supply design. It will operate very close to the negative rail, but will only go to 1.5V below the positive rail.

http://www.national.com/mpf/LM/LM324.html#Overview

[edit]Just curious but which gyro are you using? Those voltage ranges don't sound right for full range on an analog gyro. [/edit]

Very possible, the specs call for 1.6 volt swing but I was unable to get the Flymentor gyro to move that far. Could be the speed or acceleration, but anything close to the range named, I will be entirely happy. :)

The LM324 is an old-school single-supply design. It will operate very close to the negative rail, but will only go to 1.5V below the positive rail.

http://www.national.com/mpf/LM/LM324.html#Overview

Seriously, I can live with this. ;)