better understanding ADC

Discussion in 'Embedded Systems and Microcontrollers' started by sairfan1, Mar 1, 2013.

  1. sairfan1

    Thread Starter Member

    May 24, 2012
    46
    1
    hi,

    im working with PIC mcu, i go through different tutorials and examples regarding ADC module.

    My mcu has 10 bit resolution for conversion. it means, ADC divides input volts by 1024. but i do not understand why do we divide ADC results again with 1024. for example

    tmp = ADC_Read(0);
    tmp = tmp/1024; // why result is divided by 1024 as ADC has already done it
    tmp = tmp*5; //convert back to 5 volts

    my second question is, can i calculate expected ADC result, for example if volts on LDR pin are 3.7, how can i calculate expected results of ADC 3.7/1024 ?? right?

    thanking you.
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    The ADC has 10 bits that will give you 2^10 possible conversion results in the range from 0 to 1023. The results are always converted against a reference voltage. In your case it will probably be the VCC voltage of your MCY. Each bit in the conversion result will have a bit weight equal to (Vreference/(2^10))
    So let us assume that your Vreference is 5 volt. Your bit weight will be (5/(2^10)). If your ADC conversion result is 509. You multiply 509 with the bit weight. To convert the reading back to volt
     
  3. sairfan1

    Thread Starter Member

    May 24, 2012
    46
    1
    thanks, im little clear about it, but please explain, why do we divide adc results with 1024 in code also, i thought result is already divided by 1024 by ADC??

    tmp = ADC_Read(0);
    tmp = tmp / 1024;
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    You multiply the conversion result with the bit weight that is constant. 2^10=1024. Then the bit weight will be Vref/1024. It is better that you find out of this by your self. Here is a good free Ebook. The first part of the book will sort things out for you I guess http://www.analog.com/library/analogDialogue/archives/39-06/data_conversion_handbook.html
     
    sairfan1 likes this.
Loading...