Connect one end of diode to ground, other to pic input and pull up resistor. Just like in schematic on page 8.
They suggesting to connect diode to ground thru mosfet to minimize current consumption. When mosfet is turned on, there is about 0,6V on pic input, and that voltage won't change.
You do not need to use mosfet, you can connect diode to ground permanently, or connect to output pin.
You are missing...
There is Vref on every pic with ADC.
http://ww1.microchip.com/downloads/e...oc/41211d_.pdf Page 63 Bit VCFG(bit 6 of ADCON0)
OK, I see that now. So how do I select between the IO pin and the Vref source in code? No idea how that is done...
Still don't see how the resistor - diod junction will provide me with a reading that represents the changing Vbatt...
Last edited by tekart; - 27th October 2014 at 19:11.
"Do or do not, there is no try" Yoda
I think the confusion between you and pedja089. The first way you need two external pins from the ADC or comparator.
One of the pins is tied to an external vref source and the other is your analog input. There is no voltage reference in the 683
VCFG bit or ADCON0.6 either connects the ADC vref(input) to VDD internally or connects it to and external (pin) reference you provide. .
The second way only one external pin is needed. (pic12F1822) has an internal reference diode which can be configured to be the vref source for the adc or comparator.
Mark, thank you for clarifying. I thought it was something like that but my inexperience with internal voltage references left me confused. I have ordered some F1822 chips to experiment with.
So would you mind clarifying for me how I would go about using the single pin to take advantage of the internal reference diode. Do I understand correctly that this diode would replace the external diode we have been discussing, so all I would need is a pull-up resistor on the ADC pin? I still don't see how that would give me a reading that would very since I would still just be reading the voltage drop of the reference diode. Forgive me for being dense about this but I still don't get it.
"Do or do not, there is no try" Yoda
"Do or do not, there is no try" Yoda
Bookmarks