View previous topic :: View next topic |
Author |
Message |
arrow
Joined: 17 May 2005 Posts: 213
|
On Board A to D Conversion? |
Posted: Wed Jan 25, 2006 4:38 am |
|
|
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
|
|
Posted: Wed Jan 25, 2006 7:06 am |
|
|
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
|
|
Posted: Wed Jan 25, 2006 8:23 am |
|
|
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
|
|
Posted: Thu Jan 26, 2006 3:24 am |
|
|
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. |
|
|
|