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

wanna know about delay in ADC

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



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

wanna know about delay in ADC
PostPosted: Thu Oct 09, 2008 11:30 pm     Reply with quote

Hi,
I am working on 18f452.I have some Analoge Channels Some digital Inputs.Exactly i want to know that is it necessary to add a delay in adc routine for example
Code:

set_adc_channel(2);
  delay_ms(5);
  ts1=read_adc();
  ts2=(ts1*0.488);//ts2=((ts1*5)/1023)*100 => ts2=(ts1*0.488)
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  hold_regs[10]=ts2;//loading value of ts2 in holding register

Here the delay is too much because i want to run the entire program in 55uS.My program consists of 4 analoge channels so it would be take too much time.

i used another technique.i have initialize a counter.when a conter reaches at a particular value it read adc like

Code:

set_adc_channel(2);
if(counter==2400)
 {
  ts1=read_adc();
  ts2=(ts1*0.488);//ts2=((ts1*5)/1023)*100 => ts2=(ts1*0.488)
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  rotate_left(&ts2,2);
  hold_regs[10]=ts2;//loading value of ts2 in holding register
  }


But by doing this when i vary any one analoge channel by potentiometer all analoge channels varies.
Tell me another way for doing this
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Fri Oct 10, 2008 12:29 am     Reply with quote

The datasheet states:
Quote:
The A/D conversion time per bit is defined as TAD. A minimum wait of 2 TAD is required before the next acquisition starts......The A/D conversion requires 12 TAD per 10-bit conversion.
This comes up to be a little under 12us for temperatures around 25 degC.

When changing ADC channels it is recommended that you wait about 20us before doing an ADC read to allow for ADC settling. You do not need to wait for 5ms.

Quote:
My program consists of 4 analoge channels so it would be take too much time.
I don't see you changing channels.

Quote:
But by doing this when i vary any one analoge channel by potentiometer all analoge channels varies.
I have no idea what you are trying to do here.

I don't think its possible to read 4 channels in 55us using the '452. You may want to try a higher end PIC or switch to an external ADC.

Rohit
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