6
\$\begingroup\$

I am trying to make a button control on/off and reset all in one, but I can't quite get my head around how to design it.

It should basically function like a PC power button. If short press it's either on or off, depending on state, and a long press is the reset that works when something completely locks up the computer. The on/off is easy as that's software controlled, but the reset has to be in hardware somehow as it has to ALWAYS work, no matter the state of the software or MCU.

The reset functionality should kick in after a long press of about 5~10 s. Once the reset signal goes low it should stay low for >10ms. How to do this?

I can find dedicated IC's that can set a signal low for x ms, which would work, but how do I trigger them in a good way? RC and then a comperator to trigger at a set voltage or...? And how do I avoid triggering the reset when starting up if using the RC approach?

Any help would be appriciated.

\$\endgroup\$

3 Answers 3

3
\$\begingroup\$

You could use a RC delay circuit.

A simple one is made out of a resistor and a capacitor. For example, charge the capacitor, attached to ground, through a pull-up resistor R1. Then discharge through another resistor R2 and the "long-press" reset button to the ground. The trick is to calculate the values of C, R1 and R2 to make the timings right, so that the capacitor slowly discharges to the digital zero threshold. Then the signal at the junction could be used for (inverted) reset signal.

You could add an inverter to make the reset signal more robust.

Here is an online calculator to estimate the delays: http://ladyada.net/library/rccalc.html

\$\endgroup\$
3
  • \$\begingroup\$ Something like the circuit diagram in Fig. 2 of Jack Ganssle's eng.utah.edu/~cs5780/debouncing.pdf , page 12? \$\endgroup\$ Commented Jul 27, 2015 at 20:35
  • \$\begingroup\$ @CamilleGoudeseune that might also work, although not exactly what I described. Note, that the question asked for a digital signal as well for on/off duty. That would be taken at the switch, and also might need debouncing, depending on the consumer of the signal. Some chips have debouncing built-in. \$\endgroup\$
    – elomage
    Commented Jul 28, 2015 at 22:26
  • \$\begingroup\$ Note that it shouldn't reset if the button is pressed repeatedly, so the RC needs to be reset as soon as the button is released. \$\endgroup\$
    – endolith
    Commented Dec 7, 2016 at 17:59
1
\$\begingroup\$

You can use a push-button/reset driver IC. These can automatically detect long presses, simultaneous presses of multiple buttons, etc. There also exist versions with a built-in watchdog timer, or brown-out detection, which will automatically reset your microcontroller if it hasn't responded within some time or if the voltage drops below an acceptable level, respectively.

An example is the TPS3422: https://www.ti.com/lit/ds/symlink/tps3422.pdf

\$\endgroup\$
0
\$\begingroup\$

Use a microcontroller that receives the button signal and drives the reset and on/off lines accordingly. Even the tiny PIC 10F200 can do this job easily. It comes in a SOT-23 6-pin package, with one input line and 3 I/O lines. You'll even have a extra I/O line left over.

The first thing the micro needs to do is debounce the button. This creates a debounced button signal internally. The rest is counting time to see how long the button is pressed. Depending on the length of time, the code either toggles the on/off line or asserts the reset line. You can also do the logic so that any press when off turns the unit on, since reset doesn't make sense when off.

The dedicated input pin of the 10F200 can have a internal pullup, so the only hardware you need is the button, the 10F200, and its bypass cap. Yes, it really is that easy.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.