Maker Pro
Maker Pro

single switch on off and mode select

P

panfilero

Hello,

I'm trying to come up with a way to only have one button, and use that to power my circuit on and off, and also to flip through different modes of operation.

For example, my circuit is suppose to blink an LED in different patterns,

click it once, turns on LED is on
click it again LED is blinking slow
click it again LED is blinking fast
click it again LED is blinking slow (any additional clicking just keeps cycling through these two states)
hold button down for 3 seconds and circuit turns off

I've come up with the circuit below (based it on something I saw on the EEVBlog, video blog)

I haven't breadboarded it yet, I'm not sure if it'll work... does anyone have any better suggestions on how to do this?

the link below shows what I came up with

thanks!


http://s555.photobucket.com/albums/jj477/panfilero/?action=view&current=Switch1.png
 
Hello,

I'm trying to come up with a way to only have one button, and use that to power my circuit on and off, and also to flip through different modes of operation.

For example, my circuit is suppose to blink an LED in different patterns,

click it once, turns on LED is on
click it again LED is blinking slow
click it again LED is blinking fast
click it again LED is blinking slow (any additional clicking just keeps cycling through these two states)
hold button down for 3 seconds and circuit turns off

I've come up with the circuit below (based it on something I saw on the EEVBlog, video blog)

I haven't breadboarded it yet, I'm not sure if it'll work... does anyone have any better suggestions on how to do this?

the link below shows what I came up with

thanks!

http://s555.photobucket.com/albums/jj477/panfilero/?action=view&curre...

something like this with an LDO with enable input (not tested!)

LP2981
Vbat .-----. VCC
o----------+-------------| |---------------o
| | |
| .---+EN |
o | | '--+--'
|- | |
o | | ===
| | GND
| |
+--|>|----+----|<|--------< HOLD
| | ____
+-------- | ----|____|--+-> switch input
| |
| |
.-. .-.
| | | |
| | | |
'-' '-'
| |
=== ===
GND GND


switch turns on regulator, mcu set HOLD to keep it on
switch input can see the switch state

maybe add a small cap on enable so the MCU has a bit of
time to set the HOLD pin

want to turn off, clear HOLD and wait for ever

-Lasse
 
P

panfilero

action=view&current=Switch1.png



You need to think really hard about currents flowing when you don't want

them to -- specifically, you want to avoid a parasitic path that'll power

up your microprocessor or some chip through an input pin, via the

protection diode.



reg'later

Vbat PNP .---. VCC

o---------------------- --------| |-------o-------o

v / '---' |

--- | |

| === |<

.----o----. GND .--| PNP

| | | |\

| | | |

.-. .-. .-. |

| | | | | | |

| | | | | | .-.

'-' '-' '-' | |

| | | | |

| | | '-'

| o-----|<----' |

| | |

hold_on ___ |/ o | | switch_open

o------|___|----| NPN |- o--------o

|> o | |

| | |

| | |

=== === ===

GND GND GND

(created by AACircuit v1.28.6 beta 04/19/05 www.tech-chat.de)



This circuit ought to do it -- no promises, think hard and maybe simulate

it, definitely bread board it.



"hold_on" and "switch_open" are a microprocessor output and input,

respectively. VCC is the microprocessor supply.



When the power is off and the switch open, all possible paths to the

microprocessor are via reverse-biased PN junctions.



When the switch is closed, the upper left PNP turns on; this turns on

power to the microprocessor.



The microprocessor should come out of reset, check the state of

switch_open, then set hold-on high for as long as it wants to stay on.



With power on, any time the switch is closed the PNP on the right will

turn on, switch_open will go low, and the microprocessor will see the

button press.



Make sure to check the state of the switch on power-up: the first time I

did a circuit like this I failed, and my system would reset but never

turn off! This was because I (wisely) put my filter caps after the main

PNP switch; the switch would open, VCC would decrease, the microprocessor

would go into reset -- then the electrolytics would bounce back, the

microprocessor would come _out_ of reset and turn the system on, and all

would proceed happily (well, except for me -- I was unhappy and

flummoxed).



--

My liberal friends think I'm a conservative kook.

My conservative friends think I'm a liberal kook.

Why am I not happy that they have found common ground?



Tim Wescott, Communications, Control, Circuits & Software

http://www.wescottdesign.com

hey thanks alot, thats a neat little circuit, but isn't your switch_open always tied low? seems like the micro would always see a low there regardelss of what you do with the switch

thanks!
 
P

panfilero

action=view&current=Switch1.png



You need to think really hard about currents flowing when you don't want

them to -- specifically, you want to avoid a parasitic path that'll power

up your microprocessor or some chip through an input pin, via the

protection diode.



reg'later

Vbat PNP .---. VCC

o---------------------- --------| |-------o-------o

v / '---' |

--- | |

| === |<

.----o----. GND .--| PNP

| | | |\

| | | |

.-. .-. .-. |

| | | | | | |

| | | | | | .-.

'-' '-' '-' | |

| | | | |

| | | '-'

| o-----|<----' |

| | |

hold_on ___ |/ o | | switch_open

o------|___|----| NPN |- o--------o

|> o | |

| | |

| | |

=== === ===

GND GND GND

(created by AACircuit v1.28.6 beta 04/19/05 www.tech-chat.de)



This circuit ought to do it -- no promises, think hard and maybe simulate

it, definitely bread board it.



"hold_on" and "switch_open" are a microprocessor output and input,

respectively. VCC is the microprocessor supply.



When the power is off and the switch open, all possible paths to the

microprocessor are via reverse-biased PN junctions.



When the switch is closed, the upper left PNP turns on; this turns on

power to the microprocessor.



The microprocessor should come out of reset, check the state of

switch_open, then set hold-on high for as long as it wants to stay on.



With power on, any time the switch is closed the PNP on the right will

turn on, switch_open will go low, and the microprocessor will see the

button press.



Make sure to check the state of the switch on power-up: the first time I

did a circuit like this I failed, and my system would reset but never

turn off! This was because I (wisely) put my filter caps after the main

PNP switch; the switch would open, VCC would decrease, the microprocessor

would go into reset -- then the electrolytics would bounce back, the

microprocessor would come _out_ of reset and turn the system on, and all

would proceed happily (well, except for me -- I was unhappy and

flummoxed).



--

My liberal friends think I'm a conservative kook.

My conservative friends think I'm a liberal kook.

Why am I not happy that they have found common ground?



Tim Wescott, Communications, Control, Circuits & Software

http://www.wescottdesign.com

hey thanks alot, thats a neat little circuit, but isn't your switch_open always tied low? seems like the micro would always see a low there regardelss of what you do with the switch. Should there be a resistor between the switch_open and ground?

thanks!
 
Top