I think the circuit will be easier to understand if the names of the pins and the internal structure of the PIC port pins are in the picture. I am not so sure if I understand the circuit correctly but I will give it a try. The one connected to the decompling capacitor (pin14) is the Vdd pin. Normally it is connected to the supply, but not in this case. Port pins have diode protection to Vdd and Vss. Therefore the external power (5.5V and limit at 50mA) will charge the Vdd decoupling capacitor through the port protection diode to about 5.5V-0.6V=4.9V. This will make the PIC happy and running. Pin 8 then will be configured as an output pin and output high (to turn the high sider FET on). Now we can pulse-charge the two backup batteries or supercaps by configuring pin6/pin7 as output pins and outputing high to charge and configuring as input to stop charging. To detect DC voltage on Pin 8, we need to configure it as an input pin from time to time (thus turn the high side FET off). Once it reads low, we know that the DC voltage drops quite a lot and we'd better turn off the high side FET totally. In this case, the backup batterie(s)/supercap will take over. Since pin 8 should not sink more than 25mA, the total current consumption should be less than this. The voltage should not be higher than maximum allowed input voltage (Vdd+0.3V). That is why the external DC voltage to pin 8 is typically 5.5V and can drive 25mA at most. I think this is quite non-standard. ;-) Regards, Xiaofan -----Original Message----- From: Peter Sent: Wednesday, October 12, 2005 4:25 AM To: Microcontroller discussion list - Public. Subject: RE: [PIC] Battery backup On Mon, 10 Oct 2005, James Newtons Massmind wrote: > Can you comment a bit more on what is happening in that circuit? In the pdf, > you say "The bulk diodes are used during startup, then code turns on the > relevant high side output FET which conducts both ways, so it can be used > for charging and/or extra power (as a low power scheme). Pulsed charging can > achieve very low current charging of the backup battery(es)." > > When you refer to bulk diodes and FETs, you are talking about components > that are inside the PIC? Yes. The circuit as shown powers the pic from either battery or the dc input, without the code doing anything. When the code wakes up it should turn on the high side fet where the power comes in and then pulse the high side fets of the batteries to charge them. It cannot really measure the voltage but it can make sure that the integrated current does not exceed the trickle charge current of the NiCd or supercap used. When external dc drops the pic can detect this (f.ex. by not keeping the high side fet on on the dc input pin, but pulsing it off every few msec) and turn the high side fet off. > I assume the PIC can read the pin connected to the external power supply to > see if it is producing, then it would set the pin as an output and drive it > high to connect that power source to the internal Vdd and set the pin > connected to one of the batteries to high to charge that battery? > > Your statement "using the outputs to drive low at full (20mA) current from > another power supply within +/-0.3v+0.6v of the voltage on the decoupling > cap" totally confuses me. > > Finally, is there any particular reason why you have two batteries? The idea is to use two coin cells so they can be changed one by one wihout losing data. Of course you would not charge the coin cells. If using a proper supercap or battery then just one is enough. I have used such a scheme in a hours meter. It could also work in other systems, like alarms, dongles and clocks. Peter -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist