![analog to digital converter computer analog to digital converter computer](https://upload.wikimedia.org/wikipedia/en/thumb/5/52/ADC_voltage_resolution.svg/250px-ADC_voltage_resolution.svg.png)
So, ADC conversion result = 251 as you can’t have a fractional result.Ībove, the situation considered was simple as reference voltage is 5V with respect to ground. So, for a reference of 5.00V, what will be the ADC result when input voltage is 1.23V?Įxpected value = (1.23 / 5.00) * 1023 = 251.658 This is because the input voltage is a fraction of the maximum possible voltage and hence the ADC output result is the same fraction of the maximum possible value – 1023 in our case. The ratio of ADC conversion result to maximum possible reading is equal to the ratio of input voltage (Vin) to maximum possible input voltage (Vref). This is because (ADC result / 1023) = (Vin / Vref) The simple linear relationship between ADC input and output is given by: There is no rounding off, so you get 511. So, if you had gotten an expected ADC conversion result of say 511.8, the real result would be 511. Take note that the output is NOT rounded off. Even though 1023/2 = 511.5, the ADC cannot give results in decimal points and it will only output an integer. One thing to note here is that the ADC conversion result is 511, not 512, not 511.5. So the input and output have a pretty simple linear relationship. Since the input is midway between its maximum and minimum possible values, so is the output. If ADC input is 2.5V, you might have figured out that the ADC conversion result would be 511. If ADC input is 0V, the output is minimum as the input is at its minimum level. If the ADC input is 5V, the output is maximum as the input is at its maximum level.
![analog to digital converter computer analog to digital converter computer](http://msb.my/webshaper/pcm/gallery/lg/cf14aa233e360554e00fdbf92a144ea11568180879-lg.jpg)
So, what is the conversion value/result you obtain? Anything in between is read and converted by the PIC ADC.
![analog to digital converter computer analog to digital converter computer](https://ae01.alicdn.com/kf/HTB1a_QZRVXXXXbbXFXXq6xXFXXXx/VOXLINK-Digital-to-Analog-Audio-Converter-Optical-Coaxial-digital-audio-signals-to-analog-L-R-audio.jpg)
You can’t input anything lower than 0V since that’s your negative reference voltage. You can’t input anything higher than 5V since that’s your positive reference voltage. So, your input voltage has to range from 0V to 5V. For now, let’s say that the reference voltage is 5V. So, the ADC reading can vary from 0 to 1023. That means that the ADC result can have 2^10 (2 to the power 10) values. Hence, here I have made an effort to explain everything I could about the ADC module of the PIC microcontroller, by using the popular PIC 16F877A as reference. Many even assume it to be a daunting task after looking at all the possible settings and configurations. I have seen that many people, especially newbies, are not clear regarding the modalities of using the ADC module of PIC microcontroller. The PIC, without the conversion to digital, can do almost nothing with an analogue input (unless you use the analogue comparator). The ADC is used to convert an analogue input signal (an analogue voltage within a specific range) to a corresponding digital data that can be processed and used by the PIC.