mutiple adc read

Discussion in 'Embedded Systems and Microcontrollers' started by Anjanav, May 15, 2010.

  1. Anjanav

    Thread Starter New Member

    Mar 2, 2010
    16
    0
    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,

    Code ( (Unknown Language)):
    1. void GetAnalogStatus(){
    2. int i,g,j;
    3. int temp,temp1,temp2,temp3,temp4,temp5,temp6,temp7;
    4. char k2[7][7]={0};
    5. 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];
    6.  
    7.  
    8. ADCON0=0b00000001; //reading channel 0//
    9. Delay10TCYx(4);
    10. ConvertADC();
    11. while(BusyADC());
    12. temp = ReadADC();
    13. Delay10TCYx(4);
    14.  
    15. ADCON0=0b00000101; //reading channel 1//
    16. Delay10TCYx(4);
    17. ConvertADC();
    18. while(BusyADC());
    19. temp1 = ReadADC();
    20.  
    21. Delay10TCYx(4);
    22. ADCON0=0b00001001;  //reading channel 2//
    23. Delay10TCYx(4);
    24. ConvertADC();
    25. while(BusyADC());
    26. temp2 = ReadADC();
    27.  
    28. Delay10TCYx(4);
    29. ADCON0=0b00001101;  //reading channel 3//
    30. Delay10TCYx(4);
    31. ConvertADC();
    32. while(BusyADC());
    33. temp3 = ReadADC();
    34. Delay10TCYx(4);
    35.  
    36.  
    37. itoa(temp/2,adc_buffer1);
    38. itoa(temp1/2,adc_buffer2);
    39. itoa(temp2/2,adc_buffer3);
    40. itoa(temp3/2,adc_buffer4);
    41. Delay10TCYx(4);
    42. putsUSBUSART(adc_buffer1);
    43. putsUSBUSART(adc_buffer2);
    44. putsUSBUSART(adc_buffer3);
    45. putsUSBUSART(adc_buffer4);
    46. Delay10TCYx(350);
    47.    
    48. }
    49.  
    50. //******************************************
    51. //command function for Analog input Parallel
    52. //******************************************
    53. void Check_Analog()
    54. {
    55.   if(Rst==0){
    56.    if(DATA=='A')Rst=1;   // A input command//
    57.    }
    58.   else
    59.    if(Rst==1){
    60.     Rst = 0;    
    61.     if(DATA=='I')Rst=2;   // I input command//
    62.    }
    63.   else
    64.    if(Rst==2){
    65.    GetAnalogStatus();  //Calling function for parallel Analog input//
    66.    Rst=0;
    67.   }
    68. }
    69.    
     
Loading...