I am trying to construct a latching circuit with a 1-2 minute shutdown delay so I can soft start/stop a 240V-5V power supply.

I am looking for a momentary push latching (on-off) circuit to switch the 240V supply that will work like this:

---Push once (irrespective of push duration) the circuit latches and switches the 240V supply to a 240V-5V power transformer.

---Push again (irrespective of push duration), the latching releases but the 240V supply continues running to the 240V-5V transformer for a set time (approximately 1.5 minutes) and then the 240V supply is disconnected.

I have previously used a latching circuit I found online http://www.electronics-lab.com/project/toggle-on-off-switch/ and have found a "Power off delay" thread here How can I add a power-off delay to this circuit.

Because my skill level is low I am thinking about combining the two circuits with the relay in the latching circuit replacing SW1 in one of the options provided by Olin Lathrop and EM Fields.

So my current plan is to simply use a rely to connect the seperate soft start and power off delay circuits. However I am wondering if there is a simpler way (I am sure there will be) to integrate the latching circuit into one of the Power off delay options? Or is there a better alternative?


  • \$\begingroup\$ Do you want something that uses a momentary switch, but where once pressed the circuit stays powered for some specified delay time and is then automatically switched off? What happens if the push button is held down for a while? Is this to disconnect the 240 V side or the 5 V side? \$\endgroup\$ – jonk May 9 '17 at 6:03
  • \$\begingroup\$ I need something that uses a momentary switch that with one push will start and the next push will stop the power supply. \$\endgroup\$ – Barnys May 9 '17 at 6:55
  • \$\begingroup\$ Oh. So what is the "off delay" exactly? I guess I was not able to read your words with any understanding. Must be just me. But I can't tell what you want, I guess. I thought I saw you say "delay." But now you say just "toggle?" \$\endgroup\$ – jonk May 9 '17 at 6:58
  • \$\begingroup\$ Sorry, I somehow only posted part of my reply. The delay off function will allow the power supply to continue running for a period after the pushbutton/latching circuit has released. I want to switch the 240v (input) side so the all subsequent circuits will be off. R.e. “What happens if the push button is held down for a while”; irrespective of push duration I would like the push function to only act as a momentary push. I have a permanent 12V supply available to run this. \$\endgroup\$ – Barnys May 9 '17 at 7:07
  • 1
    \$\begingroup\$ Okay. It would be a good idea to edit your question to be thorough and careful in your wording and to discuss all corner cases, clearly. \$\endgroup\$ – jonk May 9 '17 at 7:09

enter image description here

Good news, I have hit it with a stick a lot, made some guesses, then some changes and have managed to get a result...

I couldn’t get the existing flipflop to work without the timer so I looked at some CD4013 on-off circuits online (and built one to make sure my components weren’t faulty). The result being I combined the flipflop I built with the circuit provided by Jonk. The timer circuit is the same, but the flipflop C2, D4 and R4 area is now a bit different and I have grounded pins 4 and 6 on the CD4013. LED 1 and R6 don’t have an impact on the operation; they are there so I can see when the flipflop switches.

When the circuit is off I am seeing the base of Q2 sitting at 11.27V (collector at 0.01V) and when the button is pushed the base drops to 10.95V (collector rises to 11.65V). The power supply is stable at 11.8V. In its off state (standby) the circuit appears to be consuming about 21mA including LED1 which is on when the circuit is in standby. When active it consumes 87mA which includes the relay and 2 LEDs indicating the relay has switched to the NO pins.

I am interested to hear if this circuit can be improved and/or if the Volts and mA I have recorded are good or could be better...


Edit; I have found the circuit switches on and switches the relay when the power is connected. The flipflop and timer delay work correctly after that. Is there a way to prevent the self starting with power on/the main power supply is connected?


I believe I now have it working well. Irrespective of button press speed-duration there isn’t any bounce, the off timer duration is (now) consistent, the collector voltage on Q2 is now stable, the Q2 switching base voltage is now around 0.8V (I was seeing less than 0.5V) and the relay is off when powering up the circuit. With the exception of the inclusion of C2 and D4 and a change in the values of R4 (100R) and C3 (100nF) it is basically the same as the one Jonk posted.

enter image description here


I'll provide an approach. I haven't reviewed the CD4013B datasheet well enough, so take it with a grain of salt. But the following might be an approximate solution:


simulate this circuit – Schematic created using CircuitLab

I've chosen to use \$V=12\:\textrm{V}\$ here. It is NOT designed for any arbitrary load, though. It can handle up to \$250\:\textrm{mA}\$. Perhaps more. But it can certainly drive an appropriate relay as the load if you would prefer that.

The "T" showing for the CD4013B is really the "D" input of the device (darned schematic program here doesn't have a full D-FF picture.) You can adjust \$C_1\$ and \$R_3\$ to get you where you need to be, but this would be in the area of 1.5 minutes. \$SW_1\$ is assumed to be a momentary push button that either powers the LOAD (first time) continuously or else (second press) initiates the start of the timed interval.

Here's a simulation of the output, where the RED line is the momentary push of the push-button and the GREEN line is the application of power to the LOAD. The first push turns the device on and does not time things. The second push allows the timing period to start.

enter image description here

The circuit is really two parts: a flip-flop and a timer. This whole thing could be replaced by a sot23-6 or DIP8, 50 cent microcontroller. But if you don't have the ability to program something like a PIC10F200, then this is where you wind up. I'd go with the PIC10F200, because the above circuit is far too much to do for something so simple with a micro.

The above example is probably one good reason among many why almost any electronics engineer these days must also have at least some experience programming microcontrollers, along with using the associated tools properly.

Circuit description:

The basic idea is this:


simulate this circuit

When active, the timer's output connects almost directly to the \$+12\:\textrm{V}\$ supply rail and is able to source \$250\:\textrm{mA}\$ into a grounded load. So any load attached to \$OUT\$ can expect to see \$+12\:\textrm{V}\$ with a current compliance up to about \$250\:\textrm{mA}\$ (when the timer is active.) Otherwise, the timer's output is high impedance and therefore "tied towards ground" by the load itself, if present.

\$C_1\$ and \$R_3\$ form a timing circuit. Normally, this RC timing circuit is inactive because the timer's \$V_{OUT}\$ is inactive. So there is about \$0\:\textrm{V}\$ across \$C_1\$ and across \$R_3\$ and the \$THRH\$ input is close to ground. Also, the D-type flip-flop should be in its reset state with \$\overline{Q}\$ high, keeping \$Q_2\$ off and inactive so that \$R_4\$ also has no impact on the RC timing section. This is the "inactive" case.

At the moment when \$SW_1\$ is closed, it pulls upward rapidly on \$C_1\$ through \$D_3\$ causing that end of \$C_1\$ to rapidly reach perhaps \$+11.5\:\textrm{V}\$. Since \$C_1\$ has little or no voltage across it, this also means that the timer's \$THRH\$ input is pulled to about the same voltage, as well. This causes the timer circuit to activate and cause \$V_{OUT}\approx +12\:\textrm{V}\$. Now, \$D_3\$ is no longer providing any function and \$SW_1\$ becomes irrelevant (de-bounced, in effect) for a time. Now, the timer itself is holding one end of \$C_1\$ high, allowing a small current to flow in \$R_3\$, which now begins to charge \$C_1\$ moving the voltage at the timer's \$THRH\$ input downward towards ground (over time.) When the voltage at the timer's \$THRH\$ input reaches some threshold, the timer circuit shuts off and inactivates its \$OUT\$ pin causing it to become high impedance. When this happens, the load itself then pulls downward on the top end of \$C_1\$ causing the load to lose its supply voltage but also pulling the top end of \$C_1\$ to ground. (It uses the applied load itself to do that.)

Unattended, this sudden turn-off behavior would cause the voltage at \$THRH\$ to become quite negative and to slowly discharge through \$R_3\$. If left unattended, this would be a serious problem. However, within the timer circuit there is a diode (\$D_2\$) which discharges \$C_1\$ quite rapidly and allowing the timer circuit to be completely reset in very short order, ready for a new switch event to take place.

However, there is a D-type flip-flop circuit now which gets a clocking signal every time \$SW_1\$ is engaged. It toggles between two states: inactive and active. The inactive state has \$\overline{Q}=+12\:\textrm{V}\$ so that \$Q_2\$ is off. The active state has \$\overline{Q}=0\:\textrm{V}\$ so that \$Q_2\$ is turned on via \$R_5\$. When active, \$R_4\$ supplies a strong pull-up and overwhelms \$R_3\$, forcing the timer's \$THRH\$ input to be held high and keeping the timer circuit active. But when inactive, \$R_4\$ does nothing and the timer circuit is allowed to operate normally.

Together, this provides the instant on behavior and delayed off behavior.

For the whole circuit to power up inactive, it does require that the D-type flip-flop also powers up in its inactive state. An additional RC timing circuit could be added to the RESET input in order to make sure this happens (not shown.)

Note: \$D_3\$ and \$D_4\$ isolate the timer circuit from the flip-flop circuit, allowing them to each observe \$SW_1\$ independently without interfering with each other.

  • \$\begingroup\$ Thanks for the circuit, it looks a lot (more elegant) less complicated than my efforts. Re. the CD4013B; just to clarify, the pins used are 1 (Q1), 2 (Q dash 1), 3 (Clock 1) and 5 (Data 1)? Re. the BSS145, I have found them to be quite expensive (the ones I have found are over €10 each delivered), is there an alternative? Re. the T=RC pair (R3-C1), is it better to aim for a larger R value so C will be smaller? \$\endgroup\$ – Barnys May 11 '17 at 8:50
  • \$\begingroup\$ Also, I recall reading that it is better to use something other than electrolytic capacitors because the leakage from electrolytics may interfere with the discharge/time, although the cap in this circuit isn’t polarised I am wondering, what would be an “ideal” type of cap for this role? \$\endgroup\$ – Barnys May 11 '17 at 8:50
  • \$\begingroup\$ @Barnys I just picked the BSS145 out of the blue. I don't know what you can find cheaply, so you tell me what you have available. Chances are it will work okay. \$\endgroup\$ – jonk May 11 '17 at 15:57
  • \$\begingroup\$ @Barnys Regarding the resistor and capacitor, sure. At some point the leakage in the board and parts, dirt, humidity, and a lot of things start to come into play. So you can play the game of using "as high a value for \$R_3\$ as possible, but no higher" if you want. From a theoretical point of view it all just works. But reality impinges and there will be a point where you won't like the results anymore. I tried to pick a rational balance and to select a resistor value that is cheap and easy to find, too. The cap leaks too, but not so much that you should be worrying here, I think. \$\endgroup\$ – jonk May 11 '17 at 16:00
  • \$\begingroup\$ How about a BSS138 it looks like the same thing but @ 50V it is 15V less than the BSS145. Also, would a 2N7000 work? \$\endgroup\$ – Barnys May 12 '17 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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