PDA

View Full Version : 'Soft' On/Off Power Switch



Art
- 9th August 2003, 23:55
Hi Guys,
These links show examples of on/off circuitry commonly used in calculators,
mobile phones, and other battery-operated devices.
The p-channel MOSFET serves as an electronic power switch.
They look ideal for pic based circuits, so I gave the first example
a shot.

Description:
http://www.reed-electronics.com/ednmag/index.asp?layout=article&articleid=CA54571&rid=0&rme=0&cfd=1
Figure 1:
http://www.reed-electronics.com/ednmag/contents/images/54571f1.pdf
Figure 2:
http://www.reed-electronics.com/ednmag/contents/images/54571f2.pdf

The 5K1 resistor in series with the switch S1 in Figure1
only appears to short the battery.
I have constructed the circuit on a small PCB, and had no luck.
I tried connecting another 5K1 resistor between Q1 gate, and
the switch end of the other 5K1 resistor because I thought it
might have been left out.

I found that the P Channel MOSFET was powering the 7805 reg
no matter what I did to the gate pin. It even provides power when the gate pin is disconnected.

Any suggestions?... I don't have any experience with MOSFETs :(
Art.

Melanie
- 10th August 2003, 08:28
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

languer
- 10th August 2003, 11:49
Art,

That circuit should work except for the following.

1. You need to really pull the gate to ground. You sort of attempted this, but you should do it by either tying the 5k1-SW junction directly to the gate (probably not too safe, but proves the point). Or tying it through a resistor (as you did), or using a voltage divider (Battery-Resistor-Gate-Resistor-Switch). The gate vs source resistor ratio (note they form a voltage divider) should be very low. In other words, when the switch closes you want the gate to see as close to ground as possible.

2. Make sure you're using a P-channel MOSFET, not N-channel. More so, make sure the device is meant to operate from logic levels (i.e. you want a logic level MOSFET).

3. You could use the same RC time constant in the second picture and it would give you additional delay. Capacitor goes on gate (to ground), resistor from gate to SW as small as possible, resistor from gate to battery as large as possible. This should give you a fast discharge rate (for turning on) and slow charge rate (to allow uC to take control).

4. You could also use either the second circuit shown, or Melanie's. Both very elegant solutions too.

Hope this helps any,

languer.

Art
- 11th August 2003, 00:46
Woohoo!

I found a similar circuit that is based on the more common
N-Channel power MOSFET.
The circuit was a MOSFET based touch switch where you finger's
condictivity across two pins acts as the momentary switch.
The circuit was for a lamp, and didn't make allowance for 'staying on'.

After some modification I got the physical circuit working great
first go. The second circuit also doesn't use the second
transistor (Q2).

I have had LOTS of fun with it now that the pic can turn itself off.
If you get a PIN wrong, the pic can say bye, bye! ...
The same if the program has a point of finalistic determination,
where the pic can turn off after completing a task.

I will post my schematic in the right section since it might help others.
Cheers,
Art.

Corey
- 4th October 2003, 20:39
Hi,

Try using an LM2941 linear regulator. They need to be configured, but I've attached a VB program that does all of the calculating for you. You should still take a look at the datasheet though.

They are great little linear regualtors and can also be used as a 1 amp switch.

They have a control pin that must be tied low for the unit to work.

I designed a circuit that tapped a signal off of the RS232 TX line from my PC. The RS232 line drove a transistor (2N3904) which charged a capacitor that, when it reached a certain voltage, drove another transistor that brought the regulator's control pin low. Then, when the regulator turned on, the PIC would start up and would drive one of it's pins high. This pin would take over from the RS232 signal and would hold the PIC on.

You could then turn off the PIC and the entire circuit with a simple command to make that same pin low.

Super easy!

Good luck.

Leonardo
- 19th September 2005, 19:46
Hello,

Where I connect the load to control?

Leonardo





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

Melanie
- 20th September 2005, 15:30
The 'load' is connected between the Collector of Q1 and 0v.

AMay
- 22nd September 2005, 06:12
My final circuit, sort of like Melanie's, works perfectly as far as I can tell. I have no quick button problem, perhaps because I put a decoupling cap., .1uf, in the circuit.

AMay

Leonardo
- 26th September 2005, 04:06
Hello,

Do I want to connect a load with a battery of 9V, like I make to connect the pic with 5V and that it doesn't consummate a lot?.

Thank you

Leonardo
- 26th September 2005, 04:54
Can this work this way?

Melanie
- 26th September 2005, 09:33
That will work to turn your PIC ON, and have the PIC switch OFF... D2 and R4 are then not required.

However, if you require a Button-OFF function, then you need to tell the PIC that the Button has been pressed. In that case D2 and R4 are required and in your circuit you will then have omitted to take a line from the D2/R4 junction back to an available PIC pin.

Leonardo
- 26th September 2005, 16:55
Melanie,

Thank you very much by its aid.

flotulopex
- 29th June 2008, 19:39
I do have difficulties to make this circuit switch-ON.

Problem description: if I switch-off my power-supply for about 2 to 3 minutes and switch it on back again, the soft-switch won't function and power the PIC. But once the PIC has been "successfully" powered, it works any time (as long as I don't switch-off the supply again).

For Q1, I implemented a 2N3906, then aBC307, then BC557; no way to make it work. Finally an old (metal case) 2n2905.

By "chance", I got it to work by making a false-contact between the 2n2905's (Collector is connected to case) and R1 (any pole) on the breadboard.

Once the contact has shortly happened and as long as the power-supply is not disconnected, the soft-switch will work perfectly (!?).

What shall I do to correct this?
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2705&stc=1&d=1214759755">
NB: I didn't implement D2 + R3 since the program shuts-off the circuit by program (RA1 = 0).

skimask
- 29th June 2008, 20:08
I'm not sure, but I think your R1 has to tap directly to the base of Q1 and not below the resistor below that...

Melanie
- 29th June 2008, 21:14
Apart from the Resistor connection that Ski mentioned (which is there to keep Q1 switched OFF), it is the job of your PIC to drive RA1 high BEFORE the User removes his finger from the switch. If your software has delays or other things before it sets RA1 high, then the circuit will simply switch-off when the finger is taken off the switch.

It is a simple circuit - it can't fail. As long as the Base of Q1 is driven low (what is your value for R2 and what is the current draw via Q1?), it will conduct and supply power. Check your wiring and software and value for R2. Remember (simplistically) the gain (hfe) value for your chosen Transistor together with the current you're sucking out the Collector will determine the amount of cuurent you need to put into the Base. Your chosen R2 may be too high a value.

flotulopex
- 30th June 2008, 07:29
Yup, R1 is actually connected du Q1's base. Thanks for noticing, skimask.

My drawing only is incorrect, in fact, I built this circuit according to Melanie's plan in a previous post.

The values of the components are those stated in the same previous post.
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
There is no delay in the program. In fact, I set RA1 high at the very beginning of the code.

At startup, the circuit draws 4,5 mA. A few milliseconds later, the current peaks up to 600mA (I drive an IR led - it's a remote control).

I'm going to add another Tr to provide the "power" to the IR-led instead of using only Q1. This should solve the problem.

SteveB
- 30th June 2008, 18:36
Simple, but need to ask. Are you sure RA1 is set to digital?

flotulopex
- 30th June 2008, 20:00
I checked an re-checked all over again; I even changed my breaboard.

Finally, I tested all components and surprise: R2 has infinite resistance (should be 12k!).

Everything is fine and the circuit works well now.

Thank you to All for your help.

I add the corrected shema - hope I didn't made a mistake this time.
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2707&stc=1&d=1214848654">

tekart
- 29th September 2008, 21:49
If all you need is a push button to turn on the circuit and the PIC to turn it off then I have tested a simplified circuit that uses a MOSFET. Low part count = lower cost! I didn't have a P-MOSFET laying around, but I *think* that you could replace my Q1 with one and that would eliminate R2 in my circuit too.

Guy

Leonardo
- 14th November 2008, 02:54
If all you need is a push button to turn on the circuit and the PIC to turn it off then I have tested a simplified circuit that uses a MOSFET. Low part count = lower cost! I didn't have a P-MOSFET laying around, but I *think* that you could replace my Q1 with one and that would eliminate R2 in my circuit too.

Guy

Hello,

¿You can replace the transistor by a canal N?.

Thank you