PDA

View Full Version : Figuring out the Fixed Voltage Reference (FVR) 12F1822 (and others)



Heckler
- 17th February 2014, 23:30
Hey group,

Well I spent most of the weekend trying to figure out how to take advantage of the FVR to improve my A/D conversions.

Just when I though I'd never get it... and Darrel's (and others) hints and tips were falling into a black hole (where my brain should be), it all started to make sense.

I can now use the FVR as a reference to either reading Vdd or an outside AD input. (what fun!)

Any way one thing that is still confusing me is a note on the 12F1822 datasheet.
The FVRCON register contains a FVRRDY bit 6 that tells you when the FVR is stable.

Note 1: FVRRDY is always ‘1’ on PIC12F1822/16F1823 only
Datasheet pp. 138

So what are the ramifications of that??
Does that mean that one should include a fixed delay to give the FVR time to settle down? Or that the FVR is always ready on these chips and there is no need to wait for it?


thanks

Heckler
- 18th February 2014, 02:39
Most of what I learned and the Code samples I used came from this other thread...
http://www.picbasic.co.uk/forum/showthread.php?t=17321

I'd be happy to share anything I learned with others...

Mostly what I had to understand was that whatever you use as the ADC voltage reference (VDD, FVR, or External Vref+ on AN1) will be equivalent to 1023 counts (10bit) and the analog voltage you are trying to read will be measured against that (and cannot exceed that REF without employing some sort of voltage divider to scale it down.)

So if you program the FVR to be 1.024v then that will be 1023 counts and your analog input cannot exceed that.

When your external analog input is the same voltage as what ever you have chosen as the reference (via ADCON1) it will also read as 1023 counts. So if you set the FVR to be 4.096v then your analog input will also show 1023 counts when it reaches 4.096 volts.

If you want to calibrate the FVR (ie. find out what it actually is internally [since, as Darrel pointed out] it will likely only be close to the data sheet value)
then set the registers (ADCON0, ADCON1 & FVRCON) so that the ADC uses VDD for the reference and do an ADCIN 31 (which is the FVR channel) you can then (using an accurate voltmeter) measure your VDD, and compare the reading you get from the FVR (ADCIN 31) and then do a simple ratio to determine the real FVR voltage.

ie. if your VDD is 4.500 volts and you read 233 counts on ADCIN31 then 4500/1023 = ?(FVR actual)/233 So the answer is FVR real = 1024.9 mv or 1.0249 volts. Continuing with that same test but this time setting the FVR to be 4.096 (by changing FVRCON) and you read 930 counts on an ADCIN31 then...
4500/1023 = ?/930 then the FVR is actually putting out 4.0909v NOT 4.096v.

You can then use the above information to adjust your calculations when using the FVR as the reference to an external AD measurement.

I hope this helps others understand. And if I got something wrong here please correct me.
I am by no means an expert but it helps me to understand it just by writing it here.:o