Detecting presence of mains - Page 1
Forum section: electronics / beginners

author: chaseadam
author_rank: Contributor
timestamp: February 14, 2014, 06:42:41 am
content: I discovered a few ideas for detecting the presence of mains from another forum. Hero999 (which I believe is the same Hero999 on the other forum where he is now "banned") mentioned using leakage current from some Y1 capacitors with a bridge rectifier. I like the elegance of this solution.I wanted to follow up specifically about what happens to the excess current in the following circuit (ripped off from Hero999)Hero999 mentioned R1 is only to ensure the MCU pin is pulled down.The diode means the MCU pin should never rise past 0.6V above the 5V rail, but what happens to the excess? I imagine the 5V circuit (12VDC in my case) will consume the remaining current, but what would happen if there were not to consume (all of) it?I believe the voltage on the 5V rail would rise and that pull down resistor will sink more current as the voltage rises on both sides of D1?I am interested mostly because I have 4.7nf Y1 capacitors which will provide more leakage. It was not straight forward how to calculate the leakage for capacitors connected directly to the mains.Background. This is for a delayed off latched relay circuit. I have the 555 circuit completed which will provide the off delay. I need to pull one pin high and another low when mains is active so I can reset the 555 and hold the capacitor at 0V until the power is removed. It will be controlling a 55W 120V blower with a power relay.Thanks!

author: Dave
author_rank: Super Contributor
timestamp: February 14, 2014, 03:23:14 pm
content: I would prefer to use an optically isolated circuit for detection, so your low voltage circuit is completely isolated from the mains.Here is a solution with an opto-coupler that I would use:The green graph is the mains voltage scaled to 1/100, so it's easier to compare it with the output.C1 and R1 are there to limit the current, R2 is there just to discharge the capacitor after you unplug the device. The four diodes can be replaced with a small bridge rectifier.If you don't need to detect individual pulses, you can just add a 1uF capacitor from the output node to GND.DO NOT ground the one of the nodes of the mains input.I had ground that node purely for simulation.

author: amyk
author_rank: Super Contributor
timestamp: February 14, 2014, 10:21:13 pm
content: If most of the circuit is going to be nonisolated by necessity then it makes more sense to use a capacitive supply like what you have to power everything; you just have to make sure the user isn't exposed to the circuit.AN954has some useful information.

author: chaseadam
author_rank: Contributor
timestamp: February 14, 2014, 10:47:53 pm
content: That is a good app note!A friend of mine suggested that I switch from the relay to a Triac with a a resistor/capacitor for delaying the release of the gate. I decided to add a MOC3061 to get some zero crossing goodness (not that I am going to be turning it on and off all that often). Much simpler than the 555 circuit. Going to give it a try.

author: Riotpack
author_rank: Regular Contributor
timestamp: February 15, 2014, 01:38:59 am
content: If you want a one part solution, why not use something like this?http://www.ebay.com.au/itm/10A-240V-AC-Load-220-240VAC-Coil-Voltage-Electromagnetic-Relay-DPDT-LY2-J/360829682372?rt=nc&_trksid=p2047675.m1851&_trkparms=aid%3D222002%26algo%3DSIC.FIT%26ao%3D1%26asc%3D261%26meid%3D4842230921267377542%26pid%3D100005%26prg%3D1088%26rk%3D1%26rkt%3D5%26sd%3D151207586337%26

author: tszaboo
author_rank: Super Contributor
timestamp: February 16, 2014, 12:31:08 am
content: If you put a wire close to the mains cable, preferably heat shrink them together for 5 cm, and you connect the other end of the cable to a NOT gate, with some diode protection, that will also work.

author: Zero999
author_rank: Super Contributor
timestamp: February 18, 2014, 08:25:44 pm
content: Calculating the leakage is fairly straightforward.XC= 1/(2pi*FC)I = V/XCF = 60Hz presumably you're in the US?V = 120C = 1*10-9XC= 1/(2*3.15*60*4.7*10-9= 564kI = 120/564k = 0.0002126 = 213µAThis is too low to feel.The other ideas: opto coupler and relay are both good and will work. Wrapping a wire around a piece of mains cable will also work but it will depend on the polarity of the mains and you need a good ground plane.