# Keep relay energized longer with capacitor [closed]

OK, I've found plenty of questions about relays where either the person wanted to have event 1 at time T trigger the relay at time T+delay (like flip a switch and have the relay energize 2 seconds later. Simple enough with a single-triggered 555 or such.) I've also found people who wanted a single event to trigger the relay but have the relay stay energized for a time after the event happened (so that a 1ms pulse from a MCU may cause a relay to stay on for 2 seconds. Again, simple enough with a cap connected to the gate of a transistor.) What I'd like is a good way to energize a relay that then kills the power to the WHOLE circuit and holds that for a bit longer.

Basically, the idea is for a watchdog circuit for a X Pi board. A 555 or a MCU (attiny85) could watch for pulses on one of the Pi's GPIO pins. When it fails to get the pulse in time, it energizes a relay that's NC so that it kills ALL power to both the Pi AND the watchdog. But I'd like to stretch that off-time out by a few more milliseconds just to make sure things have time to reset OK. So I can't use a cap connected to a transistor connected to the relay as when the power dies, it dies for the coil as well. I'm figuring a cap parallel to the coil would hold it for a brief time but what's the best way of wiring it to charge the cap (somewhat) slowly and also to keep it charged and the coil energized as long as possible after the power dies? The exact time it's held open isn't important so don't worry about the math and figuring out "well, a 1f cap and a 200ohm resister would hold it open for XXXX milliseconds if the coid resistance is 150ohm", etc. I'm just looking for the general circuit that would work best.

edit 1...
This is the basic idea of the circuit in mind (and yes, I didn't wire up the 555 completely here. I was mainly wanting to show the output and how the power would go to it.) And to answer Bruce's question(s), when I say "as long as possible", I meant "given any set of available parts of arbitrary values, what arrangement would allow them to keep it energized as long as possible for that set?" So if the question was a simpler "what would keep a cap charged as long as possible in a circuit with a resister and yet still drain it?" the answer would be a simple series RC circuit without worrying about the size of the cap, the value of the resistor or what constitutes "as long as possible." I realize probably under reasonable sizes of a cap, I probably wouldn't be able to delay the relay more than a few extra microseconds so I'm not looking for a 2-hour delay or such.

The relay I planned on using is http://old.ghielectronics.com/downloads/man/20084141716341001RelayX1.pdf (basic stats: 5v relay, coil resistance about 50ohms, dropout around 0.5v.) So if my math is correct, a 100uf cap would be a 1RC of around 5ms, so that's about the longest I'd expect to be able to hold the relay open past its own operational delay with that sized cap. I do have a couple of 1f super-caps I could use as well but charging them may be tricky.

edit 2...
BTW, yes, I did leave out the flyback diode on my initial schematic (was just in a hurry.) The relay module I was planning to use is basically like this one (except that I only see one resistor on it, not two. Image is from http://www.electroschematics.com/8998/arduino-temperature-controlled-relay/)

• "...keep it charged and the coil energized as long as possible" - that could be a very long time! "... I'd like to stretch that off-time out by a few more milliseconds" - this is a more reasonable specification. What is the minimum time that you think would be sufficient? – Bruce Abbott Jan 7 '18 at 7:20

You need a capacitor on the watchdog power supply, otherwise the relay will cut power to itself before being fully operated and its contacts will rapidly fall back to the NC (Normally Closed) position.

The Pi normally draws a lot of current which you don't want taken out of the capacitor, so you also need an isolating diode. A Schottky diode should have low enough voltage drop to allow the use of a 5V relay.

simulate this circuit – Schematic created using CircuitLab

The release voltage of a relay is usually much lower than its operate voltage, due to the smaller air gap and resulting stronger attraction of the armature to the core when operated. So provided the capacitor can hold its voltage up long enough to fully operate the relay, it should be able to keep it operated for a significantly longer time.

A typical 5V relay with 5A contacts might have a 50Ω coil, 6ms operate time and <1V release voltage. The formula for capacitance is C=I*t/V. So if you needed eg. 6ms with 0.5V drop (4.7V to 4.2V) at 90mA, the required capacitance would be 0.09*0.006/0.5 = 1080uF. As a capacitor discharges the current and voltage reduces exponentially, so the time to reach 1V would be much longer.

Hopefully the 555 will keep the relay operated until the capacitor has discharged to a low voltage. If not then the flyback diode (D2) should slow the relay's release time by recirculating current through the coil.

To ensure that the Pi's supply voltage goes down to zero rapidly you could also wire a low value resistor from the relay's NO (Normally Open) contact to ground.

As an alternative to a mechanical relay you could use a Solid State Relay or MOSFET. These options would have much lower holding current so the capacitor could be made much smaller, and they should be more reliable. You might also consider keeping the watchdog circuit powered continuously and pulsing the relay, as this would solve the problem of how to hold the voltage up long enough to do a proper reset.

• Thanx, @bruce, this is basically the sort of feedback I was looking for. The placement of the cap was basically what I was already thinking of but I wasn't thinking of the (Orange, in this case) Pi also draining the swamp - err, "capacitor" - so the diode would definitely help there. I'd also thought about having the watchdog powered separately but was considering just powering it off the 5v pin on the Pi to make wiring easier and don't mind if it got reset at the same time. Not really sure just how long of a power-loss the Pi would need to really drain it and get a good reset, though. – Mike Anderson Jan 8 '18 at 6:07
• "was considering just powering it off the 5v pin on the Pi" - but you have to insert the relay contact into the power line anyway, so just tap the watchdog power off the input side of the relay contact. "Not really sure just how long of a power-loss the Pi would need to really drain it and get a good reset" - due to its high current draw I think the Orange Pi would drain its 'swamp' pretty quickly. Still it might be best to give it a nice long power off to ensure that all peripherals are properly reset. – Bruce Abbott Jan 8 '18 at 7:19

Using a thyristor (aka SCR) or a triac instead of the coil switch (M2 in Bruce's diagram) could allow eliminating the 555. These switching devices can be triggered with a short duration gate pulse, and only stop conducting once the main path (A-K or MT1-MT2) current falls below a threshold.

You'd want to find a device whose max holding (stay-on) current is lower than the current at which the coil has been on long enough to meet your other needs.

• The 555 is needed to kill the circuit if the Pi locks up. I didn't wire it fully (nor did Bruce) but the idea is that it'd trigger the relay off after say 10 seconds. If the Pi is working, it'd send a pulse to the 555 every 1 second to reset it. If the Pi fails to get that pulse, it eventually triggers and energizes the relay, thus opening the circuit and killing all power to it. An SCR or triac (which I don't have) could replace the relay (which I do have) but I don't see how the 555 could be replaced (other than by some other vibrator circuit.) – Mike Anderson Jan 8 '18 at 6:13
• Sure. I see now that you described the watchdog keep-alive pulse objective in your original post, so, my bad. – Neil Schipper Jan 8 '18 at 8:18