Push Button Long press On/Off dual function

crutschow

Joined Mar 14, 2008
31,149
SW is just a voltage-controlled switch or relay to simulate a push-button.
Here's a reference for that.
V2 and V3 control the switch closure.
 
Last edited:
Would this work for a low amp 3.7v circuit?
Is there a parts list for this? 3.5s is just right.
How small of a package do you think you could make this awesomeness?
I would like to piggy back an existing button on a controller to switch off/on the controllers power on a long press, this should work if I'm not mistakin.

Any help is much appreciated
 

crutschow

Joined Mar 14, 2008
31,149
Would this work for a low amp 3.7v circuit?
Yes, the circuit will work down to 3V.
The simulation below shows it working at 3.7V.
upload_2018-8-5_0-36-21.png
Is there a parts list for this?
--- Bill of Materials ---
Ref. Mfg. Part No. Description
C1 -- -- capacitor, 22µF
C2 -- -- capacitor, 22µF
D1 OnSemi 1N4148 diode
D2 AOT AOT-2015 diode
D3 OnSemi 1N4148 diode
Q1 NXP 2N2222 bipolar transistor
R1 -- -- resistor, 237K, 1%, 0.1W
R2 -- -- resistor, 1K
R3 -- -- resistor, 100K
R4 -- -- resistor, 4.7K
R5 -- -- resistor, 10K
R6 -- -- resistor, 100
U1 (unknown) CD4013B (unknown 3rd party model)
U2 (unknown) CD4013B (unknown 3rd party model)
How small of a package do you think you could make this
You can make it quite small depending upon whether you are up to building in on a PCB with surface-mount parts.
 

sentinels

Joined Jun 30, 2019
13
Hello:

May I ask some question?
If I replace U2 by a RC time delayed circuit, will it work normally?
What is the function of R3, C2 ?
May I connect preset of U1 to GND?
Replace C2 by a small cap?
Will it work normally?

best regards
 

crutschow

Joined Mar 14, 2008
31,149
If I replace U2 by a RC time delayed circuit, will it work normally?
No, because U1 needs a fast clock risetime to work properly.
I don't add parts if they are not needed. :rolleyes:
What is the function of R3, C2 ?
Set the output to OFF upon power-up.
May I connect preset of U1 to GND?
Only if you don't care about the state of the output when it's powered up.
Replace C2 by a small cap?
It may not reset upon power-up if the power-up ramp time is slow.
 

danadak

Joined Mar 10, 2018
4,057
Udhaya, the following is an alternative way of doing stuff using micros that may be of interest.

Don't tackle this for your design, just consider new tools out there where you no longer have
to write code in the "standard" way.

Sanp4Arduino (and other block languages, mBlock, Scratch for Arduino, Ardublock) are
drag and drop gui blocks (left hand window) onto a canvas in middle of screen. You
configure them, then tell tool to upload to Arduino. Tool compiles project creating
Arduino code and then programs the Arduino.

Videos on web how to do this. Once you get comfortable with the tool you can program individual
UP chips, like the ATTINY85 and its variants. You use a low cost Arduino board to function as the programmer.

upload_2019-8-14_16-16-32.jpeg

Your design would look like this -

upload_2019-8-14_16-13-26.png

There are other block languages, all with their own "special sauce", and much in common. Once you
learn one the rest are easy to work with.

One other side advantage is you can look at the C code tool generates for you, should you desire to
delve deeply into micros.

Fun stuff, here in US 6'th graders are using tools like this to program basic robots.

The advantage over a discrete design is

1) No power up glitching
2) Minimal components
3) Timing accuracy (ATTINY85 is 2%)

upload_2019-8-15_19-24-48.png

Regards, Dana.
 
Last edited:

danadak

Joined Mar 10, 2018
4,057
An afterthought.

Should you decide to delve into block programming an excellent platform is
an Arduino Nano board. Cheap (ignore price shown on URL page), ~ $3,
and can be used at a later time to program parts like the ATTINY85.

Board has xtal on it so timing related jobs, like delays, pulse widths, tones etc.
very accurate

https://store.arduino.cc/usa/arduino-nano



Regards, Dana.
 
Last edited:

danadak

Joined Mar 10, 2018
4,057
Corrected pinout error, changed logical test for user holding button
longer than 5 secs so that when button hits 5 sec, LED turned on,
and then if user keeps holding button program waits until user releases
button before it starts a new "cycle" waiting for a button press.

upload_2019-8-17_10-15-40.png

Regards, Dana.
 
Last edited:

danadak

Joined Mar 10, 2018
4,057
Same program done in mBlock, very similar, small differences in block
usage. mBlock makes it easier to see code generated.

upload_2019-8-17_10-12-36.png


Regards, Dana.
 
Last edited:

ci139

Joined Jul 11, 2016
1,873
? (a "sequre" design :cool:) it 1-st determines whether the consuming circuit is ON or OFF ... then "selects" where to send a "TRIGGER Pulse"
Startup - Test - x010.gif M3 D9 C9 may need revision/re-design
 
Last edited:

danadak

Joined Mar 10, 2018
4,057
Here is a better way to debounce the button in mBlock.

This example just flips an LED on Arduino board, button set up has to
be pushed then released in order to flip LED. Button can be active high or
low depending on what you pass in DeBounce call as KeyState parameter.

upload_2019-8-29_10-47-0.png

Here is flow chart to show basic method to debounce a button.

upload_2019-8-29_10-54-26.png

Regards, Dana.
 

eetech00

Joined Jun 8, 2013
3,418
Yes, the circuit will work down to 3V.
The simulation below shows it working at 3.7V.
View attachment 157561

--- Bill of Materials ---
Ref. Mfg. Part No. Description
C1 -- -- capacitor, 22µF
C2 -- -- capacitor, 22µF
D1 OnSemi 1N4148 diode
D2 AOT AOT-2015 diode
D3 OnSemi 1N4148 diode
Q1 NXP 2N2222 bipolar transistor
R1 -- -- resistor, 237K, 1%, 0.1W
R2 -- -- resistor, 1K
R3 -- -- resistor, 100K
R4 -- -- resistor, 4.7K
R5 -- -- resistor, 10K
R6 -- -- resistor, 100
U1 (unknown) CD4013B (unknown 3rd party model)
U2 (unknown) CD4013B (unknown 3rd party model)

You can make it quite small depending upon whether you are up to building in on a PCB with surface-mount parts.
Hi

The LTspice BOM generator doesn't take into account the actual number of components within an IC package.
I'm sure you already know that, but for the TS's benefit, there is really only 1 CD4013B IC required.
The CD4013B IC has two D Flip-Flops in one package.

eT
 

sentinels

Joined Jun 30, 2019
13
Here's the LTspice simulation of a circuit that should do what you want.

D2 is your LED.

The CD4013 is two flip-flops in one package. You must add power and ground to that chip (not shown).

The delay time is determined by the value of R1 and C1.
The values shown give a delay of about 3.5s.

View attachment 118095
Dear Sir :

The upload file is some waveform.
Channel 1 yellow is PWR_BTN
Channel 3 Red is Q1
Channel 4 Green is Q2/ STB_CTRL
Sometimes Q2/ can not change status.
If I zoom in the waveform.
I found some glitch on Q1, so STB_CTRL change unnormally.
I do not know why there is glitch on Q1?
Could you help to solve this problem?
Thanks

Best regards
 

Attachments

crutschow

Joined Mar 14, 2008
31,149
I'm having a problem reading those files.
Just use the Upload a File button to upload them directly to your post without zipping them.
 
Top