PIC ADC reference Q?

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
I like to know this to understand the Vref part of the PIC.
To measure a voltage and to display accurately, do I need to use the Vcc(5V) or the internal reference ?
If it is not too much to ask, can someone explain the internal Voltage reference part and why it is preferred if any.
 

nsaspook

Joined Aug 27, 2009
13,262
I like to know this to understand the Vref part of the PIC.
To measure a voltage and to display accurately, do I need to use the Vcc(5V) or the internal reference ?
If it is not too much to ask, can someone explain the internal Voltage reference part and why it is preferred if any.
It depends on how and what you need to measure. For absolute external voltage measurements usually the internal reference (or external precision Vref) is better than the 5V Vcc supply as the Vref unless it's filtered to remove noise from other circuit components and has a precision voltage regulator. For ratiometric measurements from a device powered by a common Vcc the absolute value of Vcc is less important as long as the Vref and Vcc voltage ratio (1:1 for direct connection) remains stable.

 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
I just need to measure the DC Voltage between 8V and 15V and show them on LCD. I am using 10Bit ADC PIC
 

nsaspook

Joined Aug 27, 2009
13,262
I just need to measure the DC Voltage between 8V and 15V and show them on LCD. I am using 10Bit ADC PIC
Then use the internal Vref if the PIC has one. The "initial accuracy" and other electrical characteristics of the Vref should be in the device specification sheet.
 

JohnInTX

Joined Jun 26, 2012
4,787
The 10bit ADC divides the range of voltage from VrefLow to VrefHigh into 1024 parts. When the input = VrefLow, the count is 0, when the input ~=VrefHigh, the count is 1023. The counts are mapped to the input voltage range determined by the range of Vref.
What @nsaspook is telling you is that you need to know a few things before selecting the source and range of Vref.
First off, Vref can't be >Vdd. Niether can your input signal. You'll have to scale your input and be mindful of the maximum source resistance allowed.

Next, the source of Vref is important. Vdd is cost free but not very precise. Diffferent regulators have different outputs within a valid range. Temperature etc can cause Vdd to drift a bit.
Vdd as a reference is usable if the analog source tracks Vdd. Suppose you had a resistor divider from Vdd-GND, tapped at Vdd/2. If Vdd moves around, your ADC reading won't change because the input voltage (Vdd/2) changes with it. The RATIO of input to reference remains the same hence the name ratiometric.

If OTOH, the analog input is NOT linked to Vdd (maybe some sensor that outputs a voltage independent of Vdd say 1V per pound of weight for example, then using Vdd is not a good choice. The sensor will output 1V regardless of Vdd but if Vdd is now the reference and changes and 1V will not be the same fraction of Vref - different ADC counts for the same 1V in. In this case, you need a stable reference, independent of Vdd. On PICs without an internal reference, some precision source like a bandgap diode is used to set the reference voltage. Many newer PICs have a programmable reference built in. saving the cost and pin of the bandgap diode.

Some designs carefully pick the Vref voltage so that they get a 1:1 ratio of input to ADC count i.e. 1.024volts gives 1 count per .001Vin. To make that work, you DO needs high precision reference at a particular value. Ever wonder why lots of reference diodes have voltages like 1.024V, 4.096V? That's why.

Personally, I just pick a good, stable reference that covers the signal range and do the math to map the ADC count to the linear input voltage, choosing units that make sense. In the pressure sensor example, I would work the math to yield not volts but some usable pressure number. If the sensor is linear, all you have to do is add/subtract an offset then multiply by a gain.

Finally, be absolutely certain that your analog section (Vref and input signal) never exceeds Vdd on power up (or any other time) That can cause latch-up and a very unhappy (and hot) PIC.

Have fun.
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
I thought about posting this in the ICSP thread before but since both are for the same purpose I will post here.
I am attaching a pdf that I am thinking of using ICSP.
The reset switch part & ICSP part is copied from the easyPIC7 schematic.
Can you confirm my VPP, PGC and PGD, connections are fine and using the reset components are also A-OK.
The PIC no can be seen from this diagram.
My aim is to measure the charge and battery voltage and display it on LCD. Voltage will be from 7V to 15V. I am using resistor divider to feed the PIC ADC. Like to know for this project which Vref would you suggest. The PIC internal Vref or the PIC 5V PSU.
 

Attachments

Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
Since the battery voltage is not related to Vdd, I would use the internal reference.
The ICSP looks OK.
When you do the voltage divider, keep in mind that the max source impedance of an analog source needs to be <=2.5K to satisfy the ADC acquisition requirements.
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
Check the data sheet, ADC source Z should be <=10K.

As for source Imped. can you check the Pdf.
I am guessing source Z should be calculated as R11||R12 for MainPSU_OK, ADC, Right ?
 

Attachments

ErnieM

Joined Apr 24, 2011
8,377
Check the data sheet, ADC source Z should be <=10K.

As for source Imped. can you check the Pdf.
I am guessing source Z should be calculated as R11||R12 for MainPSU_OK, ADC, Right ?
Check what data sheet? You do not disclose what device you are looking at.

The source impedance is the equivalent thevenin impedance that you calculated correctly.
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
Sorry. I meant "checked the data sheet" and it says 10K.
The pdf shows my target PIC.

I googled how to calculate the source Z.
And they says it should be the parallel resistors value (total resistance) of the series voltage divider. Not sure why how this is done though.
 
Last edited:

nerdegutta

Joined Dec 15, 2009
2,684
I am attaching a pdf that I am thinking of using ICSP.
Not that it matters too much with the ADC questions, but...

When I use my PIC16F877A, which I think is pin compatible with the PIC16F876, I have a 10K resistor from pin1 to +5v. In the schematic in post #6, it looks like the pin one is connected to +5, through a 1K resistor and a 10K resistor.

I might be wrong, though...
pic16f877a-icsp.JPG
 
Top