Electronic – How to turn a Latch circuit from Press-ON/Press-OFF to Press-ON/Hold-OFF circuit and how to make it auto-off when power is first connected

circuit-designintegrated-circuitlatchne555

I'm building a Latching circuit using 555 IC. The schematic is as follows:
enter image description here

The Input voltage is 12V and is used to operate the 555 IC that switches a relay coil through a transistor.
When the circuit is implemented on a breadboard, it turns on when the power is first connected. How can I change it to be off when power is first connected? Also, it turns on when button is pressed and then off when pressed again. How to make it turn off by long press?

Best Answer

Behavioral Overview

Although a SOT-23-6 MCU is the obvious approach, if you want to avoid the toolchain and coding work involved in using one, then the following timing diagram illustrates one approach:

enter image description here

  • pwr is a power-on flip-flop that is clocked by clk. It is reset by a power-on event.

  • long is a one-shot with a long time period that represents your long-press period. It is always triggered by the rising edge of your push-button. It is assumed that its time is very much longer than the debouncing time required by the push-button when pressed.

  • clk is a one-shot with a time period long enough to form a good clocking pulse for the pwr FF and also long enough to cover the debouncing period required when the push-button is released. It is triggered by the falling edge of your push-button when \$\overline{\textbf{long}}\:+ \:\overline{\textbf{pwr}\vphantom{\textbf{long}}}\$.

  • PB is the push-button.

The power will be engaged upon the release of the initial power-on button-press (any short press will work) and will continue until very shortly after the release of a long-press of the button. If the button-press is too short to turn the power off then the falling edge of PB will occur before long goes low and, as both long and pwr are still high, clk will not be triggered and pwr will remain active.

Again, if the toolchain and coding effort is acceptable to you then a SOT-23-6 MCU would be a better choice here. Small, cheap, programmable to your specific needs, etc. But if that's a problem, then I think you are asking for something like the above.

555 Design

To implement the above with 555 devices would require something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

The power-on reset signal is generated by an RC and a CD40106B Schmitt inverter. This will be used to generate a clean reset for the circuit.

(There are six Schmitt inverters in the CD40106B package and this circuit uses three of them. So the package will be half-used.)

The push-button is just a pull-up resistor and the switch to ground.

There are two one-shots made out of the 555 IC.

The first (at bottom, above) provides a long timing pulse that is triggered by the rising edge of the PB input. You can adjust the resistor or capacitor values that are attached to the discharge and threshold pins to adjust the long timing period to your liking. I've set it here to about \$3\:\text{s}\$.

The second (at top, above) provides a short clocking pulse for the power FF that is triggered by the falling edge of the PB input. However, in this case, there are times when we don't want to allow the short clocking pulse. So the BJT transistors are added here, along with four resistors, to form a circuit designed to inhibit the clock pulse generation when both LONG and PWR are both HIGH. Otherwise, it's allowed.

Finally, there is the power-on state FF portion. You can use its output to drive a BJT circuit that activates your relay, for example. Or for other purposes. It's active-HIGH. This uses the CD4013B IC, which contains two FF devices. (Only one is used.)

Here's an illustrative output from a run on LTspice of the circuit:

enter image description here

Above, you can see the push-button events on the bottom green curve. (I had to sum three separate switches in LTspice to emulate that.) The next up, red, is the PWR output. You can see that it is switched off when the push-button is held for \$3\:\text{s}\$ but that it is not switched off when the push-button is held for \$2\:\text{s}\$ on the second attempt (right half.) Above that, light blue, you can see the LONG timer output. It responds to the rising edge of the push-button and is used to measure the duration of the push-button. And finally at top, in violet, is the CLK that drives the PWR FF, if the falling edge of the switch is allowed to pass through to it.

Now you can see why no one ever did this until MCUs were available. With an MCU, it's just a cheap, tiny, push button switch and a user who is now forced to learn that holding a switch for a while turns things off.

(There is another use, which is that the MCU isn't forceably turned off when it's not expecting it. It's allowed to 'do things' before turning off or to go into a sleep mode. None of which applies in your case.)

A question might be, "Why would you go to all this trouble just to emulate an MCU rather than simply use a slide or toggle switch?" It's easy. 'On'/'Off'. And more available around the world, too.