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.

One button on/off system

Status
Not open for further replies.

TKS

New Member
Hi

is it possible?

would it work if i i connected VSS to the emiter of an BC transistor.

then i would connect the emiter to the real VSS

when i press the button it applies VDD (5volts) to the base with in series a 10K.

when the pic turns on it puts an pin high wich over rules the switch.

when i press the button also it connects an pin to ground (pull down)

Then the pic knows it needs to shut down, when it can it will lower the on pin and it will shutdown.......

will it work?

TKs
 
Your description is confused.

I would use a PNP transistor. Connect the emitter to the "real Vdd" and the collector to the Vdd line.

Then connect the 10k resistor to the push button and the other side of the PB to gnd (ie. the Vss line).
I don't know what current your circuit requires, so 10 k may be too high.

Connect another resistor from the base to an i/o of the PIC. Configure this i/o as an output and set it low in the initialising routine. When the PIC wants to turn the power off, it sets this output high.
 
ljcox said:
When the PIC wants to turn the power off, it sets this output high.

The solution works when the PIC knows when to turn off the power. But one must enable the PIC brown-out protection while the PIC is shutting down.

If user wants to turn off the power at any time then first the PIC must monitor the state of the push button and sensed it is pressed by the user. Your configuration bypassed the push button to Vss and make sensing difficult.

Possible solution(s), untested:

1. use a push button with two pair of contacts and use one additional PIC pin for sensing.

OR:

2. use only one PIC pin with P-Ch MOSFET and gate capacitor to keep the MOSFET turned-on while momentarily toggle the PIC pin to input mode and sense the state of the button. Some resistors and diode will be needed to make the this scheme work.
 
Forget your original idea.

Just use a CD4013 or a 74xx47 D-flip-flop, and connect the reset and set pins to -ve (for CD4013) or +ve (for 74xx47).

Connect the D to the Q' (or Q with a line on top of it) output.
Connect the CP (clock) to ground through a pull-down resistor.

Connect VCC to +5V (your +ve) and GND to -ve.

All you have to do is connect a button to CLK and VCC. Each press will invert the last Q output.
 
eblc1388 said:
ljcox said:
When the PIC wants to turn the power off, it sets this output high.

The solution works when the PIC knows when to turn off the power. But one must enable the PIC brown-out protection while the PIC is shutting down.

If user wants to turn off the power at any time then first the PIC must monitor the state of the push button and sensed it is pressed by the user. Your configuration bypassed the push button to Vss and make sensing difficult.

I assumed that there is some other trigger other than the push button that tells the PIC when to turn off. Certainly, if you want to use the push button to trigger the switch off then extra logic is required. For example, another i/o could be configured as an input to monitor the state of the button. A second pair of contacts on the push button is not necessary.
 
ljcox said:
A second pair of contacts on the push button is not necessary.

ljcox you're right. It can be done with just one pair of contact and two PIC pins.

The shutdown process is a relatively "long" one as many PIC instructions can be executed during the process with the Vdd dropping continuously. I am thinking whether it is advisable to place the PIC into SLEEP mode immediately after removing the LOW on the port pin that latch the PNP transistor ON.

Comments anyone?

This is an interesting and useful feature to implement on the PIC. I would definitely try to pursue a working setup when I can get around to do it.
 
I did not understand your point "enable the PIC brown-out protection while the PIC is shutting down". (I know about the "brown out" but don't understand why it would be necessary here - I'm not disagreeing, just curious)

Putting it into sleep may be a good solution. I don't know enough about the PIC Internals to be sure.
 
ljcox said:
I did not understand your point "enable the PIC brown-out protection while the PIC is shutting down". (I know about the "brown out" but don't understand why it would be necessary here - I'm not disagreeing, just curious)

I have seen users reported in Microchip forum that the operation of the PIC is erratic with gradually reducing Vdd to the point that the port pin is pull low again thus preventing the PIC to complete the shutdown process. As I said, the process(milliseconds for Vdd to die down, possibly longer) is very long in PIC's timing.
 
Preferrably you'd always apply power to the PIC and make the "switch" a normal PIC input. "OFF" would just be sleep mode, pressing the switch triggers an interrupt which wakes the PIC.

Main downside is that although the PIC's sleep mode current can be quite low, if a reg is required then the reg will probably take much more current than the PIC itself. Also enabling the BOR and possibly WDT will raise the PIC's sleep current somewhat.
 
I will just add my 2 cents here, last time I tried to let a PIC turn off power to itself it didn't go very well to say the least :lol: it wound up in a cycle turning itself off and on repeatedly.

Not to say it can't be done; I just didn't take the time to sort it out for my application. you just have to watch out for the behavior of the PIC when it browns out like that.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top