Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ADC reference voltage problem

Status
Not open for further replies.

Nix

New Member
Hi all

Perhaps somebody can offer some advice -

I have successfully been using a PIC 16F690 to take ADC measurements, using Vdd as the reference (i.e. setting the VCFG bit of the ADCON0 register to zero).

However, I'd like to take measurements relative to a precision reference, but so far I have failed.

I have rigged up a LM431 precision reference (using the PIC's 5v supply, a 2K resistor and 10uF capacitor in the arrangement shown in Nigel Goodwin's tutorial: . This works fine, giving 2.5v out. But, when I connect this output to the PIC's Vref pin, the voltage at that pin reads 0.05v on my meter and the ADC does indeed seem to be using a very low reference voltage indeed - not the 2.5v I was expecting!

I cant find a software mistake. ADC results are fine when using Vdd as a reference. I believe all that is needed to switch to using a reference voltage on the Vref pin is to ensure:
The TRIS bit for the Vref pin (TRISA bit 1) is set to zero (disable digital IO)
The VCFG flag inthe ADCON0 register (bit 6) is set to 1 (use Vref)

Can anyone suggest something I may have overlooked/misunderstood?

Thanks

Phil
 
Nix said:
I cant find a software mistake. ADC results are fine when using Vdd as a reference. I believe all that is needed to switch to using a reference voltage on the Vref pin is to ensure:
The TRIS bit for the Vref pin (TRISA bit 1) is set to zero (disable digital IO)
The VCFG flag inthe ADCON0 register (bit 6) is set to 1 (use Vref)

Can anyone suggest something I may have overlooked/misunderstood?

It's very easy to overlook something really silly - in this case you've just said you've set TRIS to be an output, not an input - so you wouldn't expect it to work :p
 
Nix said:
I cant find a software mistake. ADC results are fine when using Vdd as a reference. I believe all that is needed to switch to using a reference voltage on the Vref pin is to ensure:
The TRIS bit for the Vref pin (TRISA bit 1) is set to zero (disable digital IO)
The VCFG flag inthe ADCON0 register (bit 6) is set to 1 (use Vref)

Can anyone suggest something I may have overlooked/misunderstood?

Thanks

Phil
Pins with analog functions are controlled by the ANSEL and ANSELH registers in the 16f690. If you use an external voltage reference, you should also define RA1/AN1 as an analog input. I think that this is another problem, in addition to the the TRISB settings. You might have overwritten bit 1 of the ANSEL register ('1' by default) selecting the input channel?
 
Last edited:
Hi

Thanks to you both! - it was indeed a combination of my silly binary error AND not having set the ANSEL bit. My belief was that setting the AN1 bit would enable AN1, rather than enabling VREF, but perhaps it was incorrect to think of these as distinct functions.

Many thanks

Phil
:)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top