Single button Power Up/Power Down

Status
Not open for further replies.

Dimitri

New Member
Ever noticed how devices such as mobile phones have a single button that is used for both power up and power down?

I'm using a PIC microcontroller but I dont have many I/O pins to spare, and I was wandering if anyone had a neat hardware & software solution to achieving this.

Thanks,
Dimitri.


By the way:
(I've seen a circuit on the Tips'n'Tricks PDF from Microchip that uses the clk out of the pic to latch a FET which holds the power on however this kind of circuit can't use the same button to power down.)
 
use a flip-flop... a D-type flip-flop with inverted output tied to the input will toggle itself every clock cycle. you can make a flip-flop circuit out of discrete transistors if you are worried about board space
 
I suppose I could use a flip flop, but this poses two problems:

The first is that it will require some debounce circuitry, and I need to keep board space down.

The other problem, is that I would prefer not to just cut power to the Microcontroller, I want it to execute some shutdown code before the power is cut.
 
you could conceivably do both debouncing and time delay with a couple of capacitors and large value resistors...
 
All you need to do is connect the switch a set reset flipflop and an interrupt pin on your controller. Another controller pin is connected to the Reset on the Flipflop. The button sets the flipflop to turn on a pass transistor. To shut down the controller is interrupted by another button press, does it's shutdown code and then resets the flipflop to cut the power. You also probably want something that generates a delayed pulse if the button is held down to cause a hard power down in case your controller runs away.
 
sadly enough, the thing that would probably minimize board space is to program an 8-pin PIC to act as a power controller. it would just need to use one input and one output, and handle the debounce and timing.

horrendous overkill, using a PIC, but it would be really small if you use a surface-mount one
 
I am thinking about it, what you will handle to turn on/off the system
the power supply or the reset of the uC?

Will you shutdown the power supply? why you don't use and interrupt
it will save more energy, I think
 
You need only 1 I/O pin. When the button is pressed just make the pic go to sleep. Power consumption is virtually nothing for a pic in sleep. Another press to wake the pic up...

off course you'll have to use a pin that allows the pic to wake up (interrupt or wake up on port change, portB on most pics)

you can use a second pin as an output to control the power of any other devices you want turned on or off.
 
I had considered that, but like you said I would need to power down the other devices in the circuit as well, and that would require more I/O pins (a commodity that I don't have in plentifull supply. I can only spare one I/O pin).
 
Powering down is not really a great idea. It requires additional hardware and is not so versatile. What phones and other stuff do is all sleep mode. Sleep mode consumes so little power it might as well be off. For that, you either need an interrupt pin or you could have the internal oscillator timer wake the PIC periodically so it can poll a normal pin.
 
You didn't mention what PIC you're using. If it has an MCLR pin, then you can use that as ON/OFF. I remember someone used MCLR in a bootloader. You might connect a push button and a capacitor to generate a negative going pulse to reset the PIC and wake it up from SLEEP. The reset sequence may also be used to put a PIC to sleep.
 
Someware I seen a circuit using a SCR. The idea was to power the pic with the scr using the gate to turn in on. then when your code has finish put the pic to sleep. The current in sleep mode is less then the holding current of the SCR so it will shut off the pic.
 
motion: I'm using a PIC16F628A.

Maybe I will put the pic into sleep mode as suggested, but I'll probably isolate the power to the other devices on the board, and use a PIC I/O pin to switch the powersupply for those other devices on and off (such as a wireless transceiver). That way I can power them down when it's in sleep mode.
 
In the 627/628 chips, MCLR as well as OSC IN/OUT double as portA I/O pins. If the hardware design isn't fixed yet, you might consider using these pins as additional I/O.
 

That works quite well. I have done some very complicated projects with such a sleep feature and it works dandy. A logic level PMOS is necessary. If you need a regulator, then you're going to want to hunt down one with a low quiescent current. That current in a standard reg can easily be on the same order of magnitude that the PIC consumes in normal operation. You want to get that way down (or use a battery which doesn't go over 5v).

After you turn off the peripheral circuitry but before you go to sleep, you must not only change the input pins to outputs but also drive 0 to all pins, whether they used to be inputs or outputs.
 
Ozong:
I've currently got a 9V battery and a 5V regulator. I haven't yet got to the point of optimising the power supply. However it is tricky to get a power supply of 5V without a regulator, since 3 AA's gives you 4.5 volts. I know the pic will run all the way down to 3V, but the other devices wont (specifically my LCD screen which refuses to run on less than 5V, and my RF module which probably wont appreciate a lower voltage).
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…