>> >> ----------- ------/\/----+---- to PIC pin >> | E \ / C 47K | HI=batt OK >> | ------ \ LO=batt low >> | | / >> | / 100K \ >> | \ 47K | >> | / gnd >> | ------- | >> from ---+---| reg |---+-- +5v to circuit >> batt | ---+--- | >> i/p --- | --- o/p >> cap --- | --- cap >> | | | >> gnd gnd gnd >> >> Mile Keitz suggested: >Rearrange the circuit so the resistor in series with the emitter instead, >and connect the base directly to the 5V line. The collector voltage will >then rise only to about 5.6V regardless of the battery voltage. A 100K >resistor from the collector to the PIC pin will limit flow into the >protection diode to a very small amount. good point, good call. There was a good reason that I didn't do that on my original version (but I can't think of it right now, dammit), and inertia just kept me using the circuit. Another circuit that I posted here a couple of years back used a 4.3V zener and the Vbe drop to make a simple 5V zener regulator. The output of that one directly drives MCLR, and the transistor for that one IS used in common base configuration. Many thousands of that one out there so far (part of a furnace controller). >The sensing threshold could be raised more predictably by putting diodes, >Zeners, etc. in the emitter circuit. This could be useful if the >regulator is not the low-dropout type, or advance warning of power-off is >required to backup into EEPROM, etc. I suppose . . . but would you really want to? Personally, I want to get as much life out of the battery as possible. That means using the low dropout reg. If I have to worry about updating EEPROM, I use a port pin into the PIC (not MCLR, which would shut the PIC down immediately) and power the product with alkaline batteries. So far, the 0.4V difference between signalling a low battery and the regulator reaching dropout voltage has allowed enough time to complete any pending writes (usually just a single byte). But, using the emitter-resistor circuit, RA4 >may be the best choice, since it can withstand 5.6V without flowing any >current. Applying significantly more than 5V to RA4 could put the PIC in >a test mode. The emitter-resistor circuit should also be suitable to >drive MCLR directly. Your suggested change means that RA4 is indeed the optimal input pin. Only 3 components implements the dropout detector: the transistor, with B tied directly to VDD, the emitter resistor to Vin, and the pulldown resistor from C to gnd. >True. If the circuit is to go to sleep, the 5V line will rise above 5V. >There doesn't seem to be a simple way to disable the voltage-detector >circuit to prevent it from leaking current into the 5V line. I haven't done any projects where I have had to put the PIC to sleep yet. The most that I have done is power down things like displays, sensors, etc while still leaving the PIC operating. Dwayne Reid Trinity Electronics Systems Ltd Edmonton, Alberta, CANADA (403) 489-3199 voice (403) 487-6397 fax