Hi, I have a question on arduino's analog to digital conversion resolution.
Arduino decimila is known to convert analog input values(such as voltage) into digital values between 0v to 5v, and they also measure variables in between.
I would like to know how fine the resolution will be?
Can anyone tell how finely arduino's ADC make resolution between 0v to 5v?
Thank you.
Gladly!
The arduinos analog inputs have a 10-bit resolution. 2^10 (converting to decimal system) = 1024
So that's 1024 states, divided in the range 0-5V. 5V / 1024 states = 0,00488V/state (4.88mV/state)
Basically means that when you read the arduinos analog inputs you'll get a value between 0 and 1023. Each increase in this value signifies rougly a 4.88mV increase in the voltage measured.
Hope that helps! =)
Thank you for your reply. It's very very helpful. ^^
So that's 1024 states, divided in the range 0-5V. 5V / 1024 states = 0,00488V/state (4.88mV/state)
Hmmm, I just thought (having read your core memory post previously) is it actually 0-AREF? If so, then by making AREF less than 5V you could get finer values.
--Phil.
So that's 1024 states, divided in the range 0-5V. 5V / 1024 states = 0,00488V/state (4.88mV/state)
Hmmm, I just thought (having read your core memory post previously) is it actually 0-AREF? If so, then by making AREF less than 5V you could get finer values.
--Phil.
Hey Phil, quite active on the forums these days, aren't we? What you say is very interesting indeed! So, I re-read the whole "magnetic core memory" thread but I can't seem to find any mention of AREF at all.. Care to clarify?
Hi, I would like to find out whether below arduino programing is workable.
void loop()
{
val = analogRead(0); // read input value
if (val < 101)
{
digitalWrite(2, HIGH); //send signal to digital pin #2 in case input variable is smaller then 101
delay(1000);
digitalWrite(2, LOW);
delay(1000);
} else if (val > 100 && val < 201) {
digitalWrite(3, HIGH); //send signal to digital pin #3 in case input variable is greater then 100 and smaller then 201
delay(1000);
digitalWrite(3, LOW);
delay(1000);
I will connect just normal digital indicator which widely used for weight check(used wil loadcell).
This digital indicator will give between 0~5V DC voltage variables to arduino's analog input pin(0) whenever it gets signal from loadcell.
I want to ask you two questions.
(1) Let's say that the digital indicator is displaying 150, and send DC voltage(to arduino analog input) which corresponds to digital value 150, then the value arduino gets after the analog to digital conversion process is also 150?
(2) I want my arduino to send 40mA digital signal to another arduino when the variable received from analog input pin is greater then 100 and smaller then 201. Is above programming is suitable for my intention?
Thank you.
So, I re-read the whole "magnetic core memory" thread but I can't seem to find any mention of AREF at all..
That's because I didn't actually mention it there... I figured you'd read this thread so only mentioned it here. The link kuk provided should get you started.
--Phil.
In Arduino 0011, there will be an analogReference() that allows you to select from the DEFAULT reference of 5V, the INTERNAL reference of 1.1 V on the ATmega168 / 2.56 V on the ATmega8, or the EXTERNAL reference applied to the AREF pin.
I was searching for this and found your post.
So I'd like to ask you:
I am thinking that VREF for ADC is by default set to AREF external pin, because I didn't see ADMUX register programmed on both Atmega8 and 168.
If this is correct, I can put any voltage between 0 and +5v to AREF directly, without software, right?
Or I am wrong, and this is right:
The AREF pin is, by default, connected to the AVCC voltage of around 5 volts (unless you are running your Arduino at a lower voltage). To provide a lower reference voltage to this pin you need to disconnect the internal voltage reference.
quote from http://www.arduino.cc/en/Reference/AREF
Sorry, I think I've found it.
Is the wiring.c used when doing bootloader on Atmega8 and 168?
If yes, there is a line with:
// set a2d reference to AVCC (5 volts)
cbi(ADMUX, REFS1);
sbi(ADMUX, REFS0);
that makes REFS1 go 0
and REFS0 go 1,
so the VREF goes AVCC, with external capacitor at AREF pin, right?
And what do I need to do to get other condition? Ext ref on AREF for example?
Is it simple like adding this line to a sketch?:
ADMUX = (0<<REFS1)|(0<<REFS0);
or what commands do I need to add to sketch?
Sorry if I'm asking you things like this, but I know almost nothing.
[edit]I found another post, but with another solution for sketch:
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1142283743/3#3
But is it possible to use the other command with one line in sketch?[/edit]
Yes, the analog reference is set to +5V (AVCC) by default in the init() function in wiring.c which is run in every sketch. You could try changing it to the AREF pin inside setup(), but you might have problems during the intervening interval, if AVCC gets connected to AREF.
Oh, I see.
So the wiring.c is loaded as a header on every sketch.
And all I have to do is to change this:
// set a2d reference to AVCC (5 volts)
cbi(ADMUX, REFS1);
sbi(ADMUX, REFS0);
to this:
// set a2d reference to AREF
cbi(ADMUX, REFS1);
cbi(ADMUX, REFS0);
on wiring.c?
Sounds reasonable, at least until Arduino 0011 comes out.
Thank you, Mellis.
Helped too much.
Reviving a really old thread, I am sorry.
This discussion about a-ref is interesting. My understanding was that while you can change the A-REF and such the value at 1024, it doesn't change the resolution, so you still have a 4.88mv max resolution. A-REF might change the scale but not the precision, isn't that true ?
i.e. if I need to measure a 0-200mv sensor, with a .1mv precision, I can't do that with the Arduino, no matter what A-REF i pump in. Correct ?
Precision is how close the value returned by the ADC is to reality. It really isn't relevant to your specific question.
The resolution (number of bits) is fixed by the hardware design.
Changing AREF will change the range. So, for example, if you use a 1.024V reverence on AREF, you get 1mV per step.
i.e. if I need to measure a 0-200mv sensor, with a .1mv precision, I can't do that with the Arduino, no matter what A-REF i pump in. Correct ?
Correct, because that's at least 2000 steps at .1mV resolution and you can't get that out of a 10 bit (1024 step) ADC. You'll need at least an 11 bit ADC, and assuming you don't want to amplify the analog signal and create your own reference voltage, you'll probably want a 1.024V reference and a 14 bit ADC.
-j
... and it's not particularly helpful to ask your question in two different threads at the same time...
-j
I think the reference voltage of 5V also has an error bar on it. Nothing has been said about it though. OP, I think you want to be careful what other reference you want to use if you want to replace the default 5V cause that reference (say rectified from AC) may not be stable and will degrade your result.