mutiple adc read

Thread Starter

Anjanav

Joined Mar 2, 2010
16
HI,,,

using pic18f4550 am reading 8 Analog channels at a time. but am getting only one value displayed in the hyperterminal.. am using ADC library functions for reading the channels.how to read and display 8 analog channel values...

Awaiting for your replies...

thanks,

Rich (BB code):
void GetAnalogStatus(){
int i,g,j;
int temp,temp1,temp2,temp3,temp4,temp5,temp6,temp7;
char k2[7][7]={0};
char adc_buffer2[8],adc_buffer1[8],adc_buffer3[8],adc_buffer4[8],adc_buffer5[8],adc_buffer6[3],adc_buffer7[3],adc_buffer8[3];


ADCON0=0b00000001; //reading channel 0//
Delay10TCYx(4);
ConvertADC();
while(BusyADC());
temp = ReadADC(); 
Delay10TCYx(4);

ADCON0=0b00000101; //reading channel 1//
Delay10TCYx(4);
ConvertADC();
while(BusyADC());
temp1 = ReadADC();

Delay10TCYx(4);
ADCON0=0b00001001;  //reading channel 2//
Delay10TCYx(4);
ConvertADC();
while(BusyADC());
temp2 = ReadADC();

Delay10TCYx(4);
ADCON0=0b00001101;  //reading channel 3//
Delay10TCYx(4);
ConvertADC();
while(BusyADC());
temp3 = ReadADC();
Delay10TCYx(4);


itoa(temp/2,adc_buffer1);
itoa(temp1/2,adc_buffer2);
itoa(temp2/2,adc_buffer3);
itoa(temp3/2,adc_buffer4);
Delay10TCYx(4);
putsUSBUSART(adc_buffer1);
putsUSBUSART(adc_buffer2);
putsUSBUSART(adc_buffer3);
putsUSBUSART(adc_buffer4);
Delay10TCYx(350);
   
}

//******************************************
//command function for Analog input Parallel
//******************************************
void Check_Analog()
{
  if(Rst==0){
   if(DATA=='A')Rst=1;   // A input command//
   }
  else
   if(Rst==1){
    Rst = 0;     
    if(DATA=='I')Rst=2;   // I input command//
   }
  else 
   if(Rst==2){
   GetAnalogStatus();  //Calling function for parallel Analog input//
   Rst=0;
  }
}
 
Top