Pages: [1]   Go Down
Author Topic: How to detect loss/presence of AC mains?  (Read 909 times)
0 Members and 1 Guest are viewing this topic.
Canada
Offline Offline
Newbie
*
Karma: 1
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need some help to detect loss/presence of AC mains. 24VAC runs into an input pin, through 100k resistor=1/2 wave.

I thought of missing pulse detect by having a timer overflow if AC didn't appear and clear the timer. The timer starts on a rising edge. But if AC is not (initially) present, the timer never sees an edge and just sits there?

It looks like 8-bit TMR2 is available= 16.32msec overflow (16MHz clock and prescale/1024, count of 255) so it's too fast for 60Hz 1/2 wave  smiley-cry
Anyone have suggestions for an algorithm...




Logged

West Des Moines, Iowa USA
Offline Offline
Sr. Member
****
Karma: 2
Posts: 428
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

A while back I saved a circuit for a mains-powered LED circuit (attached) - I'm not a circuits guy, but wonder if the LED could be the input side of an opto-isolator, and if the detector side could be connected to your Arduino...


* 115VAC-LED.png (8.8 KB, 478x212 - viewed 61 times.)
Logged

There's always a better way!

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

@Morris Dovey

Yes, it will work. But it is missing a two zener of 24 V  connect in serie. 

Like :   Cap ---- C -Zener - A -- A - Zener - C --  to led / diode. 

Telephone ringer is almost the same circuit. Except the circuit have zener diodes.  ( I open a few electronics phones to find that out )
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23835
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How long does it need to be missing for?
Add a diode rectifier to your transformer and a low pass filter, then watch the analog level.


* AC_detector.jpg (35.61 KB, 960x720 - viewed 53 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Edison Member
*
Karma: 57
Posts: 2193
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This has come up a lot lately.
You don't want zero-cross == no ac.
You don't want something so slow that an actual drop out is missed or detected late.

Using XC, you don't need a resistor, just a diode across the LED (opposite polarities).
Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

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

I've always liked the use of a simple 120vac relay as a drop out detector. Contacts are completely isolated from the AC power and a small lower mass relay should drop out in one or two cycles of the 16 millisec period of a 60hz cycle.

Logged

Austin, TX
Offline Offline
Full Member
***
Karma: 0
Posts: 134
I make my own electricity.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The OP needs to define how long "Off" is before coming up with a solution.

Here in the States, most utilities set the automatic reclosing circuit breakers so they reclose after an overload (or lightning strike) in 3 to 6 cycles -- 3 seems to be the most common, and probably so 3-phase power goes through enough cycles.  I have to assume that wherever the OP is that they have 240 volt supply at the mains (probably 230/400 3-phase for the system power) that their utilities also reclose after 3 cycles or so.  Which means ... anything more than 3 cycles is a real power outage.
Logged

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

@jfhaugh

Quote
I have to assume that wherever the OP is that they have 240 volt supply at the mains (probably 230/400 3-phase for the system power) that their utilities also reclose after 3 cycles or so

I notice the OP fill out the location in his/her profile... Canada.   Therefore, North American system...

The OP want a code "example" of : if no pulse ( at the ouput of the opto-coupler ) for a lengh of time.... do something ....
« Last Edit: February 26, 2012, 12:12:19 am by Techone » Logged

Austin, TX
Offline Offline
Full Member
***
Karma: 0
Posts: 134
I make my own electricity.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@jfhaugh

Quote
I have to assume that wherever the OP is that they have 240 volt supply at the mains (probably 230/400 3-phase for the system power) that their utilities also reclose after 3 cycles or so

I notice the OP fill out the location in his/her profile... Canada.   Therefore, North American system...

The OP want a code "example" of : if no pulse ( at the ouput of the opto-coupler ) for a lengh of time.... do something ....

Yeah, I also see that the "240" I thought I read was a 24VAC transformer.

They should wait 3 full cycles before assuming the power is out, unless they want to see "power outage" indications all day long.  My system picks up an AC line loss after two cycles, and I see a lot of "blips" that were fewer than 5 or 6 cycles in length.

With that in mind, I'd wire up an external crystal for the timer2 oscillator and use the on-chip oscillator for the uPC itself.  I don't know how the clock source is determined, so someone else will have to answer that question or tell you that I'm all wet.
Logged

Pages: [1]   Go Up
Jump to: