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 CCS Technical Support

ADC using external Reference

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



Joined: 15 Mar 2004
Posts: 6

View user's profile Send private message Send e-mail

ADC using external Reference
PostPosted: Tue Oct 04, 2005 9:01 am     Reply with quote

Just a general question as to how to use an external reference when using a pic with an inbuilt AtoD convertor.

The PIC I am using is a 16LF872 and I cannot use V+ as a reference as it is not constant with temperature. The PIC is run stright off a battery and the battery voltage varies from 3.6V at ambient to 3.9V at 150C. I know that this PIC has an external reference pin any guidance as to the value of reference I should use and how to configure the PIC to use this reference would be great.

Any example code as how to do this would be great.

Best regards

Javed
_________________
Javed Shafi

email: JShafi@aberdeen.oilfield.slb.com
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Tue Oct 04, 2005 9:55 am     Reply with quote

Hello

Quote:
to the value of reference I should use


That depends on your analog input volatage range.

Quote:
how to configure the PIC to use this reference


Should be in the datasheet or the CCSC manual

mfg
Felix
Ttelmah
Guest







PostPosted: Tue Oct 04, 2005 10:01 am     Reply with quote

Open the .h file for your PIC. Look for the section entitled 'Constants used in SETUP_ADC_PORTS()'. This has a list of the allowable values, and which pins do what. You will probably want the one 'AN0_AN1_VSS_VREF'. This defines A0, and A1 as analog inputs, with Vref on A3. This is the 'least pins used' configuration for an external Vref (the other using the same number of pins, is 'AN0_VREF_VREF' - this uses A0 as a single input, and A1, as the 'low' reference voltage, with A3 as the 'high' reference).
Then everything behaves as normal. Just select the analog input channel, and convert as normal. There is a 'caveat', that the accuracy of the ADC, falls if the reference gets too low (this happens below about 2v between the low and high reference voltage). The chips work well with a typical 2.5v bandgap reference, and this would seem to suit your supply voltage. The reference source, needs to be able to stably supply up to 1mA of current to cover all situations.

Best Wishes
Javed Shafi



Joined: 15 Mar 2004
Posts: 6

View user's profile Send private message Send e-mail

PostPosted: Tue Oct 04, 2005 10:22 am     Reply with quote

Many thanks for the advice, will give it a try

Javed
_________________
Javed Shafi

email: JShafi@aberdeen.oilfield.slb.com
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Oct 04, 2005 12:03 pm     Reply with quote

Of course if you are using a ratiometric sensor, such as a potentiometer, a thermistor, or a strain bridge, it doesn't matter if the reference voltage drifts with temperature. If the battery drives both the PIC A/D and the ratiometric sensor then the value of the drive voltage can drift quite a lot without affecting the reading.

Tell us more about your application.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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