PDA

View Full Version : Fixed Voltage Reference



kduck63
- 22nd March 2011, 14:57
I am trying to read 10 bit resolution voltages pins AN0 and AN2 on a 16F616. I see on the data sheet that ADCON0 bits 5 – 2 can be used to configure a fixed voltage reference of 0.6V or 1.2V. Is this equivalent to setting up an external voltage reference on the VREF pin? If so, how would I set bit 6 of the ADCON0 register to use this internal reference, or have I misunderstood this thing completely?

HenrikOlsson
- 22nd March 2011, 16:20
Hi,
I've never used that chip but as far as I can see the fixed voltage reference can only be used as "input" to the comparator(s) in the chip - it can not be used as a reference for the ADC. The fixed voltage reference can however be measured by the ADC by selecting the proper "channel" via ADCON0.

Section 9.1.3 spells it out:

The VCFG bit of the ADCON0 register provides control of the positive voltage reference. The positive voltage reference can be either VDD or an external voltage source..

Since the ADC is ratiometric but the 0.6V fixed voltage reference is not (I'm not sure about the 1.2V one) you should be able to compensate for any drift in Vdd (if that what you're using for VRef+) by sampling the fixed voltage reference and calculate the actual Vref voltage.

/Henrik.

kduck63
- 22nd March 2011, 23:30
Thanks for the info... i guess an external voltage divider is in order.

Jumper
- 23rd March 2011, 14:45
You might have to consider what you want to measure. If your goal is to measure 10 bit resolution in an absolute accurate way I you probably need an external precition voltage reference. If you use 2 resistors as a divider your power supply will be a big part of the result.

Even if you could use the internal voltage reference it is far from accurate.

Have a look at Microchip, they have lots of voltage reference solutions.

Charles Linquis
- 24th March 2011, 01:53
I have used National LM4120-4.096 references for years. 4mV /bit with 10 bit converters, 1mV /bit with 12 bit converters. 0.2% accuracy. I use those and 0.1% resistors in my voltage dividers. If you do oversampling, you can get within a few millivolts of a calibrated FLUKE DVM over a wide range.

kduck63
- 25th March 2011, 11:57
Thank you for the suggestion.

flotulopex
- 19th April 2012, 15:12
Hello Charles,

Would you have a code sample to help me for a quick start please?

I'm trying to make a voltmeter for batteries up to 2,5 Volts with a 0,01V precision but I never made a circuit using a voltage reference.

Thanks in advance for any info ;)

Charles Linquis
- 20th April 2012, 02:32
There really is not magic.

Connect your voltage reference (I use an LM4120-4096) to AN3. Make certain that you connect the GND of the reference to the PIC GND pins.
Also, you will need to connect a .2uF capacitor from the reference output to GND. That is stated on the datasheet of the part.

If the voltage you want to measure is less than 4.096V, then just put a 2K resistor from the analog input pin to your battery.

Note that if your battery is connected, and the PIC does not have power, you will need to use a FET switch between the two, otherwise the battery will discharge through the un-powered PIC.

At any rate, I always use a 2K resistor in series with all PIC pins for protection.

Set up the chip's A/D according to the datasheet. It isn't any more complicated than that.

flotulopex
- 20th April 2012, 11:27
It isn't any more complicated than that.
Thanks Charles.

I just miss the understanding of the measurement process or principle.

Is it (my thinking):
- I have a precise voltage reference, let's say 4,096Volts
- I sample it 10 bits (= 1023 samples)
- Each sample is 4,096V / 1023 = 0,004V
- I read the ADC I will measure on i.e. a battery, and convert it to the voltage I want to know.

Is it "it"?