Electronic – Beginner A to D Converter

analogconvertermicrocontroller

I'm trying to understand the readings I am receiving from the analog to digital converter (ADC).

I am using an integrated uIceblue2 microcontroller. The microcontroller in the circuit is a 18F4550. In the manual of the uIceblue2 microcontroller it says the an analog range from 0 to 3.3v +/-0.8V. It is a 10 bit ADC.

Page 16 of the manual shows the specifications for the analog voltage
http://www.saelig.com/supplier/emxys/EMN0210_WE_uIceBlue2_Getting_Started.pdf

EDIT: I realized that I wasn't reading my ADRESH. So when I received 1V, my ADC readings ware 1070 or 1090.

Below are some readings I'm getting from the ADC when I apply a given voltage to the analog input. I am using Docklight to read my results in decimal. I receive to outputs for each result, which I believe coordinate to the ADRESH and the ADRESL. The first group of three digits is the ADRESH and the second group of digits is the ADRESL.

  • 0.055V -> 000 020 to 000 031
  • 1V -> 001 070 to 001 090
  • 2V -> 002 139 to 002 160
  • 3.3V -> 003 255
  • 3.4V -> 003 255
  • 3.5V -> 003 255

My questions are:

  1. Why is there so much variability in the range of the voltage? I thought that 10 bit resolution was quite high and there for the numbers should be constant. For example, I would expect to get a fixed reading of 90 in a row, or a variation of at most 1 in the value, between 89 to 91.

  2. I'm using the following formula to convert the reading back to the voltage, but I don't think it is correct for calculating the voltage from ADC reading.

  3. Is it possible it is already converting to volts?

  4. Should I post my code?

$$Input\,Voltage = Digital\,Reading \times \frac{Voltage\,Range}{Number\,of\,Bits}$$

Could someone please guide me to the correct formula?

Best Answer

The correct formula is \$V_{IN} = \$\$D \cdot V_{REF}\over 2^{NBITS}\$ where D is the digital value. NBITS is 10, so the denominator is 1024. That's assuming Vref(-) is 0V.

If the reference is 3.3V/0V you'd expect a 1V input to produce a digital word of 310 base 10, so something is seriously wrong. I suggest you carefully read the reference manual chapter on the 10-bit ADC as linked here. The data sheet is generally sketchy in the operation of many things.

As @Ignatio Vasquez-Abrams points out, adequate \$T_{AD}\$ is very important.

enter image description here

Related Topic