Remove Text Formatting
Loading...

+ Reply to Thread
Results 1 to 20 of 20
  1. #1
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    921

    Default 'Soft' On/Off Power Switch

    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/ednm...=0&rme=0&cfd=1
    Figure 1:
    http://www.reed-electronics.com/ednm...es/54571f1.pdf
    Figure 2:
    http://www.reed-electronics.com/ednm...es/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.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358

    Default

    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
    Attached Images Attached Images  

  3. #3
    Join Date
    Jul 2003
    Location
    USA - Arizona
    Posts
    156

    Post

    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.

  4. #4
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    921

    Default

    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.

  5. #5
    Corey's Avatar
    Corey Guest

    Lightbulb Try an LM2941 Linear Regulator

    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.
    Attached Files Attached Files

  6. #6

    Smile Help

    Hello,

    Where I connect the load to control?

    Leonardo




    Quote 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

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358

    Default

    The 'load' is connected between the Collector of Q1 and 0v.

  8. #8
    Join Date
    Aug 2005
    Location
    Houston, TX
    Posts
    43

    Default See Auto-off under schematics

    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

  9. #9

    Smile doubts

    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

  10. #10

    Smile

    Can this work this way?
    Attached Images Attached Images  

  11. #11
    Join Date
    Jul 2003
    Posts
    2,358

    Default

    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.

  12. #12

    Smile

    Melanie,

    Thank you very much by its aid.

  13. #13
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french part)
    Posts
    701

    Unhappy Turn-On won't work...

    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=121475975 5">
    NB: I didn't implement D2 + R3 since the program shuts-off the circuit by program (RA1 = 0).
    Attached Images Attached Images  
    Roger

  14. #14
    skimask's Avatar
    skimask Guest

    Default

    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...

  15. #15
    Join Date
    Jul 2003
    Posts
    2,358

    Default

    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.

  16. #16
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french part)
    Posts
    701

    Default

    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.
    Quote Originally Posted by Melanie
    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.
    Roger

  17. #17
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343

    Red face

    Simple, but need to ask. Are you sure RA1 is set to digital?

  18. #18
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french part)
    Posts
    701

    Default everythink is okay

    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=121484865 4">
    Attached Images Attached Images  
    Roger

  19. #19
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81

    Default Simplified circuit

    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
    Attached Images Attached Images  

  20. #20

    Default

    Quote Originally Posted by tekart View Post
    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

Similar Threads

  1. Switch mode power supply Pic Micro
    By iw2fvo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th July 2009, 13:11
  2. Replies: 3
    Last Post: - 29th April 2009, 00:45
  3. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 07:57
  4. Switch PIC16F877 ON/OFF
    By koossa in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th August 2005, 12:34
  5. Electronic 'Soft' Power Switch
    By Art in forum Schematics
    Replies: 0
    Last Post: - 10th August 2003, 23:50

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts