0
\$\begingroup\$

I want to measure the input voltage to my circuit. The input voltage is supposed to be anything between 7 to 35 Volts.

I have a micro-controller with 12bit ADC. I am using a simple voltage divider to connect a fraction of input voltage to the ADC pin.

The voltage divider is simply a R1 = 82k on top and R2 = 5.6k resistor on bottom.

According to my calculation, at 35V I should get (never mind the tolerance):

V_IN = (V_SUPPLY * R2) / (R1 + R2) = (V_SUPPLY * 5k6) / (82k + 5k6) = 2.24

And the same calculation at 7 Volts I should get 0.4V into the ADC pin.

Now the question is, how to convert the raw value of the ADC to a voltage?

If I supply my circuit with 12V and if I did the programming of ADC correct, I am reading the raw value of around 840 out of my ADC.

The ADC reference voltage of controller is 3.3 Volts.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ What is the ADC reference voltage? \$\endgroup\$
    – Long Pham
    Commented Oct 21, 2018 at 13:52
  • \$\begingroup\$ @LongPham it is 3.3 volts \$\endgroup\$
    – DEKKER
    Commented Oct 21, 2018 at 13:55
  • \$\begingroup\$ Well, use the formula: V = reading * Vref / (2^n - 1). Since the ADC voltage is proportional with the input voltage, you can calculate it easily. \$\endgroup\$
    – Long Pham
    Commented Oct 21, 2018 at 14:04
  • 1
    \$\begingroup\$ Just a note: If you are doing fast conversions the SAR sampling current (if unbuffered) will reduce your measured voltage because of that 82K resistor- check your RC time constants to make sure you are OK on accuracy. \$\endgroup\$
    – user201365
    Commented Oct 21, 2018 at 14:27
  • 1
    \$\begingroup\$ A quick and dirty way is to add a capacitor in parallel with R2, however to do accurate continuous conversions you will either have to have an op-amp or compensate for the drop in voltage by adding in the SAR load on your R1/R2 voltage divider. The scaling equation has already been done by Spehro below. \$\endgroup\$
    – user201365
    Commented Oct 21, 2018 at 14:31

1 Answer 1

2
\$\begingroup\$

V = (R/4096)Vref(82K + 5.6K)/5.6K

Which gives me about 10.6V, which I suspect is too far off from 12.0V to be explained by even 5% resistor tolerances and a few percent Vref tolerance.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks! Apparently I have the wrong resistors in place. now it works fine :) \$\endgroup\$
    – DEKKER
    Commented Oct 21, 2018 at 16:11

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.