Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

wanna know about delay in ADC

Status
Not open for further replies.

cool.man

Full Member level 6
Joined
May 29, 2008
Messages
323
Helped
42
Reputation
84
Reaction score
29
Trophy points
1,308
Location
Earth
Activity points
3,307
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
 

engr.hayee said:
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

I donno anything abt 18f.
Is there any in-built ADC in the uC?
If it is external what is the sampling rate of ADC..?
Can the sampling rate of ADC be changed?
What is the rate of channel selection..?
What is your ADC's settling time?
I think you have to consider all these things while programming..
At the moment we cannot suggest anything on this,... insufficient information..

Regards,
Shiva
 

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

Some delay is always needed between set_adc_channel and read_adc .Try to use 50-100 microsec delay and everything will be fine .


In your second example "if(counter==2400) then ...read_adc " => there is almost no delay used .
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top