View previous topic :: View next topic |
Author |
Message |
mquantz
Joined: 20 Feb 2014 Posts: 6
|
ADC reference woes |
Posted: Thu Feb 20, 2014 8:45 am |
|
|
Hi,
I am trying to initialize the ADC on a PIC18F46K22 using Vref- and Vref+.
Vref- comes from the DAC, and is ~1.6V
Vref+ comes from a voltage divider, and is 2.5V
The low reference works as expected, but the high reference does not seem to. It appears that the high reference is always Vdd.
Here is the relevant code:
Code: |
TRISA = 0b11100011;
setup_adc_ports(sAN0|VREF_VREF);
setup_adc(ADC_CLOCK_DIV_64);
set_adc_channel(0);
setup_dac(DAC_VSS_VREF | DAC_OUTPUT);
dac_write(5); |
Any help is greatly appreciated. Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
mquantz
Joined: 20 Feb 2014 Posts: 6
|
|
Posted: Thu Feb 20, 2014 8:58 am |
|
|
Further insight: When I use the FVR as Vref+ it works fine. It seems something is up with the Vref_Vref parameter |
|
![](templates/subSilver/images/spacer.gif) |
mquantz
Joined: 20 Feb 2014 Posts: 6
|
|
Posted: Thu Feb 20, 2014 9:21 am |
|
|
I just read that the minimum reference range is 2V, which I am definitely not adhering to. I figure that only affects spec'ed accuracy, though. My results with Vref- to Vref+ stray so far from the expected values, that I think there is a larger problem here. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9177 Location: Greensville,Ontario
|
|
Posted: Thu Feb 20, 2014 10:00 am |
|
|
I always assumed that vref- could NOT be less than zero volts( ground) and I had Adobe search the 46k22 datasheet for 'vref-'. NOWHERE can I see what the value can be!
Maybe I need better bifocals ? Perhaps someone can tell me what page of 560 that spec is on ??
jay |
|
![](templates/subSilver/images/spacer.gif) |
mquantz
Joined: 20 Feb 2014 Posts: 6
|
|
Posted: Thu Feb 20, 2014 10:02 am |
|
|
Sorry for the confusion. Vref minus is approximately positive 1.6V.
Page 464 has all the pertinent specs. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9177 Location: Greensville,Ontario
|
|
Posted: Thu Feb 20, 2014 10:54 am |
|
|
Boy, they got that chart BURIED in a silly spot! Too bad they don't reference it in the beginning of the ADC section....sigh, I'm old and cynical.No one should have to read all 464+ pages to find out critcal info.
thanks for finding it,seems I was right about the ADC being unipolar( 0..+ve).
cheers
jay |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19382
|
|
Posted: Thu Feb 20, 2014 12:19 pm |
|
|
Read up on the current drawn on the Vref.
I don't think the DAC, can deliver enough current, unless buffered. Same may apply to the 'voltage divider', depending on the resistors used.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
mquantz
Joined: 20 Feb 2014 Posts: 6
|
|
Posted: Thu Feb 20, 2014 12:23 pm |
|
|
Thanks, will do. Though it seems like that would cause the reference to be lower than expected, not higher. |
|
![](templates/subSilver/images/spacer.gif) |
mquantz
Joined: 20 Feb 2014 Posts: 6
|
|
Posted: Thu Feb 20, 2014 1:17 pm |
|
|
It seems that violating the 2V minimum span was causing the problem. I'm just not sure why it would assume Vcc was the positive reference instead of just having less accuracy over a 1V range |
|
![](templates/subSilver/images/spacer.gif) |
|