Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Push Button On/Off power to PIC

Status
Not open for further replies.

eblc1388

Active Member
I have designed the following circuit to let me control the power supply to a PIC using a single push button.

Most circuits I have seen requires two PIC pins but mine needs one only. I have built and tested the scheme and it works everytime.

If you would like to try the design, please report back to the forum whether it works or you are experiencing any problem.

The key point to its requirement is the "Brown Out Reset" protection of the PIC, which must be enabled.

Enjoy.

Code:
;**********************************************************************
;                                                                     *
;    Filename:      lf876_OnOff.asm                                   *
;    Date:          17-FEB-2006                                       *
;                                                                     *
;    File Version:  0.0 - Single button PIC Power On/Off              *
;                                                                     *
;    Author:        L.Chung                                           *
;                                                                     *
;    When a PB is pressed, power is provided to the PIC and LEDs      * 
;    and the PIC works normally. When the PB is pressed again and     *
;    released, power is turned off waiting for next PB activation.    *
;                                                                     *
;    Special point: Only one PIC port pin is needed for this setup    *
;                   Zero current drain in OFF mode                    * 
;                                                                     *
;**********************************************************************
;                                                                     *
;    Ext Files required: None                                         *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes: Crystal freq: 11.0592MHz                                  *
;           instruction cycle timing: 361.69ns per cycle              *
;                                                                     *
;           Power_sense pin: RB1 ; any Pic I/O pin (except open drain)*
;                                                                     *
;                                                                     *
;**********************************************************************
;
;                   Push Button                  Push Button
;                       _/                     PIC Power On/Off
;       +-------------o/  o--+                Using one pin only
;       |                    |
;   +5V |                    |
;    ---o----+^+--------------)-------------------+
;       |    |||             |                    |
;      .-.   ===             |                    | Vdd
;      | |   |   P-CH        |         .----------o---------.
;      | |   |  MOSFET       |         |                    |
;      '-'   |               |         |                    |
;       |    |               |         |                    |
;       +----o               |         |                    |
;     100K   |               |         |        P I C       |
;            |               |         |                    |
;            |               |         |                    |
;            +-||       4M7  |  100R   |                    |
;       N-CH ->||       ___  |A  ___   |                    |
;     MOSFET +-||---o--|___|-o--|___|--o P                  |
;            |      |        |         |                    |
;            |     ---      .-.        |                    |
;            |     ---      | |        | .-----------------.|
;            |      | 30PF  | |1K8     | |  Designed by:   ||
;            |      |       '-'        | |                 ||
;            |      |        |         | | L.Chung Feb/06  ||
;            |      |  .-----o         | '-----------------'|
;            |      |  |     |         '---------o----------'
;            |      | .-.    V ->                | Vss
;            |      | | |    -                   |
;            |      | | |10K |  LED              |
;            |      | '-'    |  Power            |
;     0V     |      |  |     |                   |
;     -------o------o--o-----o-------------------o------------
; -(created by AACircuit v1.28.6 beta 04/19/05 [url]www.tech-chat.de)[/url]
;
; Design logic:
;    
; A P-channel MOSFET is used as the main power switch and another N-Channel
; MOSFET pulling gate of P-Ch MOSFET down to GND to hold it on. The Gate of the 
; N-Ch MOSFET is controlled by the PIC via 4M7+100R resistors. When all is off,
; there is zero battery current drain.
;
; When the PB is pressed, power is fed to A and the gate of the N-Ch MOSFET
; via the 4M7 resistor. Because of the internal protection diode of the PIC, 
; a 100R resistor is needed. N-Ch MOSFET conducts and pulldown gate of 
; P-Ch MOSFET. It too conducts and powering up the PIC.
;
; All this take little time and after the PIC is started up, PIC sets pin P as
; input pin and goes into an infinite loop checking for the pin P level to 
; go LOW, which happens when user released the push button. As long as user
; keep pressing the button, a logic HIGH will be read by the PIC.
;
; When user released the button, the N-Ch MOSFET does not immediately shutoff
; because of the charge retained on gate capacitance and the added 30pF capacitor.
; However, the charges will discharge via 4M7 resistor and the 1K8+10K resistors
; eventually to 0V. Because of the large divider ratio between these resistors,
; PIC will read back a logic LOW and detected that user has released the button.
; Once a LOW is detected, PIC would reconfigure the Pin P into an output pin
; and outputs a HIGH to keep the N-Ch MOSFET in conduction. All these happens in
; the time span of a few PIC instructions, which is far far less than the RC time
; constant of the gate RC circuit.
;
; After an additional wait of 200mS in software to let the switch contact
; bounce to die down, the main user program is executed.
;
; PIC then starts periodic checking pin P, either in routines or during
; Interrupt. First it changes pin P into an input pin and read the logic level
; on it. If a LOW is read, the pin is set back to output with a HIGH. 
; All this happens in a few instructions and the existing RC combination will keep 
; the N-Ch MOSFET in conduction regardless. This indicates that user has
; not pressed the push button yet.
;
; However, if a HIGH is read, it means user is now pressing the button. Once this
; is detected, PIC executes shutdown sequence, and when it is ready to shutdown
; the PIC, it sets Pin P as input and then outputs a LOW to the PORT register,
; just in case. It doesn't matter whether user has released the push button.
; Shutdown is going to happen anyway. It then goes and executes an infinite loop.  
;  
; After the user released the push button or when the PIC changed the pin P into
; an input pin, N-Ch MOSFET gate capacitance and 30PF start discharging 
; via the 4M7 & 1K8+10K resistor. N-Ch MOSFET starts turning OFF. 
; P-Ch MOSFET starts turning OFF and supply voltage to PIC gradually reduced. 
; This is where PIC Brown Out protection comes into effect. The PIC is held 
; in reset state as voltage decreases to zero. 
;
; Actual tests on a PIC showed that the scheme works perfectly.
 
Just out of interest, what kind of voltage drop are you getting across that fet in the supply line? ( ie, what fet did you use? )

I'm currently designing something similar with a 'soft' on/off, but all I am doing is using an interrupt - my application shuts down into ultra low power consumption when in-active, but of course that doesn't suit every application.

Mike.
 
MikeHibbett said:
Just out of interest, what kind of voltage drop are you getting across that fet in the supply line? ( ie, what fet did you use? )

I have just measured it to be 120mV.

The P-MOSFET is BS208 and the N is BS170, supplying a 16F876 running at 11.0592MHz flashing two LEDs.
 
Interesting, the spec sheet for that P type fet suggests an Rds of about 7 ohms.

I guess you must be consuming about 20mA? My problem is that I have peak currents of around 300mA, which would produce an unacceptable drop between drain and source. Ho hum!

Mike.
 
MikeHibbett said:
Interesting, the spec sheet for that P type fet suggests an Rds of about 7 ohms.

I guess you must be consuming about 20mA? My problem is that I have peak currents of around 300mA, which would produce an unacceptable drop between drain and source. Ho hum!

Mike.

The design places no restriction on what P-Ch MOSFET to be used, as long as its gate works with logic voltage level.

I'm not sure whether you can get one with low enough Ron that also works with logic gate voltage level.
 
Nice idea! - but is it worth the extra parts over just putting the PIC in sleep mode?. A PIC correctly put in sleep mode will probably use less power than the shelf life of the batteries feeding it?, and save the cost of the extra parts.

But it's still clever! :D
 
MikeHibbett said:
Interesting, the spec sheet for that P type fet suggests an Rds of about 7 ohms.

I guess you must be consuming about 20mA? My problem is that I have peak currents of around 300mA, which would produce an unacceptable drop between drain and source. Ho hum!

Mike.

Search the Net for those modern P-Ch MOSFETs, they are logic level and have very very low Ron. See an example below.

I am sure other forum members can recommend several part numbers to you too.
 

Attachments

  • low_ron.gif
    low_ron.gif
    4.6 KB · Views: 812
My original searches found that low Rds fets are either hard to get or expensive - in the end, for my app, putting the attached devices into low power mode and the pic into sleep was the best solution. The total consumption is so low I'm finding that the self discharge characteristics of the battery is more important than the standby power consumption!

The NanoWatt PIC's are great devices :eek:)
 
Hi gentlemen,

There might be other things on the supply rail which one can't put to sleep. I thought the 11.0592MHz crystal frequency would give it away.

Let's start first by putting my MAX232 to sleep. :shock:

MikeHibbett said:
My original searches found that low Rds fets are either hard to get or expensive...
The following MOSFET is from Rapid Electronic UK, reasonably priced. The voltage drop at 0.3A is around 120~150mV with -4.9V Vgs from manufacturer datasheet.
 

Attachments

  • low_rds.gif
    low_rds.gif
    9.5 KB · Views: 801
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top