2
\$\begingroup\$

I have a reading from an ADC that I want to convert to the equivalent voltage. The problem is that my voltage for the the PIC microcontroller is not fixed. It changes between 5V and and 3.6V.

How can I convert my ADC reading to voltage?

The only possibility that I can think of is to connect the supply voltage to another ADC pin, make an algorithm in FW to approximate the supply voltage based on this value, and then use it to convert my first reading into voltage.

\$\endgroup\$
9
  • \$\begingroup\$ Which specific microcontroller model do you use? \$\endgroup\$
    – Tagli
    Jun 1, 2021 at 10:05
  • 1
    \$\begingroup\$ Why not just use a 3.3V reference voltage for your ADC? You can get some that use <200uA so should be suitable enough for most battery applications \$\endgroup\$
    – user103993
    Jun 1, 2021 at 10:07
  • 1
    \$\begingroup\$ "The only possibility that I think of is to connect supply voltage to another adc pin, ..." The problem is the ADC reference voltage. If you don't stabilise that at a known reference then all your ADC readings will fluctuate too and you can't do any internal calibration. \$\endgroup\$
    – Transistor
    Jun 1, 2021 at 10:17
  • \$\begingroup\$ @Tagli I am using PIC18F24 \$\endgroup\$
    – ali.hssn
    Jun 1, 2021 at 10:17
  • \$\begingroup\$ @Doodle you mean I should use an external voltage regulator of 3.3V? \$\endgroup\$
    – ali.hssn
    Jun 1, 2021 at 10:19

1 Answer 1

5
\$\begingroup\$

According to the datasheet, you can use internal voltage references for the ADC:

enter image description here

But the voltage is limited according to the supply:

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ Just to be sure, If I set it to 4.096, my adc reading will not change with the supply voltage? \$\endgroup\$
    – ali.hssn
    Jun 1, 2021 at 10:30
  • 2
    \$\begingroup\$ It seems you are restricted to 2.048 V or below \$\endgroup\$
    – devnull
    Jun 1, 2021 at 10:36
  • 1
    \$\begingroup\$ Thank you. It should solve the problem. \$\endgroup\$
    – ali.hssn
    Jun 1, 2021 at 10:38
  • \$\begingroup\$ Can't you set ADPREF to VDD and measure the 1.024V FVR channel with ADPCH=0b111111 and ADFVR = 0b10? Then you can solve the reading=1024*1.024V/VDD for VDD and calculate it directly as VDD = 1024 * 1.024/reading \$\endgroup\$
    – Dave X
    Jun 1, 2021 at 19:48

Your Answer

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

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