Hi all, I am doing a project for someone that involves using the A/D converter on a PIC18F1320 microcontroller. I believe I have it all licked, apart from I just cannot figure out how to use the A/D converter properly. This is my first experience with microcontrollers, so please forgive my ignorance if this seems like a basic problem.
I have a sensor on AN0, which outputs a voltage anywhere between 0.4v and 2.75v - which is what I want to read so the chip can determine what is going on in the outside world. Now i'm using AVdd/AVss as a voltage reference - which i've interpretted as meaning it uses the + and - power supply to the chip.. which incidently is a regulated 5v supply powered off a 9v battery.
I've set the configuration to what I believe is correct, the chip will be operating at 1MHz and i've used an acquisition time of 8TAD, set the A/D converter up as specified in the manual, and understand that my result is returned as a 10-bit number in ADRESH:ADRESL, and i've set up a routine which does certain things depending on what range the value in these registers are.
What I havent yet been able to figure out, and i've checked the manual so perhaps i'm missing something obvious, is how the value in ADRESH:ADRESL translates into a voltage?
Does it translate into an absolute voltage? ie does a result of B'0000010000' (decimal 16) translate to 1.6v? (or wherever the decimal point might be)
Or is it more a case of B'1111111111' represents VREF+? and B'0000000000' represents VREF- and anywhere in between is a fractional step up towards VREF+?
Or is it something else?
Thank you kindly for any advice