# Converting ADC reading to voltage where microcontroller voltage is not fixed

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.

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.

• Which specific microcontroller model do you use? Jun 1, 2021 at 10:05
• 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
– user103993
Jun 1, 2021 at 10:07
• "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. Jun 1, 2021 at 10:17
• @Tagli I am using PIC18F24 Jun 1, 2021 at 10:17
• @Doodle you mean I should use an external voltage regulator of 3.3V? Jun 1, 2021 at 10:19

• 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 Jun 1, 2021 at 19:48