
Originally Posted by
Melanie
Appended is a circuits that I subscribe to... it's one that's been floating about for a while and credits go to Dr Jan Kazula. You can replace the transisors with mosfets.
Circuit Description: At initially applying power at point SUPPLY, PNP transistor Q1 remains switched off by Resistor R1. There is no voltage at OUTPUT end, all circuitry is in OFF state.
To SWITCH-ON, press button SW1, this will bias on transistor Q1 via R2 and D1. +5v will appear at the output and your PIC chip will wake up. The PIC must now provide a signal at an output pin for the switch to remain ON. It can be any pin, and for this example we will use RA1 configured for output. PIC sets RA1 high as soon as possible in it's software (before finger is removed from button!!!). This via R3 will keep transistor Q2 switched on, and this in turn via R2 keeps Q1 switched on. The circuit is now latched and will remain on as long as the PIC keeps RA1 high.
To SWITCH-OFF. In this example we are also using a second pin from the PIC...again it can be any pin, but in this example we use RA2 configured for input. The PIC is polling pin RA2 (but not within one second of switch-on to allow your finger to release the button!), RA2 is held high by Resistor R4, but goes low if you press SW1. Your PIC software sees you press the button at RA2 and in turn switches RA1 low (thru software), voltage disappears from Q2 and the power circuit switches off. The secret here is to ensure that you do not switch off RA1 (ie make it go low) until you detect that the person has taken his finger off the button SW1, (ie on a negative to positive transition of RA2). This will stop automatic cycling to OFF and immediately back to ON if someone keeps their finger on the button permanently.
D1 stops Q2 from passing a low signal back to RA2 and switching the whole circuit OFF when it's job is actually to keep everything ON. D2 stops the PIC's +5v bias on RA2 (via R4) getting mixed up with the switching circuit voltages which may be at a much higher level.
Automatic TIMER OFF is accomplished in your software. Any time you want, just make RA1 go low and the entire circuit is switched off.
Q1 BC327B (most any PNP transistor)
Q2 BC547B (most any NPN transistor)
D1, D2 1N4148 (or equivallent low-power signal Diode)
R1 22K
R2, R3, and R4 12K
Melanie
Bookmarks