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

On Board A to D Conversion?

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



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

On Board A to D Conversion?
PostPosted: Wed Jan 25, 2006 4:38 am     Reply with quote

Hi

I have been doing A to D conversion on board the PIC16F873. This is the code that worked pretty well for me:

Code:

   set_adc_channel( 0 );
   delay_us(40);
   Ch0 = Read_ADC();


Can someone please tell me how many useconds this conversion takes, and is the 40us delay necessary?

Thank you in advance.
a.
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

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

PostPosted: Wed Jan 25, 2006 7:06 am     Reply with quote

I also put a delay after i set the a/d channel, sometimes even for 1 ms. This is because i have not figured out all those cryptic formulas in the datasheet!

Anyhow, once you do have the a/d channel set, try not to set it again, especially if you won't be invoking other a/d channels. This way, you can avoid the lengthy delays just to let it settle.
SherpaDoug



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

View user's profile Send private message

PostPosted: Wed Jan 25, 2006 8:23 am     Reply with quote

That 40us delay only applies if you change A/D mux channels. To understand its length you have to first understand the exponential decay of an RC circuit. Any EE book will cover it in the first few pages. Then you find the R and C values for the datasheet and see how much of the decay curve you need to give the time required.
I'm afraid there is no shortcut to understanding these fundamental analog principles.
_________________
The search for better is endless. Instead simply find very good and get the job done.
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Thu Jan 26, 2006 3:24 am     Reply with quote

Hi

Thank you guys.

So the delay_us(40)
is actually for the set_adc_channel( 0 );


I will try this right now.

Regards
a.
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