1
\$\begingroup\$

I have a certain analog signal v(t) which varies from 0 to 2V, which I want to be read by Arduino.

I know that Arduino can read it through the function AnalogRead, and the result will be a sequence of numbers from 0 to 1023. Now, I have some doubts:

  1. The input range 0 - 5V is mapped to 0 - 1023. Therefore, if I get the result X and I want to find the original input voltage V, I have to apply the formula: V = X * 5 V /1023. Correct?

  2. The output range is 0 - 1023: this means that Arduino uses 10 bit for the A/D conversion. If I am correct, this means that the Arduino resolution is equal to 5V/1024 = 4.88 mV. But my signal varies from 0 to 2V, so there is a waste of bits. I think the conversion might be better. For instance, if all 10 bits were used for the range 0 - 2V, we would get a resolution of 2V/1024 = 2mV. Any solution? Moreover, what does it happen if I decide to amplify my voltage with a gain = 2.5? Is there a benefit?

Mike
2,6192 gold badges17 silver badges31 bronze badges
asked Sep 18, 2019 at 7:58
\$\endgroup\$
2
  • \$\begingroup\$ \$V = X\times 5/1024 \$ (see here) \$\endgroup\$ Commented Sep 18, 2019 at 8:13
  • \$\begingroup\$ Thank you for the correction! \$\endgroup\$ Commented Sep 18, 2019 at 11:12

1 Answer 1

3
\$\begingroup\$
  1. As Tom Carpenter has already pointed out, you must divide by 2^N = 1024.

  2. You are correct with your second assumption. You always want to fit the ADC full scale voltage (the maximum voltage it can measure) with your maximum input amplitude. Typically there are two ways to do that:

    • You can use an input amplifier to amplify/attenuate your signal to exactly match the FS voltage.
    • You can set the reference voltage of the ADC to the desired value.

While the controller used on the Arduino Uno (Atmega) offers in general the option to connect an analog reference voltage differing from general Vcc, this does not work for you, because the analog reference input is hardwired on the Arduino to 5V. So you are stuck with a reference voltage of 5V, which means your FS (full scale voltage) will always be 5V on the Arduino.
What you CAN do, is to use an operational amplifier to increase your signal's amplitude by factor of 2.5 from 2V to 5V. That way, you get the full resolution of the 10 bit ADC.

Dave Tweed
184k17 gold badges248 silver badges431 bronze badges
answered Sep 18, 2019 at 8:13
\$\endgroup\$
4
  • \$\begingroup\$ Thank you for the answer. I have only another doubt. Intuitively I understand that an amplification of 2x improves the conversion since we use all the scale, but I do not see this from a math point of view. Since the scale is always 0-5V, the resolution will be always 5/1024 = 4.88 mV \$\endgroup\$ Commented Sep 18, 2019 at 11:13
  • \$\begingroup\$ Yes, the resolution will still be 4.88mV, but for measurements at 5V. You amplified your signal by 2.5, this means in software you have to divide the value again by factor 2.5. This also devides the voltage step from 4.88mV to 1,95mV. \$\endgroup\$ Commented Sep 18, 2019 at 12:09
  • \$\begingroup\$ Perfect. Ah, a last question: if I decide to use the ATMEGA328 in a board different from Arduino, how can I solve the problem? Which is the reference voltage I have to set? \$\endgroup\$ Commented Sep 18, 2019 at 13:58
  • \$\begingroup\$ The ATMEGA328 has a Pin called Aref. Here you can connect the analog reference voltage, which will be your FS voltage. This is described in this datasheet at page 256 "21.5.2 ADC Voltage Reference": sparkfun.com/datasheets/Components/SMD/ATMega328.pdf \$\endgroup\$ Commented Sep 18, 2019 at 14:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.