usb analog input problem

Discussion in 'Embedded Systems and Microcontrollers' started by Anjanav, Mar 2, 2010.

  1. Anjanav

    Thread Starter New Member

    Mar 2, 2010
    16
    0
    hi,,,,:)
    am new to this forum... and new to microcontroller also... can anyone pls help me... am working with pic18f4550 to get the analog input in AN0 pin and to display it in hyperterminal screen...

    now my problem is am getting values like this "00000001112121162225263335363745454849505050" in hyperterminal screen...:confused: i tired some functions but am not getting in float values...

    please help me for this....:( i don know what to do....

    am waiting for ur replies....

    here is my code..

    Code ( (Unknown Language)):
    1.  
    void ReadPOT(void)
    {
    ADCON0bits.GO = 1; // Start AD conversion
    while(ADCON0bits.NOT_DONE); // Wait for conversion
    return;
    }//end ReadPOT
    void SendADC(void)
    {
    int temp;
    float advalue;
    counter++;
    if (counter==10000)
    {

    counter=0;
    ReadPOT();
    input_buffer[0] = ADRESH;
    input_buffer[1] = ADRESL;

    if(mUSBUSARTIsTxTrfReady())
    {

    temp = ReadADC();


    if(mUSBUSARTIsTxTrfReady())
    {
    itoa(advalue,input_buffer);
    mUSBUSARTTxRam((byte*)input_buffer,2);

    }
    }
    }
    }
    Code ( (Unknown Language)):
    1.  
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I did not know that Hypertrem could read the USB port. But well let us stay on topic. If you are going to read your values in Hyperterm. You must first convert the two byte value from the AD converter into a text based number. To do this you first have to scale the AD converter result into whatever unit you use. Then convert this value into text. You will find functions in your C compiler that do this. But they might hog some CPU time. Then doing this kind of application. I prefer to send the data as raw data to the host PC. And do all the conversion on the PC by writing a simple program
     
  3. Anjanav

    Thread Starter New Member

    Mar 2, 2010
    16
    0
    could u please tell me how to write that conversion program

    coz i tried out some it coudn't worked out....

    thanks
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
Loading...