- Processor: PIC18F66K22
- Compiler: C18 (XC8 is fine also)
I've just made (and succesfully tested) code to measure the voltage on AN4 analog pin.
Now I want to try something else, not quite sure if it's theoretically possible.
My test-board has a PIC processor, with VDD,AVVD connected to a supply (ranging from 0(if the battery is empty/disconnected) to 4,2(full battery).
Can I use ADC to measure the VDD(-in) of my board?
Why not?:
- It's not an ANx pin, not sure how to make the ADC measure it? (Channel?)
- If the voltage on VDD(-in) drops, will my ADC reference voltage also drop? (So when my PIC only gets 3,3V the ADC will still say it's 100% (as the max Voltage on the chip, also the reference is 3,3V).
Why/what do you ask?:
- Can I just measure Channel 30 (VDDCORE)?
- Could I set my Vref to Vdd and measure a precision voltage reference with the A/D converter. (Not sure how)
Or I could add a wire from VDD-in to an ANx pin?
Will Internal VREF+ (4.096V) stay 4+V when the VDD-in is around 3,4V? Is there some kind of transformator that makes it so?
- Internal VREF+ (4.096V) is a bit lower than the max of the battery (4,2V), does this mean I can damage the ADC? Or just that the result will be max when the battery is full. (4,2V out of 4,096V)
Please mind that my knowledge of Electronics is "low". I've learnt way more about the software part in my education, but I'd like to know more about (Embedded) Electronics as it's a crucial part in Embedded Engineering. (It's sad how my school doesn't see this.)