Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Survive power off?

Status
Not open for further replies.

SystemsGuy

New Member
Hey guys - reviving a dead project I gave up on long ago. I'm trying to design a circuit that takes specific actions based on duration power failure. Pretty straightforward, it's a 12vdc circuit, and I want to be able to take different actions depending on the duration of the power loss at 15 second intervals up to one minute. So action "a" if < 15 seconds, "b" > 15 < 30, etc.

Complicating this is the fact that the power supply I'm trying to measure outage on is the same one that powers the circuit, and that I don't have the ability to add a battery to the mix - even something as basic as a RTC would make it non-viable. It's also got to fit into a very small physical footprint of about 3cm x 3cm x .5cm. I started this with a tiny13 (dating myself I guess!), but never managed to figure out how to make it survive the outage and then "know" that it both "had" and "how long" it had been out.

I'm a digital sorta guy, so trying to get my head around how to accomplish this - I was thinking a capacitor with a know decay rate, or something along those lines, but rapidly got out of my depth.

Any clever ideas? I'm not really concerned about loss > 1 minute - would be "nice" to know that there was a loss > 1 minute, but not really critical.

Thanks!!
 
Last edited:
You need something to store some power, otherwise it's something for nothing.

If you are willing to wait until power comes back on to know how long it has been off then perhaps something like your capacitor could be used.
 
Last edited:
Hey ronv - sorry, getting late and I've run out of coffee! To maybe be more clear, I'm only concerned about "doing" something when the power returns - so "power off" - delay - "power on" - "act on length of outage".


Thanks!
 
Let me just think out loud and see what you think.
The capacitor could be charged thru a diode so that when the supply goes down it doesn't discharge the cap.
Across the cap to set the discharge time you could put a large resistor. So lets say 100 Ufd. and 1 Megohm for 100 second time constant. The first time constant is fairly linear so maybe the error is okay. You would probably need to calibrate out the tolerances. Is that okay?
Once power is restored you could read the cap with the A to D in the micro. I need to check if the A to D could read it directly. It may need to be buffered so as not to discharge the cap with the A to D.
Hmm. might work.;)
 
I like the way you think - and I found some coffee! This one has been doing my head in - so let me talk through it as well while the coffee kicks in.

Circuit's got power, so cap charges. Circuit looses power, cap starts to decay a known rate. How do I prevent the cap from charging long enough to actually detect that something has happened?

I'm probably over thinking this, but in a "worse case" scenario, device might only have a few seconds of power before power drops, then comes back on within my "do something" window?

I may be wandering down a rabbit hole now! :p In the simplest terms, the system I'm monitoring will have frequent failures, and long outages - if they are longer than a minute, I can assume - for lack of a better word - a "cold start". If failed for 15 seconds, I need a "semi-warm start", 30 a "not so warm start", and 45 a "almost cold" start...
 
Hey Bionic - I can sure try! ;-)

So in the simplest terms, this is a "power failed" detector for lack of a better way of describing it. Sequence is as follows :

1] Power applied to circuit - perform "cold start", switch to "on" mode.
2] Power fails. Circuit somehow keeps track of duration of failure up to one minute.
3] Power resumes - check duration of outage. If less than 15 seconds, "warm start sequence", then switch to on. There are really 3 or possibly four modes, up to power failed for > 1 minute that I would like to take action on - basically at 15 second increments on the outage.

My brain needs less coffee and more sleep at this point - I had pretty much consigned this to the dustbin until I ran into a friend who had picked up a "brake flasher" module for his car that did damned close to what I've described above - basically it can be programmed to flash the brake light in a specific sequence, and also - ONLY flash the sequence again if a programmed delay is exceeded - so "hit brakes, lights flash", "hit brakes again in < xx seconds, no flash".

It's like a perfect storm - somehow this is doable - and it meets all my constraints - module is powered by the circuit it's monitoring, is in a tiny package, short duration power on/off/action/on sequence, etc.

My need is really close to what this thing is doing - loads of cycles, short duration / long duration power cycles - as I said, to see the damned thing so close it's killing me! :)


EDITED : On the above sequence - probably important to mention that the power may last of only a second or so, before failing again - so -

1 second of power <> 5 seconds no power <> power back on, do action based on power loss < 15 seconds

xx seconds of power <> 16 seconds no power <> power back on, do action based on power loss > 15 seconds.

1 seconds of power <> > 60 seconds no power <> power back on, "cold start".
 
Last edited:
power off save

Something like this might work. A lot depends on how the micro acts on power off, but might be worth a try.

On power up you sample the cap. Right after that you turn the circuit back on so the cap can re-charge.

The micro on power on needs to hold the circuit in the off state. This should be ok since the FET needs a + to turn on.
 
Hey Ron - thanks, I'll give it a shot and see what trouble I get into! :) I've just been told that I'll be traveling for the next three weeks, so not sure if I'll have time to throw it together before I'm back, but looks like a start!!
 
The cap discharge method suggested above looks plausible. Can't think of any realistic alternative. For reliable results the cap would need to be one with negligible internal leakage, or else with consistent leakage that you could calibrate around. Probably rules out an electrolytic; so implies a few uF max and a correspondingly very high value bleed resistor.
The spec for the PIC16F87x analog input quotes a pin leakage current of 500nA (which presumably only applies once the PIC power has been restored, and only then if the pin is selected via its transmission gate). However, if the analog input pin has protection diodes to both rails (as CMOS logic has) before the transmission gate, then the diode to Vdd will discharge the cap completely when the power goes down. So I think a FET buffer between cap and micro (PIC or other) will be needed.
 
Rather than using A/D another possibility would be to charge 4 caps (the attached circuit shows only 2) instantly when power is on and allow them to discharge at different rates when the power goes down. Use CMOS Schmitt gates to give a binary indication of charge state. Use an anti-discharge diode in the Vdd supply to the CMOS IC so that the protection diodes don't discharge the caps :-
View attachment 65321
(An anti-discharge diode could also overcome any protection-diode problems with a micro's A/D converter)
 
Hey Alex, next time I'm in Cardiff I'll have to buy you a pint!

Looking at the level of complexity here - and with a good nights sleep and some coffee - maybe I'm wandering down the wrong path trying to "detect" the outage, and would be better served by surviving it? Since anything > 1 minute fails back to "cold start" mode, I really only need to survive for that minute, right?

Some of the ATTiny's are damned power efficient - what are the thoughts about surviving the outage with a small super capacitor? As I said before, I'm much more of a programmer than an electronics guy, so I may be way off base here. Don't know if I could even charge the capacitor fast enough to catch the "one second on, survive one minute off" sort of worse case scenario?
 
That might actually be the easiest. If you can use like the Tiny 13A and run it slow you could keep it alive for quite some time with just some large standard capacitors.
 
That might actually be the easiest. If you can use like the Tiny 13A and run it slow you could keep it alive for quite some time with just some large standard capacitors.

You mind throwing together a simple circuit for me? I assume it's not as easy as just sticking the caps across the supply lines with a couple of diodes?
 
Tiny Supply

You probably need a regulator to step down the voltage to something the Tiny can use so here is one using a LM317. It could just as easily be a 7805 and the Tiny would tun at 4.4 volts.
I don't know what you need to do with the Tiny output but the lower the voltage and the slower the clock the less power they take.
It would be a good idea to put a small heatsink on the regulator even though the high power is only for 1/2 second or so.
Double check me on the Tiny current requirement.
 
Last edited:
Hello,


My take on this is that you should have some sort of simple low power battery backup. There are a couple ways to do this.

1. Rechargeable NiCd's arent too bad of an idea and you can time the power 'off' duration with a simple uC set to power up every 10 seconds and count off the time. This would work pretty well.
2. Large cap combined with battery backup clock or atomic clock. When the power goes down, the circuit stores the time of day and maybe the date. When the power comes back up the circuit sync's to the atomic clock and then subtracts the stored time from the current time--that's the time it has been down. This would be harder to implement.
 
Thanks for the input guys. One of the reasons I'm hesitant to add a battery is that this device is designed as part of a system that's deployed in the field, and in general never visited again, with pretty extreme temperature variation.

I'm more and more thinking that building a minute's worth of power into the system is a "better" solution that trying to detect that it happened and the duration after the fact.

A Tiny85 is probably the route I'll wander down - amazing how much you can get in out of a ATTiny these days!


Logic flow will be something like -> Power on, start timers, do action, go low power mode, watch timers, check power, if power off, set start time, when power resumes, reset counter, take action on result.


One other question while I've got y'alls attention - one of the device triggers is to interrupt a leg of a power supply, +12vdc, 300ma. I was thinking to use a transistor to do this. Since 99.99999% of the time this is going to be "on" - is there a "best practice" way of designing the interruption circuit? Eg since it's normally "on", and I want to briefly turn it "off", is their a "best theory" way of doing this? In a prefect world I'd like to have the flow continue if my bits fail! ;-)
 
Last edited:
If it doesn't need millions of cycles a normally closed reed relay might be the ticket.
 
If it doesn't need millions of cycles a normally closed reed relay might be the ticket.

Since this is a "fire and forget, extreme environment" sorta think, I'd like to keep it non-mechanical if I can. Was thinking using a MOSFET for the legs, but really was tying to think things through -

I guess what's I'm asking is "What's the smartest way to failure proof?" this concept - in a perfect world, I'd like to have the "rest" of the circuit work even if my part of the control dies. So was wondering "how do I use a MOSFET in such a way that by default allows power to flow, and my circuit has to actively do something to turn it off....

Again - thanks for all the advice - it's great to have someone to bounce ideas against - my wifey just goes all glassy eyed when we move from software from hardware - at least I have that!!
 
Assuming you use a low-side NMOSFET you could have the gate biased high by a resistor and your bits when active could pull it low as required.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top