The role of the ANALOG-TO-DIGITAL CONVERTER (A/D) is to convert analog voltage values to digital values. Let’s explore the principle of operation of the A/D converter: The ANALOG-TO-DIGITAL CONVERTER converts analog voltage to binary numbers. These binary numbers can be in different length - 2, 4, 8, 10-bit. The more bits the binary number has, the higher the resolution of the - A/D. For example: Suppose that the voltage that supplied to the A/D converter varies from 0 to 5 volt, and the A/D converter converts the input voltage to a binary number of two-bits. With two bits, we can ONLY display 4 different options: 00 01 10 11 That is, we can show the changes from 0 to 5 volt with 4 numbers, or more precisely four levels. You can see the 4 levels in the following illustration: BLUE line describes the changes in the input voltage of the ANALOG-TO-DIGITAL CONVERTER (A/D) of the microcontroller.RED line represents the digital levels at the output of the ANALOG-TO-DIGITAL CONVERTER (A/D) of the microcontroller. We can see that the red signal far from being ideal, i.e. not close enough to the original analog input voltage values. Thus, we can say that A/D with the binary number of two-bits has a low resolution and there is a large gap between the real value of the analog input voltage and the values represented by the A/D. Now, suppose that the voltage that supplied to the A/D converter is still varies from 0 to 5 volt, however, the A/D converter converts the input voltage to a binary number of three-bits. With three bits we can get 8 different options:

Now we can see that the RED line represents the original signal “better” than the previous RED line. The gap between the analog signal and the digital signal smaller compared to the previous graph. Based on the "good" results that we received, we can say that current A/D converter has a high-resolution compare to previous case.

Therefore we can say that the ANALOG TO DIGITAL CONVERTER (A/D) of the microcontroller with a larger amount of bits has a higher resolution and better accuracy when converting from analog signal to digital signal.

There is another fact to mention about the resolution of the A/D converter. Since the converter converts the signals, it takes a certain time. The conversion time of the low resolution A/D takes less time than the conversion time of the high resolution A/D.

When you are planning special systems, you have to take into account this fact. If you are planning to build accurate and fast systems, you have to consider carefully which convert to choose: if you select an analog to digital converter (A/D) with high resolution – system will not be as “fast; but if you select an analog to digital converter (A/D) with high-speed response – you will loose the resolution of the system.

### How to convert analog values to digital values:

If we decide to work with an analog to digital converter (A/D) with three-bit length, we obtain eight different binary numbers which represent different voltage levels. For example:

Voltage levels [V] Binary representation 0-0.62 000 0.621-1.25 001 1.251-1.87 010 1.871-2.5 011 2.51-3.12 100 3.121-3.75 101 3.751-4.37 110 4.371-5.00 111

In this example, the analog voltage values from 0v to 0.62v have a binary representation of 000; the analog voltage values from 0.621v to 1.25v have a binary representation of 001 so on.

The Analog to Digital Converter (ADC) module located within the PIC microcontroller has aresolution of ten-bit length. Therefore, the converter can divide the analog input voltage between 0v and 5v to 2^ 10 levels, which are 1024 levels. We can say that the resolution of this component is very high.

### How do we know what is the binary value/representation of the analog input voltage?

We can use the triangle method to calculate/find the binary representation of an analog input voltage. For example, lets calculate/find the binary value representation on the analog input voltage of 3.65 volt:

The analog input voltage of 3.65v will be represented by decimal number 748 or by binary number 1011101100.Using similar way we can find a binary representation for any desired level of the analog input voltage.

The A/D module has four 8 bit registers. These registers are:

VLSI PROJECTS

• ADCON0 - A/D Control Register 0; determines the behavior of the A/D
• ADCON1 - A/D Control Register 1; determines the configuration of the PORTA and PORTE and how the result of conversion of A/D will be store
• ADRESH - A/D Result High Register
• ADRESL - A/D Result Low Register