CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

ADC reference woes

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mquantz



Joined: 20 Feb 2014
Posts: 6

View user's profile Send private message

ADC reference woes
PostPosted: Thu Feb 20, 2014 8:45 am     Reply with quote

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.
mquantz



Joined: 20 Feb 2014
Posts: 6

View user's profile Send private message

PostPosted: Thu Feb 20, 2014 8:58 am     Reply with quote

Further insight: When I use the FVR as Vref+ it works fine. It seems something is up with the Vref_Vref parameter
mquantz



Joined: 20 Feb 2014
Posts: 6

View user's profile Send private message

PostPosted: Thu Feb 20, 2014 9:21 am     Reply with quote

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.
temtronic



Joined: 01 Jul 2010
Posts: 9177
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 20, 2014 10:00 am     Reply with quote

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
mquantz



Joined: 20 Feb 2014
Posts: 6

View user's profile Send private message

PostPosted: Thu Feb 20, 2014 10:02 am     Reply with quote

Sorry for the confusion. Vref minus is approximately positive 1.6V.

Page 464 has all the pertinent specs.
temtronic



Joined: 01 Jul 2010
Posts: 9177
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 20, 2014 10:54 am     Reply with quote

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
Ttelmah



Joined: 11 Mar 2010
Posts: 19382

View user's profile Send private message

PostPosted: Thu Feb 20, 2014 12:19 pm     Reply with quote

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
mquantz



Joined: 20 Feb 2014
Posts: 6

View user's profile Send private message

PostPosted: Thu Feb 20, 2014 12:23 pm     Reply with quote

Thanks, will do. Though it seems like that would cause the reference to be lower than expected, not higher.
mquantz



Joined: 20 Feb 2014
Posts: 6

View user's profile Send private message

PostPosted: Thu Feb 20, 2014 1:17 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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