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 question

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



Joined: 10 Apr 2008
Posts: 109
Location: Cape Town, South Africa

View user's profile Send private message

ADC question
PostPosted: Sat Apr 19, 2008 5:22 am     Reply with quote

Im using a pic 16f877a for and ADC conv and displying it on lcd. using 10 bit and vcc as ref but the 5/1023 res is a bit unaccurate for me. Ibought a 2.5 v ref.

My question is can i just simply connect is to pin 5 ref on pic change code to include a vref and use same calculation as for the vcc vref

adcvalue = adcvalue * 5 /1023
adcvalue = adcvalue * 2.5/1023

Thanks
_________________
"THE ONLY EASY DAY WAS YESTERDAY"
Ttelmah
Guest







PostPosted: Sat Apr 19, 2008 9:46 am     Reply with quote

Yes.
Except the division should be by 1024!...
The PIC is slightly unusual in this. Normally on most ADC's, the output changes to the top value (1023), about half a level 'below' the top voltage. There are then 1024 'counts', and 1023 'levels' (like the old 'number of fence posts' calculation). The PIC actually changes to the top reading about one bit 'low', so there are still 1024 counts, and 1023 levels, but these cover the range from 0 to 1023/1024th of the Vref voltage source,so the division to give the voltage per step, should use 1024, not 1023. Then (to make it even more complicated....), the transition point at the bottom of the range, is slightly _high_, so that the best approximation to the voltage for a given reading on the PIC, is:

adc_counts*(Vref/1024) + (Vref/2048)

Fun.....

Best Wishes
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