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?

\$\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\$
    – Kinka-Byo
    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.

\$\endgroup\$
5
  • \$\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\$
    – Kinka-Byo
    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\$
    – jusaca
    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\$
    – Kinka-Byo
    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\$
    – jusaca
    Commented Sep 18, 2019 at 14:43
  • \$\begingroup\$ Perfect, thank you very much again. \$\endgroup\$
    – Kinka-Byo
    Commented Sep 18, 2019 at 14:57

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.