Estimating VDD using FVR by routing it to the ADC with no external circuitry

Started by trastikata, Nov 25, 2021, 09:57 PM

Previous topic - Next topic

trastikata

Here's an example of measuring the VDD level internally on devices with FVR (Fixed Voltage Reference) without using any of the PIC pins or external circuitry. Here's how it works:

- Tie internally VREF to VDD
- Enable FVR at level, lower than VDD i.e. 1.024v, 2.048v ...
- Measure the FVR as referenced to VDD by selecting CHS<1111>
- Inversely calculate VDD as function of measured FVR, knowing that FVR is fixed to 1.024, 2.048v ...

ADC.jpg

And some code example:

Device = 18F14K50
Declare Xtal = 12

Declare Float_Display_Type = Large

Dim wADC As Word
Dim BatteryVoltage As Float
       
Main:
    ANSEL = 0 : ANSELH = 0  'All pins as digital
    ADCON1 = 0              'VREF tied to VDD and VSS
    ADCON2.7 = 1            'ADC data is right justified
    REFCON0 = %10100000     'FVR enabled at 2.048v, routed to CHS<1111>
   
    While 1 = 1
        Print At 1, 1, Dec VDD()
        DelayMS 500
    Wend
   
Proc VDD(), Float
    ADCON0.0 = 1            'ADC on
        wADC = ADIn 15      'Measure FVR channel as referenced to VDD
    ADCON0.0 = 0            'ADC off
   
    Result = 2097.152 / wADC    'Calculate VDD in function of FVR
EndProc

Giuseppe



Yves

Hello Trasticata,

This would be a way of checking the output of the voltage regulator going below its optimum voltage when the battery powered instrument is used.

Regards,

Yves
Yves

towlerg

Although in the past the FVR has been describes as "shite", I found it perfectly adequate to measure battery voltage in 0.1 steps.

towlerg

Hey I just found a cool thing (well actually another cool thing) about this board. It warns you if somebody has posted whilst you were carefully crafting your missive.

tumbleweed

Quote from: towlerg on Nov 26, 2021, 11:07 AMAlthough in the past the FVR has been describes as "shite", I found it perfectly adequate to measure battery voltage in 0.1 steps.
In some of the older chips the FVR accuracy is pretty poor... in the 10% range.
In most newer chips it's a bit better than that... 4-6%

Those specs are across the full temp range (ie -40 to +125), which is where most of the change in output occurs.
If you're working around room temp they're pretty good.