hayee
Joined: 05 Sep 2007 Posts: 252
|
wanna know about delay in ADC |
Posted: Thu Oct 09, 2008 11:30 pm |
|
|
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 |
|