|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
16f684 adc |
Posted: Thu Oct 01, 2009 11:44 pm |
|
|
I'm new to working with the built in ADC, and I have a few questions before I run my program on my 16f684 PIC.
First, when setting up the ADC, I noticed in other peoples code, they use:
Code: |
setup_adc_ports(sAN6 | VSS_VDD);
|
Why is it necessary to set the VDD and VSS pins as analog? Is this simply using the VSS/VDD pins in place of VREF?
The ladder would be:
Code: |
setup_adc_ports(sAN6 | VSS_VREF);
|
Which I'm assuming would use the VREF pin for reference instead of VDD. Is this correct? |
|
|
Ttelmah Guest
|
|
Posted: Fri Oct 02, 2009 2:22 am |
|
|
The place to start, is the processor .h file, where the constants used in such functions are defined. This, first shows you what options are available, and secondly, usually has a 'comment', to explain what the options do. So, for your 'VSS_VREF' definition, if you look in this file, you find the comment:
// Range 0-VrefH
While VSS_VDD, has the comment:
// Range 0-Vdd
So, the answer is 'yes'.
The 'reason' for the nomenclature chosen, actually has to do with other chips, where both VrefH, and VrefH are settable, so on these, you will have more options, like:
VSS_VDD
VREF_VDD
VSS_VREF
VREF_VREF
Allowing the four possible permutations, using either the corresponding VREF pin, or the supply, for each 'end' of the ADC range. On your chip, these are not available (the processor's data sheet, shows what options can be selected).
If you are using an external Vref, be sure to look at the DC characteristics, table 15-9, items A20, and A20A, in the data sheet.
Best Wishes |
|
|
Guest
|
|
Posted: Fri Oct 02, 2009 9:38 am |
|
|
Great, that was exactly what I needed to know! Thanks.
Which would bring up my next question: My operating voltage range for the analog input is 1.6V-2.4V, and the VDD pin on the pic is being powered by 5V. Would it be correct to use the VDD pin as my VREF? Or would it be recommended to use the VERF pin powered @ 2.5V? |
|
|
Ttelmah Guest
|
|
Posted: Fri Oct 02, 2009 9:54 am |
|
|
You would potentially double the resolution using 2.5v, and 2.5v, is the minimum useable on this chip to give full 10bit resolution. A good choice.
Also the 'odds' are that a 2.5v bandgap reference will be more stable/accurate than the supply, improving things further.
You could obviously improve things further, by 'preprocessing' the signal with an op-amp.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|