Pages: 1 [2]   Go Down
Author Topic: How to detect power failure?  (Read 4601 times)
0 Members and 1 Guest are viewing this topic.
Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4094
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@Techone, thanks, that was actually just a circuit I'd found on the web, hadn't tried it or analyzed it.  I may try it yet, as it is an interesting approach, but for now, for several reasons, I think I'll go with the second-wall-wart approach.  If I do try it, I'll report back with my findings.

Regarding your analysis, not sure what you mean by "C is 0k has long it is well above 200 V" ... If I calculate the reactance of a 0.22μF capacitor at 60Hz, I get a touch over 12KΩ.  I didn't look up the PRV for a 1N914, but if memory serves it's 75V or so, which is probably way more than that of the LED.  But neither diode will ever have a reverse voltage across it that's more than the forward voltage of the other diode, so I don't know why a 1N914 wouldn't work.  It could also be a second LED.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@ Jack

Technicaly, the C - capacitor is not needed in that design, ( you don't have a DC component to block - a telephone line is yes ) Here a site about telephone interface http://www.epanorama.net/circuits/telephone_ringer.html ( I know it is unrelated, but in a way they are )

About "wall-wart", get some "free" from the garbage or a cheapy , took apart with a metal saw ( do it carefully ) Extract the transformer. I forgot that a 1N914 is OK, has long is connect in serie with a power resistor.  ( Just my last posting )  The V drop should be the same has V led. Just my calculation for the LED ( positive swing of the AC wave ) and 1N914 ( negatiev swing of the AC wave )

And for more protection, add a fuse of 200 V @ 250 mA in serie ( in-line ) with the circuit.

So it should be --   Fuse - power resistor  -- Diode // LED ..  That it ! According to calculation, it should work. 
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4094
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@Techone,

Beg to differ, the capacitor is by far the main component responsible for limiting the current, it's not about blocking DC, or telephones for that matter. Build it without the capacitor and see, but I'd include a 1/4-to-1 amp fuse on the incoming line just for extra safety.  I also might Google up some AC circuit theory.

Anyway, old habits die hard.  I guess I can't analyze a circuit even partially and then not go into the lab and build it.  Since I had the parts available...

Turns out this circuit is just about perfect for powering the average garden-variety LED.  My standard LED dropping resistor when working with 5V is 330Ω, which results in 9mA or 10mA current through the LEDs I use.

I’ve had this circuit happily glowing here on my desk for a couple hours now without incident, nothing seems to be getting warm, etc.  I’d think the 1/6W 1K resistor might heat up a bit, as my calculation says it should be dissapating ~100mW or about 60% of its rating, but if it is, I can’t tell.  Still, I might prefer a 1/4W resistor just to be extra conservative.

I took the following measurements, all are AC RMS:
    Vin = 119.9V (wow, the utility company is right on the money today)
    Vcap = 119.0V
    Vdiodes = 1.318V
    Vr = 9.91V
    Iin = 10.1mA

Attached is a picture of the circuit, along with an identical LED powered from a 5V regulated supply with a 330Ω dropping resistor (on the right).  The AC-powered LED is not quite as bright, which stands to reason since it’s only on half the time.


* IMG_2626b.JPG (152.14 KB, 900x675 - viewed 36 times.)
« Last Edit: August 11, 2011, 12:35:40 pm by Jack Christensen » Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well..Well ..Well .. I am surprise... You design using a cap to take the biggest voltage drop work. My design use a power resistor. Your is a good one. No power resitor to buy.  So you use this :

 Reactance of Capacitor =  1 / ( 2 * PI * 60 Hz * 0.1 uF )  = 26 525.823 ohms <--- Interesting

I will never taught of this idea. I am still  learning ... You surprise me. 

Bear in mind, the LED still "flashing" @ 60 Hz.  You just need to connect an opto-coupler instead of the LED. A 4N35 will work fine. 

Quote
Anyway, old habits die hard.  I guess I can't analyze a circuit even partially and then not go into the lab and build it.  Since I had the parts available...


I use computer electronics  simulators to check some of my designs. And I test for real.   Here the link for the simulators I use.
http://www.falstad.com/circuit/  <--- It free but can not save & print.
http://www.new-wave-concepts.com/  <--- I use Circuit Wizard Pro ( Cost me about $300 can ) Yeah ! But it was worth it .
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4094
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@Techone,

That's it! It's quite a clever circuit, isn't it! Now the really cool thing (literally) is that it limits the current without generating heat, i.e. wasting power. The 0.22μF capacitor, with a reactance of about 12KΩ, dissipates effectively zero power. Sure, we could use a 12KΩ resistor instead, but assuming the same current of about 10mA, that resistor would dissipate about 1.2W; as you observed, a 2W resistor would be appropriate. The circuit with the capacitor only wastes about 100mW, not counting the power consumed by the diodes, so it wastes only about 8% of the energy than would the circuit with the resistor.

I was still wondering what the 1K resistor was for, technically it's not needed, the capacitor alone should be enough. Then I thought about failure modes, and I'm thinking it may be to limit current in case another component in the circuit (especially the capacitor) fails. The worst failure modes would involve a component shorting out. In this circuit, the diodes are the most fragile components and effectively act as fuses. If the capacitor failed and became a dead short, without the 1K resistor, we'd have 120VAC straight across the diodes. It wouldn't last long, but there could be a few fireworks. With the resistor, the diodes would still fail, but in a much less spectacular manner, opening the circuit and resulting in a safe condition. If any other component in the circuit failed by shorting out, there would be effectively very little change in operation, the circuit would continue to draw ~10mA and would still be safe.  And of course if any component failed by going open-circuit, then the current stops and things are still safe. So I think whoever originally designed this circuit thought it through a bit!

Now to delve into AC circuit theory a bit more, consider the fact that going around the circuit and adding up the observed voltage drops across the various components results in a total that is greater than the input voltage, i.e.

    Vcap + Vdiodes + Vr = 119.0 + 1.318 + 9.91 = 130.2 > 119.9 input voltage

Have a great day!  smiley

Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4094
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just circling back with my final solution. After thinking about the second-wall-wart idea, I abandoned the idea of using a DC signal to detect a utility power failure. Until I put the thing in practice, I probably won't have a feel for how brief an outage I'm actually interested in detecting (but below some minimum, I won't worry about it). With a wall-wart, there are filter capacitors involved, not sure how long they'll last, the MCU pin is effectively no load, so need a resistor to load it, have to figure time constants, etc. etc.

Much easier with an opto-isolator where the LED is driven direct from the AC line, using the circuit I posted earlier in the thread. I think this is quite a safe circuit, and of course it effectively keeps the mains voltage away from the MCU, etc. Connected the collector from the opto transistor to the INT0 pin and turned the pullup on, so while the power is on, it'll generate 60 interrupts/second. The main loop simply counts milliseconds since the last interrupt, and compares it against a threshold value, so very easy to change, and easy to set quite accurately. The ISR is one line of code, simply setting a variable to zero, so very minimal impact to other processing.

It's running as I write this, counting cycles per second, mostly giving a boring string of 60s, but it gets interesting once in a while. I just saw a string of 12 or 15 61s in a row, with a couple 63s or 64s thrown in. Also see the occasional string of 59/61 pairs which is probably just random phase synchronization between the MCU clock and the line frequency. I've heard that power line frequency is very, very accurate over the long term because they count the cycles and adjust accordingly, but it can be off a bit at any point in time. Looks like that is indeed the case given my small sample here.


* opto.png (11.46 KB, 780x450 - viewed 190 times.)
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9750
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In industrial settings where things have to work, battery powered emergency lights are operated by a simple relay. With ac available the relay that controls power to the light stays open. When power is lost, the relay fails closed supplying battery power to the light. Simple and reliable. Instead of powering a light, the closed contact could be used to provide on/off info to the arduino. 
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4094
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

In industrial settings where things have to work, battery powered emergency lights are operated by a simple relay. With ac available the relay that controls power to the light stays open. When power is lost, the relay fails closed supplying battery power to the light. Simple and reliable. Instead of powering a light, the closed contact could be used to provide on/off info to the arduino. 

That's a clever solution, someone actually mentioned it earlier in the thread I think.  Relays are relatively large and expensive, though; I think I might have $0.70 in the four components here (over half of which is probably the capacitor, which I find odd). With no moving parts, should be pretty darn reliable. I suppose the opto-isolator could fail, maybe its LED might die some day. I will be immediately aware if that happens, and finding the fault should be straightforward!
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17307
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A relay with multiple contacts, can also be wired such that the power failure state can stay 'latched' in the AC failed mode until a manual push button is pressed to reset the relay once AC power returns. This is useful in some cases where you want to not just depend of returning AC power to restart some systems.

Often the return of a AC power failure can be quite unstable for a few seconds, false starts, surge voltages, brown voltages, etc. A latched power failure detector with manual restart can be the best way to 'restart' some system and devices.

Lefty

Logged

0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9750
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Relays are relatively large and expensive, though;

Depends on where you buy and the type of relay used (5-6v relays are less than $1 when mail ordered). If you already have a wallwart, it can be used to power a small DC relay. If you have a photo resistor (RS may still carry these), you could combine it with a $1 LED night light from the Dollar Tree store (where everything is just $1) for power loss detection.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4094
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting item on the accuracy of the power line frequency.

http://catless.ncl.ac.uk/Risks/26.49.html#subj6
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

From my experience,  aka I wondered if it'd work, you can power a led directly from ac mains with as little as a 20k resistor
I used a r of about 18k in series with the led and it worked fine, the resistor got warm but not hot,
now its probably not the safest or most relible but its real cheap to just set the one led up to the mains and tape another directly opposite as an optoisolator to the arduino,
the color of the led used will be the output voltage, I find that uv works best since it puts out about 4 volts
Logged

Pages: 1 [2]   Go Up
Jump to: