Hold down button for > 3 seconds gives a 200ms 0V logic pulse at 3s

Thread Starter

bmbouter

Joined May 29, 2021
75
Right now my circuit uses a button to pull down a GPIO line of a microcontroller which is pulled up otherwise (see schematic picture). Right now when you press the button the GPIO line drops to 0V and when you release the button it goes back to 3.3V.

What I want to do instead is not have the 0V drop when the button is pressed but 3 seconds after it is pressed. Ideally, I want it to drop and then re-raise back to 3.3V with a <200ms pulse. I drew this as "Ideal Solution" attached picture.

If that's not easy then an acceptable solution is to have the voltage raise back to 3.3v when the button is released as long as it was held for at least 3 seconds. See this voltage diagram as "acceptable solution".

How can I do this with basic components? Or if not basic components, cheap components.

Also note the microcontroller is sleeping during all of this. This is an external wakeup circuit, so I can't use the microcontroller in any way to solve this problem.
 

Attachments

Last edited:

ElectricSpidey

Joined Dec 2, 2017
2,758
Off the top of my head.

Button
R/C to 555 (set up as comparator/Schmitt trigger with output high) or actual comparator.
Capacitor coupling to second 555 configured as one shot.
Inverter

Parts:
556 or 555 and comparator.
Some resistors and capacitors
1 Transistor
 
Last edited:

Ya’akov

Joined Jan 27, 2019
9,071
Right now my circuit uses a button to pull down a GPIO line of a microcontroller which is pulled up otherwise (see schematic picture). Right now when you press the button the GPIO line drops to 0V and when you release the button it goes back to 3.3V.

What I want to do instead is not have the 0V drop when the button is pressed but 3 seconds after it is pressed. Ideally, I want it to drop and then re-raise back to 3.3V with a <200ms pulse. I drew this as "Ideal Solution" attached picture.
Is there some reason you are not just doing this in software?
 

Thread Starter

bmbouter

Joined May 29, 2021
75
Yes doing it in software would be ideal. Alas I can't because the microcontroller is effectively off and this is the circuit that wakes it up. Specifically the microcontroller wakes up on the rising edge of this signal I've drawn.

I kind of imagined for the "acceptable solution" option that a capacitor and resistor combination would provide a slow drain, effectively slowing down the voltage drop from the 10k pull down ground connection. That's my naive thought.

I'll give some thought to the comparator circuit also.
 

Ya’akov

Joined Jan 27, 2019
9,071
I’d consider an ATTiny13A. It’s 8 pins and only needs a decoupling cap to run. It can be programmed in the Arduino IDE, and is dirt cheap.
 

crutschow

Joined Mar 14, 2008
34,285
If the timing is not critical, then you could do your third picture option where the button release ends the pulse, with a couple resistors, a diode, a capacitor, and a small N-MOSFET.
Otherwise you could use a 555 one-shot with an RC delay on the trigger input to do the second option.

Is the operating power of the circuit critical?
 

LesJones

Joined Jan 8, 2017
4,174
You say that you are pulling the GPIO pin down to zero volts but the circuit shown in post #1 will only pull it down to 1.43 volts. Why are you doing it like that ? This is probably in the rage that is neither considdered as a logic one or logic zero.
If you MUST verify the trigger waveform externaly then I agree with Ya'akov's suggestion of using an ATTiny13A .
I don't understand why you can't wake up your microcontroller on the falling edge of the trigger signal and then have code running that delays 3.2 seconds and then jumps to the actual code that you want to run.
I am not clear if the input signal has to be held low for the 3 seconds or just a delay of 3 seconds before the required 200 mS pulse is generated.

Les.
 
How about using two one-shots (one dual one-shot CD4538 or similar) cascaded? CD4538 provides both positive and negative level inputs and output, and it should be pretty easy to configure a solid solution. CD 4538 should be powered from as low as 3V.
 

ElectricSpidey

Joined Dec 2, 2017
2,758
Here is my solution for what it's worth.

As configured the circuit uses power only while the button is pressed.

Button can be pressed for longer than 3 seconds and the output pulse will remain the same.

I don't have a model for the low power 555s so I used 5 volts to power the circuit, but I'm pretty sure low power 555s will work, maybe needing some adjustments. low power 555s can use the 3.3 voltage.

1679074341256.png
 

crutschow

Joined Mar 14, 2008
34,285
Here's the simulation of a circuit that should do what you want, using a CMOS 555, such as the LMC555 with less than 200μA quiescent current at 3.3V:
D1 prevents the immediate retriggering from the PB still being depressed after the pulse has occurred.

The <0.2s reset pulse (yellow trace) occurs ≈3s after the push-button (green trace) is pressed.

1679093013828.png
 
Last edited:

ElectricSpidey

Joined Dec 2, 2017
2,758
Yes I noted that.

Would you be so kind as to post the CMOS subcir and that .asc...thanks

Nice, I see how you diverted the trigger voltage...you are the man.
 

crutschow

Joined Mar 14, 2008
34,285
Would you be so kind as to post the CMOS subcir and that .asc...thanks

Nice, I see how you diverted the trigger voltage...you are the man.
I have a CMOS 555 subcircuit model but I couldn't get it to work, so I just used the NE555 idealized model, which is close to the CMOS version in operation (output goes to the supply rail, for example).
I just labeled it as a generic CMOS 555.

Attached is the .asc file.
 

Attachments

Last edited:

MisterBill2

Joined Jan 23, 2018
18,176
Right now my circuit uses a button to pull down a GPIO line of a microcontroller which is pulled up otherwise (see schematic picture). Right now when you press the button the GPIO line drops to 0V and when you release the button it goes back to 3.3V.

What I want to do instead is not have the 0V drop when the button is pressed but 3 seconds after it is pressed. Ideally, I want it to drop and then re-raise back to 3.3V with a <200ms pulse. I drew this as "Ideal Solution" attached picture.

If that's not easy then an acceptable solution is to have the voltage raise back to 3.3v when the button is released as long as it was held for at least 3 seconds. See this voltage diagram as "acceptable solution".

How can I do this with basic components? Or if not basic components, cheap components.

Also note the microcontroller is sleeping during all of this. This is an external wakeup circuit, so I can't use the microcontroller in any way to solve this problem.
Here is a simple scheme that will work IF the GPIO line can handle an input that is not changing rapidly:The 22K from +3.3 volts to the input stays, and the input is also connected to the collector of a small NPN transistor. The emitter of that transistor is connected to the processor common/ 3.3volt common. A capacitor, 4.7 MFD, is connected between base and emitter of the NPN transistor. The button is connected between the +3.3volt source and the base of the transistor by a 100K resistor.
Pressing the button starts to charge the capacitor thru the resistor. When the BE voltage exceeds 0.7 volts the transistor starts to conduct, pulling the GPIO input low after some time interval. SO there may be a bit of experimenting to get the time correct. After the system awakes the button must be released. Probably some code will need to be added to ignore that input for a while after the processor wakes up. This scheme takes no standby power and will not take much space, either.
 

Thread Starter

bmbouter

Joined May 29, 2021
75
Thank you all for the wonderful discussion. I see several viable solutions, and I'm going to explore them some with LTSpice. I've never worked with the infamous 555 before, so this will be a great chance to learn. The RC solution from MrBill was what I was vaguely imaginging, but I couldn't actually put it all together.

Thank you all! As always, I'm learning with your help.
 
Top