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

analogue port in 16f877!!!

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







analogue port in 16f877!!!
PostPosted: Mon Nov 07, 2005 1:46 am     Reply with quote

hi everyone,

i wanted to ask two things.

1) i want the reference voltage of the A/D in 16f877 to be from 0-->1 volts. so i applied 1v to port A3 and included the command
Code:
 setup_adc_ports(AN0_AN1_AN2_AN4_VSS_VREF)   // A0 A1 A2 A5 Ref=A3

but this doesnt seem to work. read_adc() returns the value 255 which is incorrect as i am applying something like 0.24v at the analogue channel.
can any one explain if there are any other commands (apart from the normal) to correctly read the A/D between the range 0-->1 volts

2) is the analogue port of 16f877 only 10 bits, or can it go upto 16 bits

best wishes
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Mon Nov 07, 2005 2:21 am     Reply with quote

If your A/D is configured for 10bits, does 255 seem like a correct value - about 1/4 of the range.

Just in case, could you post your *.h file and the code where you make a call to read_adc()?

You can not configure the A/D to do 16 bits, but you can over-sample and average, which will effectively increase the resolution of the A/D. If I remember correctly, you need to oversample by a factor of 4 for each extra bit. So, to do 16 bits, you'll need to oversample by a factor of 64.
Ttelmah
Guest







PostPosted: Mon Nov 07, 2005 5:07 am     Reply with quote

Two comments.
First, oversampling, only 'works', if the noise on the reading is normally distributed, and the values actually 'read' have an exact relationship between the probability of taking the different values each 'side' of the real reading, and the actual voltage present. While, given normal noise sources it can work suprisingly well, to give an extra bit or two, it will not give an extra 6 bits of useable resolution, especially given the nature of some of the noise sources round the processor.
Second, one thing that may not be helping, is that the ADC reference voltage is below the minimum needed for the ADC to actually give it's design resolution. If you look at the AD converter specification, you will find that there is a minimum voltage required between Vref low, and Vref high, to give the quoted 10bit resolution. This is normally in the order of 2.5 to 3v. With 1v in, you will be lucky to actually be getting even 9bits of useable resolution.
True 16bit resolution, over a 1v range, will require a much more upmarket ADC, than the one present in a PIC, and some careful design. The 'high bit count' ADC's present in units like audio systems, do not actually give this sort of resolution. There will need to be less than 15uV, of total error, between the Vref, signal input etc., to genuinely offer this sort of accuracy...
One other obvious command is required, which is to select the channel to read. I might be inclined to suspect that the channel is not selected, and is perhaps reading an input that is high, and the ADC is in 8bit mode...

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