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.
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.
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/)